Memory resource allocation method, resource allocation platform, computing device and computer readable storage medium
By parsing the kernel information in the virtual machine's memory resources and determining the target physical pages in the idle state, the isolation and security issues caused by directly intruding into the user's virtual machine are resolved, and imperceptible memory resource reallocation is achieved, ensuring the isolation and security of the user's virtual machine while avoiding performance impact.
Patent Information
- Application Number
- CN202410288980.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-13
- Publication Date
- 2025-09-16
AI Technical Summary
In a virtualized network cloud platform, directly intruding into user virtual machines to reallocate memory resources will destroy isolation and security and affect virtual machine performance.
By parsing the kernel information in the virtual machine's memory resources, the target physical page in the idle state is determined, and memory resource reallocation is performed without the user virtual machine's awareness, avoiding direct intrusion into the user virtual machine.
Memory resource reallocation is achieved without the user virtual machine being aware of it, ensuring the isolation and security of the user virtual machine and avoiding performance impact.
Smart Images

Figure CN120653410A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of cloud technology, and in particular to a memory resource allocation method, a resource allocation platform, a computing device, and a computer-readable storage medium. Background Art
[0002] With the development of cloud technology, memory can be flexibly allocated to user virtual machines in virtualized network cloud platforms, effectively improving the utilization of virtual machine memory resources. This fully reflects the scalability, high availability, and sharing characteristics of network clouds, and has been widely used in many fields, such as big data, the Internet of Things, and artificial intelligence.
[0003] Currently, virtualized network cloud platforms widely use input / output (I / O) passthrough technology. When user VM I / O devices use Direct Memory Access (DMA) to access VM memory resources, flexible memory resource allocation can lead to memory conflicts, high complexity, and insecure access. To address this issue, a specific detection module is injected into the user VM to directly detect idle physical pages pre-allocated to the user VM and reallocate memory resources.
[0004] However, the above-mentioned method of directly intruding into the user virtual machine will destroy the isolation and security of the user virtual machine in the network cloud platform, and the injected detection module will affect the performance of the user virtual machine. Summary of the Invention
[0005] In view of this, embodiments of this specification provide a memory resource allocation method. One or more embodiments of this specification also relate to a resource allocation platform, a memory resource allocation apparatus, a computing device, a computer-readable storage medium, and a computer program product to address technical deficiencies in the prior art.
[0006] According to a first aspect of an embodiment of this specification, a memory resource allocation method is provided, comprising:
[0007] Parsing the virtual machine memory resources to obtain virtual machine kernel information, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page;
[0008] Scanning the virtual machine memory resources based on the scanning range and the scanning parameters to determine a target physical page in an idle state among at least one physical page;
[0009] Based on the target physical page, memory resource reallocation is performed.
[0010] According to a second aspect of an embodiment of this specification, a resource allocation platform is provided, comprising a virtual machine memory resource and a resource scheduler; the virtual machine memory resource comprises at least one pre-allocated physical page;
[0011] A resource scheduler is used to parse virtual machine kernel information from virtual machine memory resources, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scanning range and scanning parameters of at least one physical page; based on the scanning range and scanning parameters, the virtual machine memory resources are scanned to determine a target physical page in an idle state; and based on the target physical page, memory resource reallocation is performed.
[0012] According to a third aspect of an embodiment of this specification, a memory resource allocation device is provided, comprising:
[0013] a parsing module configured to parse the virtual machine memory resources to obtain virtual machine kernel information, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page;
[0014] a scanning module configured to scan the virtual machine memory resources based on a scanning range and scanning parameters, and determine a target physical page in an idle state among at least one physical page;
[0015] The allocation module is configured to perform memory resource reallocation based on the target physical page.
[0016] According to a fourth aspect of the embodiments of this specification, there is provided a computing device, including:
[0017] memory and processor;
[0018] The memory is used to store computer executable instructions, and the processor is used to execute the computer program / instructions. When the computer program / instructions are executed by the processor, the steps of the above-mentioned memory resource allocation method are implemented.
[0019] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the program / instruction is executed by a processor, the steps of the above-mentioned memory resource allocation method are implemented.
[0020] According to a sixth aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above-mentioned memory resource allocation method when executed by a processor.
[0021] In one embodiment of the present specification, virtual machine kernel information is parsed from virtual machine memory resources, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page; based on the scan range and scan parameters, the virtual machine memory resources are scanned to determine a target physical page in an idle state in the at least one physical page; and memory resource reallocation is performed based on the target physical page. From the virtual machine memory resources, virtual machine kernel information including a scan range and scan parameters of at least one physical page is parsed, and on this basis, the virtual machine memory resources are scanned, the target physical page in an idle state is determined, and memory resource reallocation of the target physical page is completed, thereby avoiding intrusion into the user virtual machine, achieving memory resource reallocation without the user virtual machine being aware, ensuring the isolation and security of the user virtual machine, and avoiding performance impact on the user virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a process architecture diagram of a memory resource allocation method;
[0023] Figure 2 This is a flowchart of a memory resource allocation method provided by one embodiment of this specification;
[0024] Figure 3 This is a schematic diagram of the process architecture of a memory resource allocation method provided by an embodiment of this specification;
[0025] Figure 4 This is a flowchart of a processing process of a memory resource allocation method for public cloud memory over-allocation provided by an embodiment of this specification;
[0026] Figure 5 This is a schematic diagram of the structure of a resource allocation platform provided by an embodiment of this specification;
[0027] Figure 6 This is a structural diagram of a memory resource allocation device provided by an embodiment of this specification;
[0028] Figure 7 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION
[0029] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0030] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0031] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0032] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0033] First, the terms involved in one or more embodiments of this specification are explained.
[0034] Operating System (OS): It is the core software layer of a computer system, responsible for managing and controlling computer hardware and software resources, providing services to users and executing applications.
[0035] Virtual Machine (VM): A software-emulated computer system that can simulate one or more complete, independently running operating system environments on a physical computer system. In a VM, software-level hardware resources such as the central processing unit (CPU), memory, hard disk, and network interfaces are virtualized, allowing each VM to run an operating system and applications like a real physical computer, without interfering with each other. Through virtualization technology, a single physical host can simultaneously run multiple different VMs, each with its own independent operating system, applications, and configuration, greatly improving hardware resource utilization and system flexibility.
[0036] Host system (Host or Host OS): In a virtualized environment, the host system refers to the operating system running on the actual physical hardware. It is responsible for managing and controlling physical resources and providing services to user virtual machines through virtualization technology.
[0037] User system (Guest or Guest OS): In a virtualized environment, the user system refers to an operating system instance running in the host system through virtualization technology. For the user virtual machine, it is unaware that it is running in a virtualized environment and believes that it directly controls the underlying hardware.
[0038] Direct Memory Access (DMA): A technology that allows hardware devices (such as disk controllers, network cards, etc.) to bypass the CPU and directly read and write system memory to improve data transmission speed and CPU efficiency.
[0039] Resource scheduler, or virtual machine monitor (Hypervisor): It is a key component of virtualization technology. It runs under or above the host operating system, is responsible for creating and managing virtual machines, and provides virtual hardware resources to the user operating system.
[0040] Memory over-commitment: This refers to the situation where the total amount of memory allocated to each user virtual machine in a virtualized environment exceeds the total amount of actual virtual machine memory resources provided by the host system. Through reasonable scheduling and memory reuse technology, it is allowed to exceed the physical memory limit for a short period of time.
[0041] IO Page Fault (IO Page Fault, abbreviated as IOPF) occurs during input and output processing in a virtualized environment when an I / O device attempts to access memory that is not in physical memory or is incorrectly mapped through DMA. This may cause problems such as memory conflicts, high complexity, and unsafe access.
[0042] The user virtual address (GuestVirtualAddress, referred to as GVA) is the memory address used inside the user virtual machine, which actually needs to be mapped to the host virtual address through virtualization technology.
[0043] Guest Physical Address (GPA): It is the "physical" memory address seen from the perspective of the user virtual machine, and actually needs to be mapped to the host physical address through virtualization technology.
[0044] The host virtual address (HVA) refers to the memory address used within the host operating system, which needs to be converted into the actual physical address (HPA) by the memory management unit (MMU) to access the physical memory.
[0045] Host Physical Address (HPA): It is the address on the actual physical memory chip and is the only real memory location that can be directly accessed.
[0046] It's important to note that in a virtualized environment, the primary memory address translation path is GVA->GPA->HPA. This GVA->GPA translation occurs within the virtual machine, performed by the user VM's own memory management unit (MMU) in conjunction with the VM's memory page table. The VM's operating system converts GVA to GPA, a process that occurs within the VM.
[0047] Physical Page: A physical page is the fundamental unit of computer memory management, a fixed-size block used by the operating system to partition and manage physical memory. In most modern computer systems, a physical page is typically 4KB or larger (e.g., 2MB, 1GB, etc.), and all physical memory is divided into a series of such pages. The operating system uses a page frame number (PFN) to identify the exact location of each physical page in physical memory.
[0048] Memory Page Table: The memory page table is a key data structure used by the operating system to implement the virtual memory system. It records the mapping between virtual address space and physical address space. Each process has its own independent page table. Each entry in the page table (called a page table entry, PTE) corresponds to a page in the virtual address space and contains the physical page address corresponding to the virtual page, as well as related permission bits and other control information. When the CPU initiates an access to a virtual address, the MMU will query the memory page table to find the corresponding physical address. This process is called address translation.
[0049] Memory Management Unit (MMU): A hardware component integrated into the CPU of modern computer systems that is responsible for translating virtual memory addresses into physical memory addresses. It performs address translation by parsing and searching the memory page table, ensuring that processes can only access authorized memory areas and assisting the operating system in implementing memory protection and memory paging mechanisms.
[0050] Extended Page Table (EPT): A hardware-assisted, secondary page table mechanism, particularly suitable for virtualized environments. In virtualized scenarios, EPT allows the hypervisor to maintain an independent, hardware-backed page table structure for each guest operating system (Guest OS), enabling efficient translation of user-physical addresses to host-physical addresses.
[0051] VMCOREINFO: A kernel information file generated under specific conditions. It records relevant information about a virtual machine or operating system kernel crash dump, including the kernel symbol table, memory map, module list, and thread information. This file is an Executable and Linkable Format (ELF) comment segment that contains various kernel information. This file is crucial for analyzing kernel crashes, debugging system issues, and understanding the kernel's internal state. It is particularly important in virtualized environments, helping the hypervisor or analysis tools identify and locate problems.
[0052] Kernel Dump (or Core Dump): A mechanism provided by the operating system. When the kernel or user-mode process in the operating system encounters a serious error, crashes, or receives a specific signal to terminate, the system will save the working status and memory contents of the process at that time to a file on disk.
[0053] Executable and Linkable Format (ELF): A widely used file format, primarily used in Unix-like operating systems (including Linux, Solaris, FreeBSD, etc.), for representing executable files, object code, shared libraries, and core dumps. This file format is designed to be flexible and extensible to support a variety of processor architectures and operating system features.
[0054] At present, in order to resolve the contradiction between direct memory access and flexible memory allocation, a specific detection module is injected into the user virtual machine to directly detect the physical pages pre-allocated to the user virtual machine in an idle state and complete the reallocation of memory resources. Figure 1 As shown, Figure 1 A schematic diagram of the process architecture of a memory resource allocation method is shown below:
[0055] The detection module is injected into the user system in advance, and the detection module transmits the detected data to the data manager of the detection module in the host system through the application programming interface.
[0056] The detection module obtains the user system's physical page metadata (the user physical address range of the physical page structure information) and the parsing strategy. Based on the physical page metadata, the user virtual memory start address and user virtual memory end address are determined and passed to the detection module's data manager via the application programming interface. The parsing strategy source code is compiled to obtain the parsing strategy binary code, which is also passed to the detection module's data manager via the application programming interface.
[0057] In the host system's detection module's data manager, the parsing policy's binary code is verified using the parsing policy's verifier. Once verified, the binary code is stored. The physical page metadata range (the user physical address range of the physical page's structure information) is converted to user physical page metadata (the host virtual address range of the physical page's structure information), completing the memory reclamation setup.
[0058] In the host system's memory reclamation routine, the user's physical page metadata is scanned and, using the appropriate parsing strategy, it is determined whether the physical page is the target, idle physical page. For the target physical page, the memory management unit's memory page table and input / output memory page table are adjusted, and the extended memory page table of the physical page metadata is adjusted to protect the target physical page.
[0059] When a system event triggers the need to access the target physical page, the physical page metadata must be accessed first. This triggers a page fault in the extended memory page table to the resource scheduler. The resource scheduler simultaneously handles the page fault in the extended memory page table and swaps back the corresponding physical page, avoiding the contradiction between direct memory access and flexible memory allocation, and avoiding problems such as memory conflicts, high complexity, and non-secure access.
[0060] However, the above method injects a specific detection module into the user virtual machine and directly invades the user virtual machine, which will destroy the isolation and security of the user virtual machine in the network cloud platform. In addition, the injected detection module will affect the performance of the user virtual machine.
[0061] To address the above issues, this specification provides a memory resource allocation method. This specification also involves a resource allocation platform, a memory resource allocation device, a computing device, a computer-readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.
[0062] See also Figure 2 , Figure 2 A flowchart of a memory resource allocation method provided according to an embodiment of this specification is shown, including the following specific steps:
[0063] Step 202: parse and obtain virtual machine kernel information from the virtual machine memory resources, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page.
[0064] The embodiments of this specification apply to a component unit with memory resource allocation functionality. This component unit is software that can be embedded within a network cloud platform, such as a network cloud platform resource scheduler responsible for virtual machine resource scheduling, or externally located outside the network cloud platform, such as a third-party memory resource monitoring and optimization component unit that interacts with the cloud platform via an API. This component unit can directly detect virtual machine memory resources, obtain virtual machine kernel information, and based on this, parse the virtual machine kernel information and scan the virtual machine memory resources, identify target physical pages that are in an idle state, and then redistribute memory resources to the target physical pages.
[0065] Virtual machine memory resources are pre-allocated to user virtual machines. These resources are allocated from the host machine's (i.e., physical machine) memory resources and are used to create and run user virtual machines. Virtual machine memory resources consist of at least one physical page. For example, if 2GB of the host machine's 4GB of memory is pre-allocated to a user virtual machine, this 2GB of memory resources is considered virtual machine memory resources.
[0066] A physical page is the basic operating unit of virtual machine memory resources. It is the basic unit of independently allocated memory in memory allocation and a user physical page metadata. Physical page sizes include, but are not limited to, 4KB, 2MB, and 4MB. During the creation of a user virtual machine (i.e., during the allocation of virtual machine memory resources), each physical page is mapped to a different virtual memory address in the user virtual machine, enabling the conversion of virtual memory addresses to physical memory addresses. For example, if 2GB of virtual machine memory resources is divided into 4KB physical pages (number of physical pages = 2 * 1024 * 1024KB / 4KB), the resulting number is 524,288 physical pages.
[0067] Virtual machine kernel information is information about the kernel itself and the resources it manages during the operation of the user system, including the status and configuration parameters of the kernel itself and the resources it manages. These status and configuration parameters reflect the virtual machine kernel's operating status, memory management policy, system call interface, kernel structure layout, and specific parameters and variable values of other key kernel components. Virtual machine kernel information covers parameters such as the kernel version, kernel compilation options, the size of kernel data structure information, parameter settings of the memory management module (such as the page size of the physical page, the structure information of the physical page, the memory allocation policy, etc.), the kernel symbol table, function offsets, and the system call table. For example, in the Linux system, the virtual machine kernel information is VMCOREINFO, which is a special ELF comment segment. VMCOREINFO contains various information from the kernel, such as structure information size, page size, symbol value, offset, and other parameters. These parameters are packaged into an ELF comment segment to analyze the kernel's memory layout. The scanning range of at least one physical page is the parameter in the virtual machine kernel information used to characterize the memory address range of at least one physical page, which is the kernel information of the physical page, including but not limited to: starting address and / or ending address. For example, in Linux, the virtual memory address range used to represent physical page structures starts at VMEMMAP_START, and ends at VMEMMAP_END. Generally, the kernel reserves a specific virtual memory area for storing physical page structures. This area might start at VMEMMAP_START and end at VMEMMAP_END. By querying these two addresses, the resource scheduler or memory management component can determine the memory range to traverse and analyze.
[0068] The scanning parameters of at least one physical page are parsing parameters used to parse the state parameters of at least one physical page in the virtual machine kernel information, including but not limited to: target parsing strategy and memory management mechanism parameters. The target parsing strategy is used to parse and understand the data structure about the physical page status in the kernel information, for example, using page to determine the size of the structure information struct page, using (page, private) to determine the offset of the private member in the structure information struct page, to parse the page size represented by the structure information strcut page, using (page, mapcount) to determine the offset of the mapcount member in the structure information struct page, to parse whether the structure information strcut page represents a free page. The memory management mechanism parameters involve the access control bits of the page table entries, the swap space strategy, the memory fragmentation handling rules, etc., which are used to determine which physical pages meet the criteria for the free state.
[0069] For example, a network cloud platform includes a host machine (Host) and multiple created user virtual machines (Guests). 2GB of guest memory is allocated to the user virtual machines from the host machine's 4GB memory resources. A host OS (Host OS) runs on the host machine, and the host system manages and schedules the virtual machine memory resources through a resource scheduler (hypervisor). The resource scheduler parses the virtual machine memory resources to obtain virtual machine kernel information (VMCOREINFO). The 2GB of virtual machine memory resources are divided into 4KB physical pages (number of physical pages = 2*1024*1024KB / 4KB), comprising 524,288 physical pages. The virtual machine kernel information (VMCOREINFO) includes the structure information (struct page) for these 524,288 physical pages, including the scan range (VMEMMAP_START; VMEMMAP_END) and scan parameters (page; (page, private); (page, mapcount)).
[0070] The virtual machine kernel information is parsed from the virtual machine memory resources. The virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes the scanning range and scanning parameters of the at least one physical page. This avoids the need to inject a detection module into the user virtual machine and directly detects the virtual machine memory resources to obtain the virtual machine kernel information including the scanning range and scanning parameters of the at least one physical page. This provides kernel parameter support for subsequent scanning of the virtual machine memory resources and determining the target physical page that is idle within the at least one physical page.
[0071] Step 204: Scan the virtual machine memory resources based on the scan range and the scan parameters to determine a target physical page in an idle state in at least one physical page.
[0072] The target physical page is a physical page that is not allocated to any process for use and is in an idle state. In the idle state, the physical page does not carry any process's data or instructions, is not mapped to any virtual address space in the virtual machine system, and can be reallocated to other virtual machines and their processes in the host system for use. For example, of the 1,000 physical pages pre-allocated to multiple user virtual machines, 200 physical pages are not currently occupied by any process. These 200 physical pages are the target physical pages. When a process in a virtual machine requests additional memory resources, these 200 idle target physical pages can be reallocated to the process of the virtual machine requesting additional memory resources.
[0073] Based on the scanning range and scanning parameters, the virtual machine memory resources are scanned to determine the target physical page in the idle state in at least one physical page. The optional method is: based on the scanning range and scanning parameters, the virtual machine memory resources are scanned to determine the status parameters of at least one physical page, and based on the status parameters of at least one physical page, the target physical page in the idle state in at least one physical page is determined.
[0074] Exemplarily, based on the scanning range (VMEMMAP_START; VMEMMAP_END) and scanning parameters (page; (page, private); (page, mapcount)) of the structure information struct page of 524288 physical pages, the virtual machine memory resource GuestMemory is scanned to determine the status parameters of at least one physical page. Based on the status parameters of the 524288 physical pages, the target physical page free guestpage that is in an idle state among the 524288 physical pages is determined.
[0075] Based on the scan range and scan parameters, the virtual machine memory resources are scanned to determine a target physical page that is idle in at least one physical page. This provides support for subsequent memory resource reallocation by determining the target physical page that is idle.
[0076] Step 206: Execute memory resource reallocation based on the target physical page.
[0077] Memory resources are reallocated based on the target physical page. An optional method is to modify the memory page table of the target physical page based on the target physical page, wherein the memory page table includes but is not limited to: the memory page table of the memory management unit and the input / output memory page table.
[0078] Exemplarily, based on the target physical page free guestpage, a memory page table MMUPage Table and an input / output memory page table I / O Page Table of the memory management unit of the target physical page free guestpage are modified.
[0079] In an embodiment of the present specification, virtual machine kernel information is parsed from virtual machine memory resources, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of at least one physical page; based on the scan range and scan parameters, the virtual machine memory resources are scanned to determine a target physical page in an idle state in at least one physical page; and memory resource reallocation is performed based on the target physical page. From the virtual machine memory resources, virtual machine kernel information including a scan range and scan parameters of at least one physical page is parsed, and on this basis, the virtual machine memory resources are scanned, the target physical page in an idle state is determined, and memory resource reallocation of the target physical page is completed, thereby avoiding intrusion into the user virtual machine, achieving memory resource reallocation without the user virtual machine being aware, ensuring the isolation and security of the user virtual machine, and avoiding performance impact on the user virtual machine.
[0080] In an optional embodiment of this specification, correspondingly, step 202 includes the following specific steps:
[0081] Based on the virtual machine system information, the virtual machine kernel information is parsed from the virtual machine memory resources.
[0082] Generally, virtual memory resources store different information, and may store other information in addition to virtual machine kernel information. Therefore, when parsing to obtain the virtual machine kernel information, it is generally implemented based on the virtual machine system information.
[0083] Virtual machine system information describes the operating system running on the virtual machine, including an operating system identifier used to identify the virtual machine kernel information. This includes, but is not limited to, the system type, kernel version, revision, and patch level of the virtual machine's operating system. For example, if the virtual machine system information is "OSRELEASE=4.15.0-162-generic," "OSRELEASE" indicates an operating system kernel identifier, while the following "4.15.0-162-generic" is the specific Linux kernel version, indicating that the user virtual machine is running a generic kernel based on Linux kernel version 4.15.0 with patch 162.
[0084] Based on the virtual machine system information, the virtual machine kernel information is parsed from the virtual machine memory resources. The optional method is: based on the virtual machine system information, the virtual machine memory resources are detected to determine the scanning range of the virtual machine kernel information; based on the scanning range of the virtual machine kernel information, the virtual machine memory resources are scanned to obtain the virtual machine kernel information.
[0085] Exemplarily, based on the standard header string "OSRELEASE=", the virtual machine memory resource GuestMemory is detected, the starting address of the virtual machine kernel information VMCOREINFO is determined, and based on the starting address of the virtual machine kernel information VMCOREINFO, the virtual machine memory resource GuestMemory is scanned to obtain the virtual machine kernel information VMCOREINFO, wherein the virtual machine kernel information VMCOREINFO includes the scanning range (VMEMMAP_START; VMEMMAP_END) and scanning parameters (page; (page, private); (page, mapcount)) of the structure information struct page of 524288 physical pages.
[0086] In the embodiment of this specification, virtual machine kernel information parsing is completed based on virtual machine system information, thereby ensuring the validity of the parsing and further ensuring the accuracy of obtaining the scanning range and scanning parameters of at least one physical page.
[0087] In an optional embodiment of the present specification, based on the virtual machine system information, the virtual machine kernel information is parsed from the virtual machine memory resources, including the following specific steps:
[0088] Based on the virtual machine system information, detect the virtual machine memory resources and determine the starting address of the virtual machine kernel information in the virtual machine memory resources;
[0089] Based on the starting address, the virtual machine memory resources are scanned to obtain the virtual machine kernel information.
[0090] Generally, after parsing and obtaining the virtual machine kernel information, it is necessary to determine the starting address of the virtual machine kernel information in the virtual machine memory resources based on the virtual machine system information, so as to scan and obtain the scanning range and scanning parameters of at least one physical page.
[0091] The starting address of the virtual machine kernel information in the virtual machine memory resources is the memory starting address where the virtual machine kernel information is stored in the virtual machine memory resources. It is a memory address reference point used to locate the starting position of the virtual machine kernel information in the virtual machine memory resources. For example, the starting address of the virtual machine kernel information VMCOREINFO in the virtual machine memory resources is 0xFF000000, indicating that all virtual machine kernel information is stored continuously starting from this memory address. Based on this starting address, the virtual machine memory resources are scanned to obtain virtual machine kernel information including a scan range of at least one physical page and scan parameters.
[0092] Exemplarily, based on the standard header string "OSRELEASE=", the virtual machine memory resource GuestMemory is detected, and the starting address of the virtual machine kernel information VMCOREINFO in the virtual machine memory resource GuestMemory is obtained. Based on the starting address, the virtual machine memory resource GuestMemory is scanned from front to back to obtain the virtual machine kernel information VMCOREINFO, wherein the virtual machine kernel information VMCOREINFO includes the scanning range (VMEMMAP_START; VMEMMAP_END) and scanning parameters (page; (page, private); (page, mapcount)) of the structure information structpage of 524288 physical pages.
[0093] In an embodiment of the present specification, based on the virtual machine system information, the starting address of the virtual machine kernel information in the virtual machine memory resources is determined, and based on the starting address, the virtual machine memory resources are scanned to obtain the virtual machine kernel information, which further ensures the effectiveness of the analysis and further ensures the accuracy of the scanning range and scanning parameters of at least one physical page.
[0094] In an optional embodiment of this specification, step 204 includes the following specific steps:
[0095] Scanning the virtual machine memory resources based on the scan range to obtain structural information of at least one physical page;
[0096] Based on the scan parameters and the structural information of the at least one physical page, a target physical page in an idle state is determined among the at least one physical page.
[0097] The physical page structure information is structured information data used to manage physical pages. It is defined by the kernel of the virtual machine operating system and used in memory management. It is a type of physical page metadata. The physical page structure information records structure parameters that represent key attributes of the physical page, including but not limited to: page size parameter, idle state parameter, page index parameter, and reference count. For example, in Linux systems, the physical page structure information structpage includes structure parameters such as physical page flags (unsigned long flags), reference count (atomic_t_count), and index in the page frame array (pgoff_tindex).
[0098] Based on the scanning parameters and the structural information of at least one physical page, a target physical page in an idle state is determined in the at least one physical page. Specifically, based on the scanning parameters, the structural information of the at least one physical page is parsed to determine the target physical page in the idle state in the at least one physical page.
[0099] Exemplarily, based on the scanning range (VMEMMAP_START; VMEMMAP_END) of the structure information struct page of 524288 physical pages, the virtual machine memory resource Guest Memory is scanned to obtain the structure information struct page of 524288 physical pages. Based on the scanning parameters (page; (page, private); (page, mapcount)) of the structure information struct page of 524288 physical pages, the structure information structpage of 524288 physical pages is parsed to determine the target physical page free guestpage that is in an idle state among the 524288 physical pages.
[0100] In an embodiment of the present specification, based on a scanning range, the virtual machine memory resources are scanned to obtain structural information of at least one physical page, and based on scanning parameters and the structural information of at least one physical page, a target physical page in an idle state is determined in at least one physical page, and the target physical page in an idle state is accurately determined, providing accurate target physical page support for subsequent memory resource reallocation.
[0101] In an optional embodiment of this specification, the scanning parameters include a target resolution strategy;
[0102] Determining a target physical page in an idle state in the at least one physical page based on a scan parameter and structural information of the at least one physical page includes the following specific steps:
[0103] Use the target parsing strategy to parse the structure information of each physical page and obtain the structure parameters of each physical page;
[0104] Based on the structure parameters of each physical page, a target physical page in an idle state is identified in the at least one physical page.
[0105] Generally, when a virtual machine operating system generates the structure information of a physical page, it needs to compile the physical page metadata, which is the physical page metadata, and convert it into binary data and store it in the virtual machine memory resources. Therefore, it needs to be parsed to obtain the structure parameters of each physical page.
[0106] The physical page structure parameters represent key attributes of the physical page, including but not limited to: page size, free state, page index, and reference count. For example, in Linux, the physical page structure information struct page includes the following structure parameters: Physical page flags (flags): Definition: unsigned long flags; Description: Used to record various status information of the physical page, such as whether the physical page is free, allocated, involved in paging, and whether it contains cached data. Reference count (count): Definition: atomic_t_count; Description: Records the number of times the current physical page is referenced, used to determine whether the page is in use. When the reference count is 0, it generally means that the page can be safely reclaimed or reallocated. Page index (index): Definition: pgoff_tindex; Description: Indicates the position of the physical page in the page frame array, allowing the kernel to quickly locate and search for a specific physical page. Union (mapping) for mapping information or other purposes: Definition: union{...}mapping Description: Depending on the usage of the physical page, the union can store different information, such as a structure pointer associated with the file system address space, or other data related to physical page mapping. In addition, in order to determine whether the physical page is in an idle state, you also need to pay attention to the following structure parameters: Status parameters: For example, you can determine whether the page is available or idle by checking specific flag bits in struct page, such as page pointer parameters. Page mapping information (mapcount): Determine whether the page is mapped to any virtual address space. If mapcount is 0, it means that the physical page is not occupied by any process and is in an idle state. Private member (private): Determine the page size of the physical page through the member variable private.
[0107] The target parsing strategy is the parsing method used to parse the physical page status in the structure information. The target parsing strategy is used to parse the structure parameters representing the physical page status. The target parsing strategy is determined based on the predefined strategy for the structure information and includes, but is not limited to, helper functions. Generally, different virtual machine operating systems have different parsing strategies, which are recorded in the virtual machine kernel information.
[0108] Exemplarily, target parsing strategy helper functions are used to parse the structure information struct page of 524288 physical pages, obtain the structure parameters of each physical page, and identify the target physical page free guest page in the 524288 physical pages that is in an idle state based on the structure parameters of each physical page.
[0109] In the embodiments of this specification, a target parsing strategy is utilized to parse the structural information of each physical page, obtain the structural parameters of each physical page, and identify the target physical page in an idle state in at least one physical page based on the structural parameters of each physical page. This more accurately determines the target physical page in an idle state, and provides more accurate target physical page support for subsequent memory resource reallocation.
[0110] In an optional embodiment of the present specification, the target resolution strategy includes an offset of the structure parameter relative to the starting address in the scan range;
[0111] Using the target parsing strategy, parse the structure information of each physical page and obtain the structure parameters of each physical page, including the following specific steps:
[0112] The offset is used to parse the structure information of each physical page and obtain the structure parameters of each physical page.
[0113] Different virtual machine operating systems have different parsing strategies, which are recorded in the virtual machine kernel information. These parsing strategies are often distinguished by setting different offsets for structure parameters relative to the starting address in the scan range. For example, in Linux systems, structure information is typically 64 bytes of binary data stored in the virtual machine's memory resources. After scanning the structure information, it is unclear which bytes represent the structure parameters representing the physical page status. Therefore, a targeted parsing strategy is required to determine whether the Mth or Nth byte is the status parameter.
[0114] The offset of a structure parameter relative to the start address of the scan range refers to the relative position of the structure parameter within each physical page's structure information within the virtual machine's memory resources when scanning virtual machine memory resources. This offset is also the byte offset relative to the start address of the scan range. In various operating system environments, especially complex systems like Linux, the structure information for physical pages is compiled into binary format and stored in the virtual machine's memory. To correctly parse this structure information, it is necessary to determine the exact location of each structure parameter within the virtual machine's memory resources. This location is precisely located relative to the start address of the scan range. For example, in Linux, the start address of the physical page structure information struct page is VMEMMAP_START. To access a private member within structpage, the offset of the private member within the structure must first be determined (page, private). The memory address of the private member is then VMEMMAP_START + (page, private). This allows accurate reading of the private member's value through offset addressing, thereby determining whether the physical page is in an idle state or another state.
[0115] Exemplarily, the structure information struct page of 524288 physical pages is parsed using the offset (page, private) and (page, mapcount) of the structure parameters relative to the starting address VMEMMAP_START in the scan range to obtain the structure parameter private member and mapcount member of each physical page.
[0116] In the embodiment of this specification, the offset is used to parse the structure information of each physical page to obtain the structure parameters of each physical page, and the structure parameters are parsed more accurately, providing more accurate structure parameter support for the subsequent determination of the target physical page in the idle state.
[0117] In an optional embodiment of the present specification, the structure parameters include a state parameter and a page size parameter;
[0118] Identifying a target physical page in an idle state in at least one physical page based on the structure parameters of each physical page includes the following specific steps:
[0119] Based on the state parameter and the page size parameter, a physical page in the at least one physical page that is in an idle state and has a target page size is identified as a target physical page.
[0120] The status parameter is a structure parameter that represents the page status of a physical page. It reflects whether the physical page has been allocated, is idle, participates in page replacement, contains cached data, and other states. For example, in Linux systems, the status parameter of a physical page is the flags member, which can identify various states of the physical page. For another example, by checking flags such as PageLRU, PageSlab, and PageFree, it can be determined whether the physical page is idle or available for allocation to new memory requests. For another example, the status parameter of a physical page is the mapcount member.
[0121] The page size parameter is a structure parameter that represents the size of the physical page, reflecting whether the page size is 4KB, 4KB, 2MB, or 4MB. For example, the private member is used to represent the page size: size_tpageSize = page->private; if (pageSize > = TARGET_PAGE_SIZE) { / / The page size meets the requirements, further check the status parameters to determine whether it is a free page}. The target page size is the page size of the physical page that meets the page size parameter.
[0122] Exemplarily, based on the state parameter (mapcount member) and the page size parameter (private member), a target physical page free guestpage in the free state among the 524288 physical pages is identified.
[0123] In the embodiment of the present specification, identifying at least one physical page that is in an idle state and has a target physical page size provides more accurate support for subsequent memory resource reallocation and more accurate target physical page support.
[0124] In an optional embodiment of this specification, step 206 includes the following specific steps:
[0125] Reclaim the page table of the target physical page;
[0126] In response to the memory allocation request sent by the target virtual machine, a page table is reallocated for the target physical page.
[0127] Page table recycling is a memory management operation that completes physical page recycling through the memory page table. The specific operation is to delete the page table entry of the target physical page in the memory page table, so that the target physical page changes to an idle state and can be reallocated to other processes or virtual machines for use. Deleting the page table entry clears the mapping relationship of the target physical page in the virtual address space.
[0128] Page table reallocation is a memory management operation that completes physical page reallocation through the memory page table. The specific operation is to rebuild the page table entry of the target physical page in the memory page table, so that the target physical page is changed to an occupied state and can be used by other processes or virtual machines. Rebuilding the page table entry newly creates a mapping relationship between the target physical page in the virtual address space.
[0129] The target virtual machine may be a virtual machine to which virtual machine memory resources are pre-allocated, which is a case of memory over-allocation, or a new virtual machine that needs to be built, which is not limited here.
[0130] In response to the memory allocation request sent by the target virtual machine, a page table is reallocated for the target physical page, specifically by generating a page table entry of the target physical page in the memory page table in response to the memory allocation request sent by the target virtual machine.
[0131] Exemplarily, the page table entry of the target physical page free guestpage in the memory page table MMU Page Table of the memory management unit and the input / output memory page table I / OPage Table is deleted, and in response to the memory allocation request sent by the target virtual machine, the page table entry of the target physical page free guestpage is generated in the memory page table MMUPage Table of the memory management unit and the input / output memory page table I / O PageTable.
[0132] In the embodiments of this specification, memory resource redistribution is achieved through page table management, ensuring the consistency and security of user virtual machines.
[0133] In an optional embodiment of the present specification, before reclaiming the page table of the target physical page, the following specific steps are further included:
[0134] In the virtual machine memory access table, the access permission of the target physical page is set to a prohibited access state, wherein the virtual machine memory access table is a physical page table used by the virtual machine to perform memory address translation when accessing memory resources.
[0135] Generally, when the I / O device of a user virtual machine uses direct memory access (DMA) to access the virtual machine's memory resources, the target physical page needs to be reallocated. If it can still be accessed by the user virtual machine, a memory conflict may occur, causing a direct memory access exception. When the user virtual machine needs to access the target physical page, it must first access its structure information. If the access permission of the target physical page is set to prohibited in the virtual machine's memory access table, a page fault in the virtual machine's memory access table will be triggered, preventing the target physical page from being accessed.
[0136] The virtual machine memory access table is a physical page table used by the virtual machine to convert memory addresses when accessing memory resources. For example, in a Linux system, the virtual machine memory access table is an extended memory page table (EPT).
[0137] Exemplarily, in the virtual machine memory access table EPT, the access permission of the target physical page free guest page is set to a prohibited access state.
[0138] In the embodiments of the present specification, by setting the access rights of the target physical page in the virtual machine memory access table to a prohibited access state before the page table of the target physical page is recycled, potential memory conflict problems are effectively prevented, the safe recycling and reallocation of the target physical page is ensured, and the stability and reliability of the virtualization environment are enhanced.
[0139] Figure 3 FIG. 1 shows a flow diagram of a memory resource allocation method provided by an embodiment of the present specification. Figure 3 As shown:
[0140] The network cloud platform includes virtual machine memory resources, resource scheduler and host system. The resource scheduler includes parsing module, scanning module and recycling module.
[0141] In the resource scheduler, virtual memory resources are detected to obtain virtual machine kernel information; a parsing module is used to parse the virtual machine kernel information and determine the scanning range and scanning parameters of at least one physical page; a scanning module is used to scan the virtual machine memory resources based on the scanning range to obtain the structural information of at least one physical page, and based on the scanning parameters and the structural information of at least one physical page, determine the target physical page that is in an idle state in the at least one physical page; the target physical page information is passed to a recycling module; the recycling module is used to perform page table recycling on the target physical page on the memory page table of the host system's memory management unit and the input / output memory page table.
[0142] The following combined Figure 4 , taking the application of the memory resource allocation method provided in this specification in the public cloud memory over-scaling scenario as an example, the memory resource allocation method is further explained. Figure 4 A flowchart of a method for allocating memory resources for public cloud memory over-allocation, provided in one embodiment of this specification, is shown. The method is applied to a resource scheduler of a public cloud platform and includes the following specific steps:
[0143] Step 402: Based on the virtual machine system information "OSRELEASE=", the virtual machine memory resource GuestMemory is detected, and the starting address of the virtual machine kernel information VMCOREINFO in the virtual machine memory resource GuestMemory is determined.
[0144] Step 404: Based on the starting address, the virtual machine memory resource Guest Memory is scanned to obtain virtual machine kernel information VMCOREINFO, wherein the virtual machine kernel information VMCOREINFO includes a scanning range VMEMMAP_START and VMEMMAP_END of at least one physical page, and a target parsing strategy, the target parsing strategy includes the offsets (page, mapcount) and (page, private) of the state parameter "mapcount" and the page size parameter "private" relative to the starting address in the scanning range.
[0145] Step 406: Scan the virtual machine memory resource GuestMemory based on the scanning ranges VMEMMAP_START and VMEMMAP_END to obtain structure information struct page of at least one physical page.
[0146] Step 408: Using the offsets (page, mapcount) and (page, private), parse the structure information structpage of each physical page to obtain the status parameter "mapcount" and the page size parameter "private" of each physical page.
[0147] Step 410: Based on the state parameter “mapcount” and the page size parameter “private” of each physical page, identify a physical page in the at least one physical page that is in an idle state and has a target page size as a target physical page free guestpage.
[0148] Step 412: In the virtual machine memory access table (EPT), the access permission of the target physical page (free guest page) is set to a prohibited access state.
[0149] Step 414: reclaim the page table of the target physical page free guestpage.
[0150] Step 416: In response to the memory over-allocation request sent by the target virtual machine, reallocate a page table for the target physical page free guestpage.
[0151] In the embodiments of this specification, the virtual machine memory resources are detected by the resource scheduler and the virtual machine kernel information is parsed to avoid intrusion into the user virtual machine. Memory over-allocation is achieved without the user virtual machine being aware of it, ensuring the isolation and security of the user virtual machine in the public cloud environment. In addition, the performance impact on the user virtual machine is avoided, and the efficiency of memory over-allocation is improved.
[0152] Corresponding to the above method embodiment, this specification also provides a resource allocation platform embodiment, Figure 5 FIG1 shows a schematic diagram of the structure of a resource allocation platform provided by an embodiment of this specification. Figure 5 As shown, the resource allocation platform includes a virtual machine memory resource 502 and a resource scheduler 504; the virtual machine memory resource 502 includes at least one pre-allocated physical page;
[0153] The resource scheduler 504 is used to parse the virtual machine memory resources 502 to obtain virtual machine kernel information, wherein the virtual machine memory resources 502 include at least one pre-allocated physical page, and the virtual machine kernel information includes a scanning range and scanning parameters of at least one physical page; based on the scanning range and scanning parameters, the virtual machine memory resources 502 are scanned to determine the target physical page in the idle state; and based on the target physical page, memory resource reallocation is performed.
[0154] In an optional embodiment of the present specification, the resource scheduler 504 is further used to scan the virtual machine memory resources 502 based on the scanning range to obtain structural information of at least one physical page; and determine a target physical page that is in an idle state in at least one physical page based on the scanning parameters and the structural information of at least one physical page.
[0155] In an optional embodiment of this specification, the resource allocation platform further includes a host system 506;
[0156] The resource scheduler 504 is further used to set the access permission of the target physical page to a prohibited access state in the virtual machine memory access table recorded by the host system 506, wherein the virtual machine memory access table is a physical page table used by the virtual machine to convert memory addresses when accessing memory resources; and delete the page table entry of the target physical page in the memory page table recorded by the host system 506, wherein the memory page table includes a mapping relationship between the virtual memory address of the virtual machine and at least one physical page.
[0157] In the embodiments of the present specification, a resource scheduler is used to parse virtual machine kernel information including a scanning range and scanning parameters of at least one physical page from virtual machine memory resources. On this basis, a scan of virtual machine memory resources is completed, target physical pages in an idle state are determined, and memory resource reallocation of the target physical pages is completed, thereby avoiding intrusion into the user virtual machine and achieving memory resource reallocation without the user virtual machine being aware of it, thereby ensuring the isolation and security of the user virtual machine and avoiding performance impact on the user virtual machine.
[0158] The above is a schematic diagram of a resource allocation platform according to this embodiment. It should be noted that the technical solution of this resource allocation platform and the technical solution of the aforementioned memory resource allocation method are based on the same concept. For details not described in detail in the technical solution of the resource allocation platform, please refer to the description of the technical solution of the aforementioned memory resource allocation method.
[0159] Corresponding to the above method embodiment, this specification also provides a memory resource allocation device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of a memory resource allocation device provided by an embodiment of this specification. Figure 6 As shown, the device includes:
[0160] The parsing module 602 is configured to parse the virtual machine memory resources to obtain virtual machine kernel information, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page;
[0161] The scanning module 604 is configured to scan the virtual machine memory resources based on the scanning range and the scanning parameters, and determine a target physical page in an idle state among the at least one physical page;
[0162] The allocation module 606 is configured to perform memory resource reallocation based on the target physical page.
[0163] Optionally, correspondingly, the parsing module 602 is further configured to:
[0164] Based on the virtual machine system information, the virtual machine kernel information is parsed from the virtual machine memory resources.
[0165] Optionally, the parsing module 602 is further configured to:
[0166] Based on the virtual machine system information, the virtual machine memory resources are detected to determine the starting address of the virtual machine kernel information in the virtual machine memory resources; based on the starting address, the virtual machine memory resources are scanned to obtain the virtual machine kernel information.
[0167] Optionally, the scanning module 604 is further configured to:
[0168] Based on the scanning range, the virtual machine memory resources are scanned to obtain structural information of at least one physical page; based on the scanning parameters and the structural information of the at least one physical page, a target physical page in an idle state is determined in the at least one physical page.
[0169] Optionally, the scan parameters include a target resolution strategy;
[0170] Correspondingly, the scanning module 604 is further configured to:
[0171] The target parsing strategy is used to parse the structure information of each physical page to obtain the structure parameters of each physical page; based on the structure parameters of each physical page, a target physical page in an idle state in at least one physical page is identified.
[0172] Optionally, the target resolution strategy includes an offset of the structure parameter relative to the starting address in the scan range;
[0173] Correspondingly, the scanning module 604 is further configured to:
[0174] The offset is used to parse the structure information of each physical page and obtain the structure parameters of each physical page.
[0175] Optionally, the structure parameters include a state parameter and a page size parameter;
[0176] Correspondingly, the scanning module 604 is further configured to:
[0177] Based on the state parameter and the page size parameter, a physical page in the at least one physical page that is in an idle state and has a target page size is identified as a target physical page.
[0178] Optionally, the allocation module 606 is further configured to:
[0179] Reclaiming the page table of the target physical page; and reallocating the page table for the target physical page in response to the memory allocation request sent by the target virtual machine.
[0180] Optionally, the device further comprises:
[0181] The protection module is configured to set the access permission of the target physical page to a prohibited access state in the virtual machine memory access table, wherein the virtual machine memory access table is a physical page table for performing memory address conversion when the virtual machine accesses memory resources.
[0182] In the embodiment of the present specification, the parsing module parses the virtual machine memory resources to obtain the virtual machine kernel information including the scanning range and scanning parameters of at least one physical page. On this basis, the scanning module completes the scanning of the virtual machine memory resources, determines the target physical page in the idle state, and the allocation module completes the memory resource reallocation of the target physical page, avoiding intrusion into the user virtual machine, and realizing the completion of memory resource reallocation without the user virtual machine being aware of it, thereby ensuring the isolation and security of the user virtual machine and avoiding the performance impact on the user virtual machine.
[0183] The above is a schematic diagram of a memory resource allocation device according to this embodiment. It should be noted that the technical solution of the memory resource allocation device and the technical solution of the aforementioned memory resource allocation method are based on the same concept. For details not described in detail in the technical solution of the memory resource allocation device, please refer to the description of the technical solution of the aforementioned memory resource allocation method.
[0184] Figure 7 7. The block diagram of a computing device according to one embodiment of the present disclosure is shown. Components of the computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and a database 750 is used to store data.
[0185] The computing device 700 also includes an access device 740 that enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 740 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless type, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC). In one embodiment of the present specification, the above components of the computing device 700 and Figure 7 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 7 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.
[0186] In one embodiment of the present specification, the above components of the computing device 700 and Figure 7Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 7 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.
[0187] Computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 700 may also be a mobile or stationary server.
[0188] The processor 720 is configured to execute the following computer program / instruction, which implements the steps of the above-mentioned memory resource allocation method when executed by the processor.
[0189] The above is a schematic diagram of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned memory resource allocation method are based on the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned memory resource allocation method.
[0190] An embodiment of the present specification further provides a computer-readable storage medium storing a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the above-mentioned memory resource allocation method are implemented.
[0191] The above is a schematic diagram of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the aforementioned memory resource allocation method are based on the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the aforementioned memory resource allocation method.
[0192] An embodiment of the present specification further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned memory resource allocation method when executed by a processor.
[0193] The above is an illustrative embodiment of a computer program product. It should be noted that the technical solution of this computer program product and the technical solution of the aforementioned memory resource allocation method share the same concept. For details not described in detail in the technical solution of the computer program product, please refer to the description of the technical solution of the aforementioned memory resource allocation method.
[0194] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0195] The computer program includes computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0196] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0197] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0198] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A memory resource allocation method, comprising: Parsing the virtual machine memory resources to obtain virtual machine kernel information, wherein the virtual machine memory resources include at least one pre-allocated physical page, and the virtual machine kernel information includes a scan range and scan parameters of the at least one physical page; Scanning the virtual machine memory resources based on the scanning range and the scanning parameters to determine a target physical page in an idle state among the at least one physical page; Memory resource reallocation is performed based on the target physical page.
2. The method according to claim 1, wherein parsing the virtual machine kernel information from the virtual machine memory resources comprises: The virtual machine kernel information is obtained by parsing the virtual machine memory resources based on the virtual machine system information.
3. The method according to claim 2, wherein the step of parsing the virtual machine kernel information from the virtual machine memory resources based on the virtual machine system information comprises: Based on the virtual machine system information, detect the virtual machine memory resources and determine the starting address of the virtual machine kernel information in the virtual machine memory resources; Based on the starting address, the virtual machine memory resources are scanned to obtain the virtual machine kernel information.
4. The method according to any one of claims 1 to 3, wherein the scanning of the virtual machine memory resources based on the scanning range and the scanning parameters to determine the target physical page in the at least one physical page that is in an idle state comprises: Scanning the virtual machine memory resources based on the scanning range to obtain structure information of the at least one physical page; Based on the scan parameter and the structure information of the at least one physical page, a target physical page in an idle state is determined among the at least one physical page.
5. The method according to claim 4, wherein the scanning parameters include a target resolution strategy; The determining, based on the scanning parameter and the structural information of the at least one physical page, a target physical page in an idle state in the at least one physical page includes: Utilizing the target parsing strategy, parsing the structure information of each physical page to obtain the structure parameters of each physical page; Based on the structural parameters of each physical page, a target physical page in an idle state is identified among the at least one physical page.
6. The method according to claim 5, wherein the target resolution strategy comprises an offset of the structure parameter relative to a starting address in the scan range; The method of parsing the structure information of each physical page by using the target parsing strategy to obtain the structure parameters of each physical page includes: The structure information of each physical page is parsed using the offset to obtain the structure parameters of each physical page.
7. The method according to claim 5, wherein the structure parameters include a state parameter and a page size parameter; The identifying, based on the structural parameters of each physical page, a target physical page in an idle state in the at least one physical page includes: Based on the state parameter and the page size parameter, a physical page in the at least one physical page that is in the idle state and has a target page size is identified as the target physical page.
8. The method according to claim 1, wherein performing memory resource reallocation based on the target physical page comprises: Reclaiming the page table of the target physical page; In response to the memory allocation request sent by the target virtual machine, a page table is reallocated for the target physical page.
9. The method according to claim 8, before reclaiming the target physical page, further comprising: In a virtual machine memory access table, the access permission of the target physical page is set to a prohibited access state, wherein the virtual machine memory access table is a physical page table used by the target virtual machine to perform memory address conversion when accessing memory resources.
10. A resource allocation platform comprising a virtual machine memory resource and a resource scheduler; the virtual machine memory resource comprises at least one pre-allocated physical page; The resource scheduler is used to parse the virtual machine memory resources to obtain the virtual machine kernel information, wherein: The virtual machine kernel information includes a scanning range and scanning parameters of the at least one physical page; based on the scanning range and the scanning parameters, the virtual machine memory resources are scanned to determine a target physical page in an idle state; Memory resource reallocation is performed based on the target physical page.
11. According to the resource allocation platform of claim 10, the resource scheduler is further used to scan the virtual machine memory resources based on the scanning range to obtain the structural information of the at least one physical page; based on the scanning parameters and the structural information of the at least one physical page, determine the target physical page in the at least one physical page that is in the idle state.
12. The resource allocation platform according to claim 10 or 11, further comprising a host system; The resource scheduler is further configured to set the access permission of the target physical page to a prohibited access state in the virtual machine memory access table recorded by the host system, wherein: The virtual machine memory access table is a physical page table used by the virtual machine to convert memory addresses when accessing memory resources; the page table entry of the target physical page in the memory page table recorded by the host system is deleted, wherein the memory page table includes a mapping relationship between the virtual memory address of the virtual machine and the at least one physical page.
13. A computing device comprising: memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method according to any one of claims 1 to 9 are implemented.
14. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.
15. A computer program product comprising a computer program / instruction, which implements the steps of the method according to any one of claims 1 to 9 when executed by a processor.