Memory expansion
By converting the host operating system into virtual mode and receiving memory expansion instructions, dynamically adding extended memory to the target operating system, the problem of limited host memory expansion in virtualized scenarios is solved, smooth and flexible memory expansion is achieved, and the stability and process performance of the operating system are improved.
Patent Information
- Application Number
- PCT/IB2025/051388
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-28
- Filing Date
- 2025-02-11
- Publication Date
- 2025-09-04
AI Technical Summary
In the prior art, the host operating system memory cannot be dynamically expanded in a virtualized scenario, and the virtual machine memory expansion is limited by the virtualization platform and cannot meet the memory needs of the host operating system.
By receiving memory expansion instructions, the operating system running in physical mode is converted into virtual mode, the memory management function is used to add extended memory to the target operating system, and allocate it to the target memory pool based on the memory management function to achieve smooth memory expansion.
Without stopping the operating system, flexible memory expansion is achieved, the stability and reliability of the operating system is enhanced, the operation performance of the process is improved, and the unstable factors caused by system restart are avoided.
Smart Images

Figure IB2025051388_04092025_PF_FP_ABST
Abstract
Description
[0001] Cross-references to Memory Extension-Related Applications
[0002]
[0001] This application claims priority to Chinese patent application No. 202410225776.7 filed on February 28, 2024, the entire text of which is incorporated herein by reference.
[0003]
[0002] The present disclosure relates to the field of computer technology, and more particularly to a memory expansion method, a memory expansion device, a computing device, a computer-readable storage medium, and a computer program product.
[0004]
[0003] In traditional operating systems, memory expansion can only be performed online when physical memory is confirmed to exist. In virtualized scenarios, the memory hot-swap function can be used to conveniently and dynamically add virtual machine memory to a virtual machine. However, the virtual memory expanded by the memory hot-swap function is virtual memory, which is subject to the limitations and support level of the virtualization platform and cannot be used in the host operating system.
[0005]
[0004] For a host operating system that is already running, it is impossible to dynamically add memory to it unless the hardware has spare redundant memory.
[0006] In view of this, embodiments of the present disclosure provide a memory expansion method. One or more embodiments of the present disclosure also relate to a memory expansion device, a computing device, a computer-readable storage medium, and a computer program product to address technical deficiencies in the prior art.
[0007]
[0006] According to a first aspect of an embodiment of the present disclosure, a memory expansion method is provided, comprising: receiving a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system, and the target operating system is obtained by converting an operating system running in a physical mode to running in a virtual mode; determining a memory expansion parameter according to the memory expansion instruction, and calling a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameter to the target operating system; and allocating the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by a memory management function, wherein the memory contained in the target memory pool is used by the target operating system.
[0008]
[0007] According to a second aspect of an embodiment of the present disclosure, a memory expansion device is provided, comprising: a receiving module configured to receive a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system, and the target operating system is obtained by converting an operating system running in a physical mode to running in a virtual mode; a determining module configured to determine a memory expansion parameter according to the memory expansion instruction, and call a memory management interface of the target operating system to add an extended memory corresponding to the memory expansion parameter to the target operating system; an allocating module configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by a memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.
[0009]
[0008] According to a third aspect of an embodiment of the present disclosure, another memory expansion method is provided, comprising: receiving a configuration change instruction submitted for an operating system running in a physical mode; converting the operating system into a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function; upon receiving a memory expansion instruction submitted through the memory management function, determining a memory expansion parameter according to the memory expansion instruction, and calling a memory management interface of the target operating system to add an extended memory corresponding to the memory expansion parameter to the target operating system; and allocating the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by the memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.
[0010]
[0009] According to a fourth aspect of an embodiment of the present disclosure, another memory expansion device is provided, comprising: a receiving module configured to receive a configuration change instruction submitted for an operating system running in a physical mode; a conversion module configured to convert the operating system into a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function; a determining module configured to, upon receiving a memory expansion instruction submitted through the memory management function, determine memory expansion parameters according to the memory expansion instruction, and call a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters for the target operating system; an allocating module configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by the memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.
[0011]
[0010] According to a fifth aspect of an embodiment of the present disclosure, a computing device is provided, comprising a memory and a processor; the memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, and when the computer programs / instructions are executed by the processor, the steps of the above-mentioned memory expansion method are implemented.
[0012]
[0011] According to a sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned memory expansion method are implemented.
[0013]
[0012] According to the seventh aspect of the embodiment of the present disclosure, a computer program product is provided, including a computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by a processor.
[0014]
[0013] An embodiment of the present disclosure provides a memory expansion method, comprising: receiving a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system, and the target operating system is obtained by converting an operating system running in a physical mode to running in a virtual mode; determining a memory expansion parameter according to the memory expansion instruction, and calling a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameter to the target operating system; and allocating the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset in a memory management function, wherein the memory contained in the target memory pool is used by the target operating system.
[0015]
[0014] An embodiment of the present disclosure provides a memory expansion method that switches an operating system running in physical mode to a target operating system running in virtual mode, receives memory expansion instructions for the target operating system, adds corresponding extended memory to the target operating system, and performs smooth and flexible memory expansion without stopping the target operating system. This ensures that services in the operating system are not interrupted, achieves user-friendly operation, reduces various unstable factors caused by restarting the operating system, enhances the stability and reliability of the operating system, and can allocate extended memory to the target memory pool on demand, so that the extended memory in the target memory pool can be used by the target process corresponding to the target memory pool, significantly improving the operating performance of the target process.
[0016]
[0015] FIG1 is a schematic diagram of a memory expansion method according to an embodiment of the present disclosure.
[0016] FIG2 is a flow chart of a memory expansion method according to an embodiment of the present disclosure.
[0017]
[0017] FIG3 is a flowchart of a processing process of a memory expansion method provided by an embodiment of the present disclosure.
[0018]
[0018] FIG4 is a flowchart of another memory expansion method provided by an embodiment of the present disclosure.
[0019]
[0019] Figure 5 is a structural schematic diagram of a memory expansion device provided by an embodiment of the present disclosure.
[0020]
[0020] FIG6 is a schematic structural diagram of another memory expansion device provided in one embodiment of the present disclosure.
[0021]
[0021] FIG7 is a block diagram of a computing device provided by an embodiment of the present disclosure.
[0022] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure. However, the present disclosure can be implemented in many other ways different from those described herein, and those skilled in the art can make similar promotions without violating the connotation of the present disclosure. Therefore, the present disclosure is not limited by the specific implementation disclosed below.
[0023]
[0023] The terms used in one or more embodiments of the present disclosure are intended only to describe specific embodiments and are not intended to limit one or more embodiments of the present disclosure. The singular forms "a," "an," "the," and "the" used in one or more embodiments of the present disclosure and the appended claims are also intended to include the 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 the present disclosure refers to and includes any or all possible combinations of one or more associated listed items.
[0024] It should be understood that although the terms "first," "second," and so on may be used to describe various information in one or more embodiments of the present disclosure, such information should not be limited to these terms. These terms are merely used to distinguish information of the same type from one another. For example, "first" may also be referred to as "second," and similarly, "second" may also be referred to as "first," without departing from the scope of one or more embodiments of the present disclosure. Depending on the context, the term "if" as used herein may be interpreted as "at the time," "when," or "in response to determining."
[0025]
[0025] 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 the present disclosure 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 the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0026]
[0026] First, the terms involved in one or more embodiments of the present disclosure are explained.
[0027] GPA: Guest Physical Address, client physical address.
[0028] HPA: Host Physical Address, host physical address.
[0029]
[0029] EPT page table: Extended Page Table, a hardware-assisted virtual memory management technology. In a virtualized environment, EPT is used to solve the memory address translation problem between the guest operating system (Guest OS) and the host operating system (Host OS).
[0030]
[0030] A page table is a concept in virtual memory technology. To allow programs to access more available memory and expand physical memory into a larger logical memory, operating systems also use virtual memory technology. This abstracts physical memory into an address space. The operating system allocates a separate set of virtual addresses to each process, mapping the virtual addresses of different processes to the physical addresses of different memory locations. When a program accesses a virtual address, the operating system converts it into a different physical address. This involves two address concepts: the memory address used by the program is called a virtual address; the space address actually stored in the hardware is called a physical address.
[0031]
[0031] Virtual addresses and physical addresses are mapped through a page table, which is stored in memory. When a process wants to access a virtual address but cannot find the corresponding physical address in the page table, the system will generate a page fault exception, enter the system kernel space to allocate physical memory, update the process page table, and finally return to the user space to resume the process.
[0032]
[0032] VMCS (Virtual Machine Control Structure): A virtual machine control structure, a data structure used to manage the state of a virtual machine. In a hardware virtualization environment, each virtual machine instance has an associated VMCS.
[0033]
[0033] The VMCS contains a large number of fields and information related to the virtual machine execution environment, such as: virtual machine processor status, including CPU (central processing unit) internal status such as general registers, instruction pointer, and flag register; memory management information, such as the EPT page table base address and address translation control field, used to support memory virtualization and address translation; execution control information, such as entry points for entering and exiting the virtual machine, event injection, exception and interrupt handling mechanisms, etc.; virtual machine operation mode settings, such as operating permissions and behavior rules in non-root (virtual) mode and root (physical) mode; and virtual machine execution control fields, such as whether to enable specific functions and virtualization extensions.
[0034]
[0034] In the embodiment of the present disclosure, when an operating system running in a physical mode is converted to a target operating system running in a virtual mode, the VMCS is a data structure for managing the state of the target operating system running in the virtual mode.
[0035] Memory hot-swap technology allows memory modules to be added or removed while the computer is running without shutting down. It is commonly used in servers and high-end computer systems to improve system availability and resource flexibility. The key to achieving this functionality lies in the inclusion of pluggable memory slots in the motherboard design and the configuration of a dedicated hot-swap controller to monitor memory insertion and removal and communicate with the motherboard firmware.
[0036] In actual operation, a new memory module is simply inserted into an empty memory slot. The hot-swap controller detects the insertion event and notifies the motherboard firmware. The firmware then automatically identifies the newly inserted memory module and completes necessary settings such as initialization and physical address space allocation.
[0037] In a virtualized environment, the virtualization platform typically allows virtual machines to perform hot-swap memory operations while they are running, thereby enabling the addition or removal of memory without stopping the virtual machine. Virtualization platforms (such as VMware ESXi, KVM, and Hyper-V) provide relevant functions and interfaces that allow virtual machines to dynamically increase or decrease memory resources. The specific steps are as follows.
[0038]
[0038] First, ensure that the configuration of the virtual machine allows memory hot-plugging operations, which usually requires setting the memory hot-plugging parameters of the virtual machine and ensuring that the operating system and application of the virtual machine support memory hot-plugging; then, in the virtualization management tool or console, select the virtual machine whose memory is to be adjusted, and perform the operation of increasing or decreasing memory according to the instructions of the virtualization platform; after receiving the memory change, the operating system inside the virtual machine will automatically respond and reallocate and configure memory resources so that the newly added memory can be effectively used by the operating system and application.
[0039]
[0039] It should be noted that the memory hot-swap operation for the virtual machine in the virtual environment is actually an operation for the virtual memory rather than the physical memory of the host machine. The virtual memory is expanded, and its function is affected by the limitations and support level of the virtualization platform and cannot be used for the host machine operating system.
[0040]
[0040] Therefore, there is an urgent need for a memory expansion method that allows a running host operating system to have a hot upgrade capability and can use hot-pluggable memory (newly added extended memory) for specific programs.
[0041]
[0041] In the present disclosure, a memory expansion method is provided. The present disclosure also relates to a memory expansion 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.
[0042]
[0042] Referring to FIG1 , FIG1 shows a schematic diagram of a scenario of a memory expansion method provided according to an embodiment of the present disclosure.
[0043]
[0043] Specifically, the memory expansion method is implemented by applying the end-side device 102 and the server 104, the end-side device 102 is used to send a memory expansion instruction to the server 104, that is, to expand the memory in the server 104; the server 104 receives the memory expansion instruction, wherein the memory expansion instruction is associated with the target operating system, and the target operating system is obtained by converting the operating system running in the physical mode to the virtual mode; according to the memory expansion instruction, a memory expansion parameter is determined, and the memory management interface of the target operating system is called to add the extended memory corresponding to the memory expansion parameter to the target operating system; based on the memory management function preset by the memory management function, the extended memory is allocated to the target memory pool corresponding to the target operating system, wherein the memory contained in the target memory pool is used by the target operating system, and the extension result, such as the message of successful extension and available memory after extension, is returned to the end-side device 102.
[0044] The end-side device 102 may include a browser, an application (APP), or a web application such as an H5 (Hypertext Markup Languages, version 5) application, a light application (also known as a mini-program, a lightweight application), or a cloud application. The end-side device may be developed based on a software development kit (SDK) of a corresponding service provided by the server, such as a real-time communication (RTC) SDK. The end-side device may be deployed in an electronic device and may rely on the device or certain APPs in the device to operate. The electronic device may have a display and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, or a personal computer. Various other types of applications may also be configured in the electronic device, such as human-computer interaction applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0045]
[0045] Server 104 can be understood as a server that provides various services, including physical servers and cloud servers. For example, a server that provides communication services to multiple clients, a server that supports backend training of models used on clients, or a server that processes data sent by clients. It should be noted that server 104 can be implemented as a distributed server cluster consisting of multiple servers or as a single server. Server 104 can also be a server in a distributed system or a server integrated with blockchain. Server 104 can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0046]
[0046] A memory expansion method provided by an embodiment of the present disclosure switches a running host operating system into a target operating system running in virtual mode, receives a memory expansion instruction for the target operating system, adds corresponding extended memory to the target operating system, and performs smooth and flexible memory expansion without stopping the operation of the target operating system, thereby ensuring that services in the operating system are not interrupted, achieving user-friendly operation, reducing various unstable factors caused by restarting the operating system, and enhancing the stability and reliability of the operating system. In addition, the extended memory can be allocated to the target memory pool on demand, so that the extended memory in the target memory pool can be used by the target process corresponding to the target memory pool, thereby significantly improving the operating performance of the target process.
[0047]
[0047] Referring to FIG. 2 , FIG. 2 shows a flow chart of a memory expansion method provided by an embodiment of the present disclosure, which specifically includes the following steps.
[0048]
[0048] Step 202: Receive a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system, and the target operating system is obtained by converting an operating system running in a physical mode to running in a virtual mode.
[0049]
[0049] The memory expansion instruction may be understood as an instruction for causing the target operating system to perform memory expansion; the memory expansion instruction may carry memory expansion parameters, and the memory expansion parameters may include the starting address of the memory to be expanded and the size of the memory to be expanded.
[0050]
[0050] The operating system is configured with a memory management function, which can implement memory allocation, memory recycling, address translation, etc.; memory allocation, such as when a process requests memory, the operating system divides a suitable area from the available memory and allocates it to the process; memory recycling, such as when a process ends or releases an unused memory area, the operating system promptly reclaims this memory space for use by other processes; address translation, such as the operating system provides a virtual address space for each process, and performs address translation between virtual addresses and physical addresses through data structures such as page tables.
[0051]
[0051] The physical mode can be understood as root mode or kernel mode; the virtual mode can be understood as non-root mode or user mode; and the target operating system can be understood as an operating system running in non-root mode.
[0052]
[0052] Specifically, a memory expansion instruction for a target operating system running in a non-root mode, submitted by a memory management function, is received, so that the target operating system performs memory expansion.
[0053] In one or more embodiments of the present disclosure, before receiving the memory expansion instruction, it is necessary to convert the operating system running in root mode to a target operating system running in non-root mode according to the received configuration change instruction. The specific implementation is as follows.
[0054]
[0054] Before receiving the memory expansion instruction, the method further includes: receiving a configuration change instruction submitted for the operating system running in the physical mode; and converting the operating system into a target operating system running in the virtual mode according to the configuration change instruction.
[0055]
[0055] The configuration change instruction can be understood as a change instruction for causing the operating system to perform a mode conversion.
[0056]
[0056] Specifically, when memory expansion is required, since the operating system running in root mode can only add memory online when there is physical memory, it is necessary to first convert the operating system's operating mode and expand the memory in the target operating system running in non-root mode.
[0057]
[0057] In actual applications, when it is necessary to expand the memory of a running operating system, a configuration change instruction is first sent to the operating system, thereby switching the operating mode of the operating system according to the configuration change instruction.
[0058]
[0058] The memory expansion method provided by the embodiment of the present disclosure can dynamically convert the operating system running in physical mode to running in virtual mode according to actual needs by receiving a configuration change instruction, thereby achieving flexible scheduling and efficient utilization of resources.
[0059] In one or more embodiments of the present disclosure, when it is necessary to convert the operating system to a target operating system running in non-root mode according to a configuration change instruction, a series of configuration operations must first be performed to complete the mode switch. The specific implementation is as follows.
[0060]
[0060] The method of converting the operating system into a target operating system running in a virtual mode according to the configuration change instruction includes: establishing an address mapping page table for the operating system according to the configuration change instruction, and saving initial data of registers corresponding to the operating system running in the physical mode; establishing a target data structure according to the address mapping page table and the initial data; configuring target data in the target data structure, and loading the configured target data structure into a central processing unit, thereby triggering the operating system to be converted into a target operating system running in a virtual mode, wherein the target data is control information corresponding to the target operating system.
[0061]
[0061] The address mapping page table can be understood as an EPT page table. The EPT page table contains page table entries for recording the mapping of virtual addresses to physical addresses. Since the operating system running in root mode has not yet been converted to the target operating system running in non-root mode, the GPA in the EPT page table is equal to the HPA.
[0062]
[0062] The initial data can be understood as the data in the register; the target data structure can be understood as VMCS, a data structure used to manage and control the target operating system execution environment; and the target data can be understood as the fields and information related to controlling the virtual execution environment.
[0063] Specifically, when a configuration change instruction is received, an EPT page table mapping from the GPA to the HPA is established, and all state information of the currently running CPU is saved, including but not limited to all data affecting the CPU execution state, such as general registers, control registers, and flag registers; and a VMCS running in virtual mode is established based on the values of these registers and the EPT page table.
[0064]
[0064] The VMCS contains a large number of fields and information related to the virtual execution environment. The VCPU (central processing unit running in virtual mode) is controlled by configuring the fields in the VMCS. For example, the VM-entry / VM-exit (virtual machine entry / virtual machine exit) control bits in the VMCS are set to specify which instructions should be intercepted. For example, an exit processing function is set during the virtualization mode operation. When an EPT violation (EPT violation, when the CPU attempts to access an address, if the EPT mapping of the address is not correctly set or the permissions do not match, an EPT violation exception will occur) exception causes a VM exit, the exit processing function is used to set the EPT page fault processing function corresponding to the EPT violation to handle the VM exit caused by the EPT violation exception.
[0065] By loading the configured VMCS into the CPU, the running central processing unit is switched to a VCPU running in non-root mode, so that the running host machine (physical machine running in root mode) enters the virtual mode, which is equivalent to triggering the switching of the operating system mode, that is, converting the operating system to the target operating system running in virtual mode.
[0066]
[0066] The memory expansion method provided by the embodiment of the present disclosure can accurately and effectively complete the conversion of the operating system mode by establishing an address mapping page table and saving the initial data of the register, establishing a target data structure, and configuring the target data of the target data structure.
[0067]
[0067] In one or more embodiments of the present disclosure, to more effectively manage and organize memory space, the memory is divided into blocks of fixed granularity, and the memory state of the memory block is set to be in use. The specific implementation is as follows.
[0068]
[0068] After converting the operating system into a target operating system running in virtual mode according to the configuration change instruction, the method further includes: dividing the physical memory corresponding to the target operating system into memory blocks of preset granularity through the memory management function; and setting the memory state of the memory block to a used state.
[0069]
[0069] The preset granularity can be set according to actual needs and is not limited here. For example, the preset granularity is 2MB (megabyte).
[0070] Specifically, all real physical memory of the host machine can be divided into memory blocks with a granularity of 2M. Since all physical memory is managed by the host machine, when the host machine runs in virtual mode, the initial memory state of all physical memory is used.
[0070]
[0071] The memory expansion method provided by the embodiments of the present disclosure divides physical memory into blocks of fixed granularity, thereby facilitating the management and organization of memory space and reducing the generation of memory fragmentation. It can also efficiently manage each memory block and thus more efficiently allocate physical memory resources.
[0071]
[0072] In one or more embodiments of the present disclosure, currently free pages are found, page table entries corresponding to the free pages in the address mapping page table are deleted, and the memory state is updated to facilitate subsequent allocation of free pages. The specific implementation is described below.
[0072]
[0073] After setting the memory state of the memory block to the used state, the method further includes: determining, through the memory management function, a current idle page corresponding to the target operating system, wherein the idle page is a physical memory page that is not currently occupied by any process and can be allocated to a process by the target operating system for use, and the physical memory pages constitute the physical memory; deleting a page table entry in the address mapping page table corresponding to the idle page, and updating the memory state corresponding to the idle page to an idle state, wherein the address mapping page table is composed of the page table entries, and the page table entries record the mapping of virtual addresses to physical addresses.
[0073]
[0074] In actual applications, physical memory pages are the allocation units of physical memory, that is, when allocating physical memory to a process, it is allocated page by page.
[0074]
[0075] Specifically, the memory management function traverses the currently idle pages in the host machine. When a physical page becomes idle, it means that the page is not referenced by any virtual address. Therefore, its corresponding page table entry can be deleted from the address mapping page table, and the memory status is updated to idle. By adding the idle page to the global free list, it is convenient to quickly find the allocatable physical memory page during subsequent memory allocation operations.
[0075]
[0076] The memory expansion method provided by the embodiments of the present disclosure ensures the effective management and rational utilization of physical memory and provides the necessary foundation for memory scheduling in a multi-tasking environment. By adding free pages to the global free list, it facilitates the rapid identification of allocatable physical memory pages during subsequent memory allocation operations.
[0076]
[0077] Step 204: Determine memory extension parameters according to the memory extension instruction, and call the memory management interface of the target operating system to add extended memory corresponding to the memory extension parameters for the target operating system.
[0077]
[0078] The memory expansion parameters include the address space of the expanded memory and the size of the expanded memory. The memory management interface can be understood as an expansion interface, and the expansion memory is added by calling the expansion interface.
[0078]
[0079] In actual applications, when expanding the memory of a virtual machine, it is necessary to notify the operating system of the memory expansion through a complex hardware interrupt mechanism. However, when the memory expansion method provides various functions in the form of modules, the extended memory corresponding to the memory expansion parameters can be added to the target operating system by directly calling the extension interface of the target operating system.
[0079]
[0080] In one or more embodiments of the present disclosure, to accurately add extended memory, the extended memory is added within the virtual memory address range corresponding to the target operating system, ensuring that the target operating system can provide a larger available memory space for the application. The specific implementation is described below.
[0080]
[0081] The determining memory extension parameters according to the memory extension instruction and calling the memory management interface of the target operating system to add extended memory corresponding to the memory extension parameters for the target operating system includes: determining memory extension parameters according to the memory extension instruction, wherein the memory extension parameters include a virtual memory address range corresponding to the extended memory; and calling the memory management interface of the target operating system to add the extended memory in the virtual memory address range corresponding to the target operating system.
[0081]
[0082] The virtual memory address range may be understood as an address space range determined according to the address space of the extended memory and the size of the extended memory.
[0082]
[0083] If extended memory is needed, the GPA address space and size of the extended memory (i.e., memory expansion parameters) must be determined. First, the target operating system's current maximum physical page frame number (PFN) must be determined. After obtaining the maximum PFN, an address range above the current maximum PFN is selected as the new memory mapping area. For example, if the target operating system's maximum PFN corresponds to the end of a 40GB (gigabyte) memory space, the newly added extended memory can be allocated starting after 40GB and allocated based on the extended memory size.
[0083]
[0084] The memory expansion method provided in the embodiments of the present disclosure can meet the needs of application products in the host machine by expanding the memory. It can also avoid the problem of insufficient available memory leading to the inability to allocate required memory to the process, thereby triggering abnormal termination of the system or forced killing of some processes, or the problem of being unable to upgrade to the latest product.
[0084]
[0085] Step 206: Based on a memory management function preset by a memory management function, the extended memory is allocated to a target memory pool corresponding to the target operating system, wherein the memory contained in the target memory pool is used by the target operating system.
[0085]
[0086] The memory management function can be understood as a processing function for extended memory, used to process and manage the extended memory. For example, the memory management function can be used to allow the extended memory to enter a specific memory pool, such as the hugetlb (Huge Translation Lookaside Buffer, a memory management mechanism used to support large page memory) or a dedicated pool.
[0086]
[0087] The target memory pool can be understood as the specific memory pool mentioned above, which can be used to meet the memory requirements of specific programs (such as programs for high-performance computing resources).
[0087]
[0088] In actual applications, in order to allow the extended memory to enter a specific memory pool, the extended memory processing function will be preset through the memory management function, so that the extended memory can be processed when the extended memory is added.
[0088]
[0089] In one or more embodiments of the present disclosure, a target memory pool mechanism may be set to dynamically allocate extended memory, thereby achieving processing allocation for extended memory. The specific implementation is described below.
[0089]
[0090] The allocating the extended memory to the target memory pool corresponding to the target operating system includes: allocating the extended memory to the target memory pool corresponding to the target operating system according to a target memory pool mechanism.
[0090]
[0091] The allocating the extended memory to the target memory pool corresponding to the target operating system according to the target memory pool mechanism includes: setting the target memory pool for use by the target process, allocating the extended memory to the target memory pool corresponding to the target operating system, so that the target process uses the extended memory in the target memory pool; or setting the target memory pool for use by the code segment and / or data segment in the target process, allocating the extended memory to the target memory pool corresponding to the target operating system, so that the code segment and / or data segment in the target process uses the extended memory in the target memory pool.
[0091]
[0092] The target process may be understood as a process that is set to be allowed to use the target memory pool.
[0092]
[0093] Specifically, for a specific memory pool, you can dynamically set the processes that are allowed to use the specific memory pool, so that the target process uses the memory in the target memory pool; you can also set the code segment or data segment of the corresponding process to use the memory in the specific memory pool, so that the target process uses the memory in the target memory pool.
[0093]
[0094] Of course, in actual applications, the extended memory can also be allocated to the general memory corresponding to the target operating system, which is not limited here.
[0094]
[0095] The memory expansion method provided by the embodiments of the present disclosure provides dedicated memory space for a specific target process or for the code segment and / or data segment of the target process by setting the target memory pool to be used. This reduces memory contention between different processes and helps improve the data reading and writing speed and execution efficiency of the target process.
[0095]
[0096] In one or more embodiments of the present disclosure, the size of a specific memory pool can be dynamically adjusted to ensure that the capacity of the specific memory pool can meet the size of the extended memory. The specific implementation is described below.
[0096]
[0097] Allocating the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism includes: adjusting a capacity configuration of the target memory pool according to a memory expansion parameter of the extended memory so that the capacity of the target memory pool matches the size of the extended memory; and allocating the extended memory to the adjusted target memory pool corresponding to the target operating system.
[0097]
[0098] Specifically, when the newly added extended memory is smaller than the capacity of the specific memory pool, the newly added extended memory is added to the specific memory pool; when the newly added extended memory is larger than the specific memory pool, the excess extended memory is placed in the general memory.
[0098]
[0099] In actual applications, the size of a specific memory pool can also be dynamically adjusted. For example, if the newly added extended memory is smaller than the current size of the specific memory pool, some memory in the specific memory pool is released to the general memory. Otherwise, memory is obtained from the general hugetlb and the extended memory is allocated to the adjusted target memory pool. It should be noted that if a memory allocation request for a specific memory pool cannot be satisfied due to insufficient memory in the specific memory pool, the target operating system does not immediately report a memory allocation failure. Instead, it falls back to the normal memory allocation path and searches for a suitable memory area within the overall available memory to complete the allocation.
[0099]
[0100] The memory expansion method provided by the embodiments of the present disclosure can effectively utilize the newly added memory resources by adjusting the capacity of the target memory pool to match the expanded memory, thereby avoiding memory waste and improving the overall system performance.
[0100]
[0101] In one or more embodiments of the present disclosure, in order to enable an application to use the newly added extended memory when extended memory is added, an exception handling function is set to perform processing. The specific implementation is as follows.
[0101]
[0102] After allocating the extended memory to the target memory pool corresponding to the target operating system, the method further includes: when a target process running in the target operating system uses the extended memory in the target memory pool and triggers a page fault exception, calling an exception handling function corresponding to the page fault exception according to the page fault exception; based on the exception handling function, determining a target memory block through the memory management function, and establishing a page table entry corresponding to the extended memory and the target memory block, wherein the target memory block is a memory block whose memory status is idle; mapping the extended memory to the target memory block through the page table entry corresponding to the extended memory and the target memory block.
[0102]
[0103] Specifically, when the process uses the newly added extended memory, since the underlying layer has not yet established a mapping between it and the real physical memory, a page fault exception will be automatically triggered and the EPT violation processing path will be followed. At this time, according to the triggered page fault exception, the EPT page fault processing function set above will be called, and an unused (currently idle) memory block will be found from the memory block as the target memory block. The EPT page table entry corresponding to the extended memory and the target memory block will be established, and the mapping relationship between the virtual address and the newly allocated physical address (target memory block address) will be recorded. The operating system will restart the process that was suspended due to the page fault exception, so that it can continue execution and successfully access the previously inaccessible extended memory area.
[0104] The memory expansion method provided by the embodiment of the present disclosure effectively solves the page fault exception problem by calling the exception handling function corresponding to the page fault exception, and realizes the dynamic mapping of the virtual memory address to the physical memory address, so that the process can smoothly use the newly added extended memory resources.
[0103]
[0105] In one or more embodiments of the present disclosure, to ensure that the underlying memory management function can allocate memory blocks, a reasonable amount of free memory is required in the underlying physical memory. Therefore, a memory free space can be set. The size of the memory free space can be used to determine whether a reasonable amount of free memory is currently available and to perform corresponding processing operations. The specific implementation method is described below.
[0104]
[0106] The memory expansion method further includes: setting memory free space in the physical memory corresponding to the target operating system through the memory management function; triggering a memory reclamation operation to release the physical memory in the idle state when the memory free space is lower than a first threshold and higher than a second threshold; and sending a processing notification to an operation and maintenance program when the memory free space is lower than the second threshold, so that the operation and maintenance program performs process migration and data protection operations according to the processing notification.
[0105]
[0107] The first threshold and the second threshold can be set according to actual conditions, and in actual applications, the first threshold and the second threshold can also be expressed as a ratio; for example, the first threshold is 30% and the second threshold is 10%. The operation and maintenance program can be understood as a program for operating and maintaining the system to ensure the safe operation of the system.
[0106]
[0108] In practical applications, memory free space can be visually represented by a memory water level. When the memory water level is higher than a first threshold, it is considered to be at a high water level, indicating that there is a lot of free memory. In this case, the status quo can be maintained without any processing. When the memory water level is lower than the first threshold but higher than the second threshold, it is considered to be between the high water level and the low water level, triggering a memory reclamation operation, i.e., reclaiming free memory or compressing memory, etc., to make room for free memory in the underlying layer. Specifically, when reclaiming memory, priority is given to reclaiming cold pages (cold pages refer to free pages that are no longer in the cache) or free memory.
[0107]
[0109] When the memory level is lower than the second threshold, it is considered that the memory level is lower than the emergency level, and the EPT page fault will return a failure so that a backup memory can be reserved to ensure that the system can continue to run for a period of time. At the same time, a processing notification needs to be sent to the upper-level operation and maintenance program so that the operation and maintenance program can perform emergency migration and other processing before the system crashes according to the processing notification.
[0108]
[0110] A memory expansion method provided by one embodiment of the present disclosure monitors and adjusts physical memory usage in real time by setting memory free space, ensuring that the system can dynamically allocate and reclaim memory resources based on actual needs, thereby improving memory utilization. Furthermore, by sending processing notifications, it can greatly enhance system stability and availability, while reducing operation and maintenance costs.
[0109]
[0111] An embodiment of the present disclosure provides a memory expansion method that switches an operating system running in physical mode to a target operating system running in virtual mode, receives memory expansion instructions for the target operating system, and adds corresponding extended memory to the target operating system. This method performs smooth and flexible memory expansion without stopping the target operating system, ensuring that services in the operating system are not interrupted. This method achieves user-friendly operation, reduces various instabilities caused by restarting the operating system, and enhances the stability and reliability of the operating system. Furthermore, if the extended memory can be allocated to a target memory pool on demand, the extended memory in the target memory pool can be made available to the target process by setting usage permissions for the memory in the target memory pool, significantly improving the operating performance of the target process.
[0110]
[0112] 3 , which shows a flow chart of a processing process of a memory expansion method provided by an embodiment of the present disclosure, specifically including the following steps.
[0111]
[0113] Step 302: Create an address mapping table.
[0112]
[0114] Specifically, when the configuration change instruction is received, an EPT page table mapping from GPA to HPA is established. Since the operating system running in root mode has not yet been converted to a target operating system running in non-root mode, the GPA at this time is equal to the HPA.
[0113]
[0115] Step 304: Save the register value and create a target data structure.
[0114]
[0116] When the operating mode of the current operating system needs to be switched, all status information of the currently running CPU needs to be saved first, including but not limited to various general registers, control registers, flag registers and other data that affect the CPU execution status.
[0115]
[0117] A VMCS running in virtual mode is established based on the data in these registers and the EPT. During the VMCS establishment process, the EPT configuration is required to ensure the correct memory access of the target operating system after the switch. After the VMCS is established, the register values of the VCPU (virtual central processing unit) corresponding to the target operating system are loaded based on the information in the VMCS, thereby restoring the target operating system's execution environment. In this way, when the target operating system is rescheduled, execution can resume from the previously saved state, ensuring the continuity and independence of the target operating system's execution.
[0116]
[0118] Step 306: Configure the target data structure and set the exit function.
[0117]
[0119] The exit function can be understood as an exit processing function during the virtual mode operation, which is used to switch from the non-root mode back to the root mode when a specific event is triggered during the execution of the target operating system.
[0118]
[0120] The VMCS contains numerous fields and information related to the virtual execution environment. Control over the VCPU is achieved by configuring the VMCS fields. For example, the VM-entry / VM-exit control bits in the VMCS specify which instructions should be intercepted. For example, during the VMCS setup and initialization process, the relevant VM Exit information must be correctly configured. For EPT violations (EPT violations occur when the CPU attempts to access an address but the EPT mapping for that address is incorrectly set or the permissions do not match), the corresponding VM Exit control bits must be enabled and the corresponding exit fields configured to capture different types of EPT violations, such as read, write, or execute permissions.
[0119]
[0121] When an EPT Violation exception causes a VM Exit, the exit processing function is the EPT page fault processing function corresponding to the EPT Violation, which is used to handle the VM Exit caused by the EPT Violation exception.
[0120]
[0122] Step 308: Switch the operating mode.
[0121]
[0123] After the VMCS is configured, instructions are sent to the CPU of the running physical machine to load the configured VMCS into the CPU. This step causes the CPU to start running in virtual mode according to the configuration in the VMCS. This switches the running CPU to a VCPU running in virtual mode, causing the running physical machine to enter virtual mode.
[0122]
[0124] Step 310: Divide the memory blocks and set the memory states of the memory blocks.
[0123]
[0125] A memory block management function is established for all real physical memory of the physical machine. That is, in order to efficiently manage and allocate physical memory resources, continuous physical memory will be divided into memory blocks of equal or unequal sizes. For example, physical memory can be divided into multiple memory blocks with a granularity of 2MB (megabytes). Since all physical memory is managed by the physical machine, when the physical machine runs in virtual mode, the initial memory state of all physical memory is used.
[0124]
[0126] Step 312: Determine the free page and update the memory status of the memory block.
[0125]
[0127] Traverse all memory blocks in the physical machine and search for physical memory pages whose memory status is "used" but are actually currently idle. For each idle page found, obtain its page table entry in the EPT and clear or set the corresponding page table entry to zero through the EPT operation instruction, thereby undoing the mapping of virtual memory and updating the memory status of these idle pages to idle for subsequent allocation.
[0126]
[0128] Step 314: Set a memory management function and determine memory expansion parameters for the extended memory.
[0127]
[0129] The memory management function can be understood as an extended memory processing function used to place extended memory into a dedicated memory pool. Specifically, a dedicated memory pool is first created and initialized to meet the memory requirements of specific programs (such as programs for high-performance computing resources). The general hugetlb is used to dynamically allocate large pages to any required large page requests.
[0128]
[0130] In actual applications, you can manage newly added extended memory by setting a processing function for extended memory. This allows the newly added extended memory to enter a dedicated memory pool, which is configured with the required memory capacity. Extended memory is prioritized in the dedicated pool. If there is still some extended memory available, it is placed in the general hugetlb, ensuring that the added extended memory is prioritized in the dedicated memory pool.
[0129]
[0131] If extended memory is needed, the GPA address space and size of the extended memory (i.e., memory expansion parameters) must be determined. First, the target operating system's current maximum physical page frame number (PFN) must be determined. After obtaining the maximum PFN, an address range above the current maximum PFN is selected as the new memory mapping area. For example, if the target operating system's maximum PFN corresponds to the end of a 40GB (gigabyte) memory space, the newly added extended memory can be allocated starting after 40GB.
[0130]
[0132] Step 316: Add virtual memory to the specific memory pool.
[0131]
[0133] In actual applications, when expanding the memory of a virtual machine, it is necessary to notify the operating system of the memory expansion through a complex hardware interrupt mechanism. When the memory expansion method provides various functions in the form of modules, the memory management interface (extension interface) of the target operating system can be directly called to add the extended memory corresponding to the memory expansion parameters to the target operating system. This avoids the problem of large-scale OOM (Out of Memory) on online hosts due to insufficient memory (due to insufficient available memory, the required memory cannot be allocated to the process, thereby triggering abnormal termination of the system or forcibly killing some processes).
[0132]
[0134] Based on the processing function of the extended memory set above, the extended memory can be allocated to a specific memory pool corresponding to the target operating system (ie, the dedicated memory pool in the above embodiment) for use by a specific process.
[0133]
[0135] Step 318: Configure a specific memory pool.
[0134]
[0136] Specifically, the specific memory pool can be set according to actual needs. For example, for a specific memory pool, the processes allowed to use the specific memory pool can be dynamically set; the code segment or data segment of the corresponding process can also be set to use the memory in the specific memory pool.
[0135]
[0137] If the newly added extended memory is smaller than the specific memory pool, the newly added extended memory is added to the specific memory pool. If the newly added extended memory is larger than the specific memory pool, the excess extended memory is placed in the general memory. The size of the specific memory pool can also be adjusted dynamically. For example, if the newly added extended memory is smaller than the current size of the specific memory pool, some memory in the specific memory pool is released to the general memory. Otherwise, memory is obtained from the general hugetlb. If there is a memory allocation request for the specific memory pool and the specific memory pool does not have enough memory, the request cannot be satisfied. In this case, the target operating system does not immediately report a memory allocation failure. Instead, it chooses to fall back to the regular memory allocation path and find a suitable memory area from the overall available memory to complete the allocation.
[0138] Step 320: Use extended memory to trigger a page fault exception.
[0136]
[0139] Subsequently, when the application uses the extended memory, since the underlying layer has not yet established a mapping between it and the real physical memory, a page fault exception will be automatically triggered and the above-mentioned EPT violation processing path will be followed.
[0137]
[0140] Step 322: Determine unused memory blocks according to the page fault processing function.
[0138]
[0141] According to the EPT violation exception, the EPT page fault handling function is used to find an unused (currently idle) memory block from the memory block to establish the EPT page table corresponding to the extended memory and the memory block, so that the application can use the newly extended virtual memory.
[0139]
[0142] Step 324: Set the memory water level.
[0140]
[0143] Specifically, the memory block management function can set a memory watermark for physical memory to ensure a reasonable amount of free memory within the memory block management function. The memory watermark indicates the amount of free memory currently available. If the memory watermark is at the high watermark, indicating a large amount of free memory, the current status is maintained. If the memory watermark is below the high watermark but above the low watermark, free memory is reclaimed or compressed to obtain more free memory. If the memory watermark is below the low watermark but above the emergency watermark, memory reclamation is accelerated. Specifically, when reclaiming memory, cold pages (cold pages are free pages no longer in the cache) or free memory are prioritized to ensure a reasonable memory watermark. If the memory watermark is below the emergency watermark, if an EPT page fault exception is triggered, no memory block will be allocated for extended memory and a failure will be returned. This allows the system to reserve a preset amount of memory to ensure continued operation for a period of time. At the same time, the upper-level operation and maintenance program must be notified of the severe memory shortage so that it can perform emergency migration and other operations before a system crash occurs.
[0141]
[0144] Of course, in actual applications, when system resources are relatively idle, extended memory can be reclaimed. This allows the system to more centrally utilize existing physical memory resources. Furthermore, when cold pages are identified using a predetermined strategy, the higher the accuracy of identification, the lower the probability of page fault exceptions, thereby reducing system operating overhead and performance loss. Specifically, when system resources are sufficient and utilization is low, properly adjusting the memory allocation strategy to restrict more operations to the real physical memory range can help improve overall system performance and response speed.
[0142]
[0145] An embodiment of the present disclosure provides a memory expansion method that switches the operating mode of an operating system. Without stopping the target operating system, the method adds corresponding extended memory to the target operating system by calling an interface based on memory expansion instructions. Compared with a method in which a virtual machine notifies the operating system of memory expansion through a complex hardware interrupt mechanism, this method not only greatly improves expansion efficiency but also achieves user-friendly operation, reduces various instabilities caused by restarting the operating system, and enhances the stability and reliability of the operating system.
[0143]
[0146] 4 , which shows a flowchart of another memory expansion method provided by an embodiment of the present disclosure, specifically including the following steps 402 to 408.
[0144]
[0147] Step 402: Receive a configuration change instruction submitted by an operating system running in physical mode.
[0145]
[0148] Step 404: Convert the operating system to a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function.
[0146]
[0149] Step 406: upon receiving the memory expansion instruction submitted by the memory management function, determining memory expansion parameters according to the memory expansion instruction, and calling the memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters for the target operating system.
[0150] Step 408: Based on the memory management function preset by the memory management function, the extended memory is allocated to a target memory pool corresponding to the target operating system, wherein the target memory contained in the target memory pool is used by the target operating system.
[0147]
[0151] For details, please refer to the above embodiments and will not be described again here.
[0148]
[0152] A memory expansion method provided by one embodiment of the present disclosure can implement the transition of an operating system from physical mode to virtual mode. By receiving a memory expansion instruction and dynamically adding extended memory according to the instruction, the target operating system can increase memory resources according to actual needs during runtime, thereby improving the system's resource utilization efficiency and response speed. In addition, a preset memory management function can effectively manage and allocate the extended memory to the target memory, ensuring that the newly added memory resources can be used reasonably and efficiently by the target operating system, avoiding memory resource waste, and also improving the overall performance and stability of the system.
[0149]
[0153] Corresponding to the above-mentioned method embodiments, the present disclosure also provides an embodiment of a memory expansion device. FIG5 shows a schematic structural diagram of a memory expansion device provided in one embodiment of the present disclosure. As shown in FIG5 , the device includes: a receiving module 502 configured to receive a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system, and the target operating system is obtained by converting from an operating system running in physical mode to a virtual mode; a determining module 504 configured to determine memory expansion parameters based on the memory expansion instruction, and invoke a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters to the target operating system; and an allocating module 506 configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by the memory management function, wherein the target memory contained in the target memory pool is for use by the target operating system.
[0150]
[0154] The device further includes a conversion module configured to: receive a configuration change instruction submitted for an operating system running in a physical mode; and convert the operating system into a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function.
[0151]
[0155] Optionally, the conversion module is further configured to: establish an address mapping page table for the operating system according to the configuration change instruction, and save the initial data of the register, wherein the address mapping page table is composed of page table entries, and the page table entries record the mapping of virtual addresses to physical addresses; establish a target data structure according to the address mapping page table and the initial data; configure the target data in the target data structure, and load the configured target data structure into the target processor, triggering the operating system to convert to the target operating system running in virtual mode.
[0152]
[0156] The device further includes a management module configured to: divide the physical memory of the target operating system into memory blocks of a preset granularity through the memory management function, wherein the physical memory is the hardware resource corresponding to the physical address; and set the memory state of the memory block to an initial use state.
[0153]
[0157] Optionally, the management module is further configured to: determine the current free page of the target operating system through the memory management function, wherein the free page is a physical memory page that is not currently occupied by any process and can be allocated and used by the target operating system, and the physical memory page is obtained by dividing the physical memory into blocks of a fixed size; delete the page table entry in the address mapping page table corresponding to the free page, and update the memory status of the memory block corresponding to the free page to an idle state.
[0154]
[0158] Optionally, the determination module 504 is further configured to: determine memory extension parameters according to the memory extension instruction, wherein the memory extension parameters include a virtual memory address range corresponding to the extended memory; and call a memory management interface of the target operating system to add the extended memory to the virtual memory address range corresponding to the target operating system.
[0155]
[0159] Optionally, the allocation module 506 is further configured to: allocate the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism.
[0156]
[0160] Optionally, the allocation module 506 is further configured to: set the target memory pool for use by the target process, or the code segment and / or data segment in the target process, and allocate the extended memory to the target memory pool corresponding to the target operating system, so that the target process, or the code segment and / or data segment in the target process, uses the extended memory in the target memory pool.
[0157]
[0161] Optionally, the allocation module 506 is further configured to: adjust the capacity configuration of the target memory pool according to the memory extension parameters of the extended memory so that the capacity of the target memory pool matches the size of the extended memory; and allocate the extended memory to the target memory pool corresponding to the target operating system.
[0158]
[0162] The device further includes a processing module configured to trigger a page fault exception when a target process running in the target operating system uses the extended memory in the target memory pool, and call an exception handling function corresponding to the page fault exception based on the page fault exception; determine a target memory block through the memory management function based on the exception handling function, establish a page table entry corresponding to the extended memory and the target memory block, and map the virtual memory to the target memory block.
[0159]
[0163] The device further includes a setting module, which is configured to set a memory water level in the physical memory of the target operating system through the memory management function, wherein the memory water level represents the water level of the idle physical memory; when the memory water level is lower than a first threshold and higher than a second threshold, trigger a memory recycling operation to release the physical memory in the idle state; when the memory water level is lower than the second threshold, send a processing notification to the operation and maintenance program, and perform process migration and data protection operations according to the processing notification.
[0160]
[0164] A memory expansion device provided by one embodiment of the present disclosure switches an operating system running in physical mode to a target operating system running in virtual mode, receives memory expansion instructions for the target operating system, and adds corresponding extended memory to the target operating system. This device performs smooth and flexible memory expansion without stopping the target operating system, ensuring that services in the operating system are not interrupted. This achieves user-friendly operation, reduces various instabilities caused by restarting the operating system, and enhances the stability and reliability of the operating system. Furthermore, the device can allocate extended memory to a target memory pool on demand, allowing the extended memory in the target memory pool to be used by the target process corresponding to the target memory pool, significantly improving the operating performance of the target process.
[0161]
[0165] The above is a schematic diagram of a memory expansion device according to this embodiment. It should be noted that the technical solution of the memory expansion device and the technical solution of the aforementioned memory expansion method share the same concept. For details not described in detail in the technical solution of the memory expansion device, please refer to the description of the technical solution of the aforementioned memory expansion method.
[0162]
[0166] Corresponding to the above-mentioned method embodiment, the present disclosure also provides another embodiment of a memory expansion device. FIG6 shows a schematic structural diagram of another memory expansion device provided by one embodiment of the present disclosure. As shown in FIG6 , the device includes: a receiving module 602 configured to receive a configuration change instruction submitted by an operating system running in physical mode; a conversion module 604 configured to convert the operating system into a target operating system running in virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function; a determining module 606 configured to, upon receiving a memory expansion instruction submitted by the memory management function, determine memory expansion parameters based on the memory expansion instruction and invoke a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters to the target operating system; and an allocating module 608 configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by the memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.
[0163]
[0167] A memory expansion device provided in one embodiment of the present disclosure can implement the transition of an operating system from physical mode to virtual mode. By receiving memory expansion instructions and dynamically adding extended memory according to the instructions, the target operating system can increase memory resources according to actual needs during runtime, thereby improving the system's resource utilization efficiency and response speed. Furthermore, a preset memory management function can effectively manage and allocate extended memory to the target memory pool, ensuring that the newly added memory resources can be used reasonably and efficiently by the target operating system, avoiding memory resource waste and improving the overall performance and stability of the system.
[0164]
[0168] The above is a schematic diagram of a memory expansion device according to this embodiment. It should be noted that the technical solution of the memory expansion device and the technical solution of the aforementioned memory expansion method share the same concept. For details not described in detail in the technical solution of the memory expansion device, please refer to the description of the technical solution of the aforementioned memory expansion method.
[0165]
[0169] FIG7 shows a block diagram of a computing device 700 according to an embodiment of the present disclosure. 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. A database 750 is used to store data.
[0166]
[0170] 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 such 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)) whether wired or wireless, 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) interface.
[0167]
[0171] In one embodiment of the present disclosure, the aforementioned components of computing device 700 and other components not shown in FIG. 7 may also be connected to one another, for example, via a bus. It should be understood that the computing device block diagram shown in FIG. 7 is for illustrative purposes only and does not limit the scope of the present disclosure. Those skilled in the art may add or replace other components as needed.
[0168]
[0172] Computing device 700 can 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 can also be a mobile or stationary server.
[0169]
[0173] The processor 720 is configured to execute the following computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by the processor.
[0174] The various embodiments of this disclosure are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the computing device embodiment is generally similar to the memory expansion method embodiment, so its description is relatively simple. For relevant portions, refer to the description of the memory expansion method embodiment.
[0170]
[0175] An embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by a processor.
[0171]
[0176] The various embodiments of this disclosure are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the computer-readable storage medium embodiment is generally similar to the memory expansion method embodiment, so its description is relatively simple. For relevant portions, refer to the description of the memory expansion method embodiment.
[0172]
[0177] An embodiment of the present disclosure further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by a processor.
[0173]
[0178] 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 expansion 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 expansion method.
[0174]
[0179] The foregoing description describes specific embodiments of the present disclosure. 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 sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0175]
[0180] The computer instructions include 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 drive, 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 of the computer-readable medium may be appropriately increased or decreased based on the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.
[0176]
[0181] It should be noted that, for ease of description, the aforementioned method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present disclosure are not limited by the order of the actions described. Depending on the embodiments of the present disclosure, certain steps may be performed in a different order or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily required for the embodiments of the present disclosure.
[0177]
[0182] 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.
[0178]
[0183] The preferred embodiments disclosed above are intended only to illustrate the present disclosure. The alternative embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations are possible based on the content of the embodiments disclosed. These embodiments are selected and described in detail to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize the present disclosure. The present disclosure is limited only by the claims and their full scope and equivalents.
Claims
Claims 1. A memory expansion method, comprising: The method includes receiving a memory extension instruction, wherein the memory extension instruction is associated with a target operating system, and the target operating system is obtained by converting an operating system running in a physical mode to a virtual mode; determining a memory extension parameter according to the memory extension instruction, and calling a memory management interface of the target operating system to add extended memory corresponding to the memory extension parameter to the target operating system; and allocating the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset in a memory management function, wherein the memory contained in the target memory pool is used by the target operating system.
2. The memory expansion method according to claim 1, before receiving the memory expansion instruction, further comprising: receiving a configuration change instruction submitted by an operating system running in the physical mode; The operating system is converted into a target operating system running in a virtual mode according to the configuration change instruction.
3. The memory expansion method according to claim 2, wherein converting the operating system into a target operating system running in a virtual mode according to the configuration change instruction comprises: Establishing an address mapping page table for the operating system according to the configuration change instruction, and saving initial data of registers corresponding to the operating system running in the physical mode; A target data structure is established based on the address mapping page table and the initial data; target data in the target data structure is configured, and the configured target data structure is loaded into the CPU, triggering the operating system to switch to a target operating system running in a virtual mode, wherein the target data is control information corresponding to the target operating system.
4. The memory expansion method according to claim 3, wherein the target operating system is configured with a memory management function; after converting the operating system to a target operating system running in a virtual mode according to the configuration change instruction, the method further comprises: By means of the memory management function, the physical memory corresponding to the target operating system is divided into memory blocks of a preset granularity; Set the memory state of the memory block to be in use.
5. The memory expansion method according to claim 4, further comprising: after setting the memory state of the memory block to a used state; Determine, through the memory management function, a currently idle page corresponding to the target operating system, wherein the idle page is a physical memory page that is not currently occupied by any process and can be allocated to a process by the target operating system, and the physical memory pages constitute the physical memory; delete a page table entry in the address mapping page table corresponding to the idle page, and update the memory state corresponding to the idle page to an idle state, wherein the address mapping page table is composed of the page table entries, and the page table entries record the mapping of virtual addresses to physical addresses.
6. The memory expansion method according to claim 1, wherein determining memory expansion parameters according to the memory expansion instruction and calling a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters to the target operating system comprises: Determining memory extension parameters according to the memory extension instruction, wherein the memory extension parameters include a virtual memory address range corresponding to the extended memory; and calling a memory management interface of the target operating system to add the extended memory to the virtual memory address range corresponding to the target operating system.
7. The memory expansion method according to claim 1, wherein the extended memory is allocated to the target operation The target memory pool corresponding to the system includes: According to the target memory pool mechanism, the extended memory is allocated to the target memory pool corresponding to the target operating system.
8. The memory expansion method according to claim 7, wherein allocating the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism comprises: The target memory pool is set to be used by the target process, and the extended memory is allocated to the target memory pool corresponding to the target operating system, so that the target process uses the extended memory in the target memory pool; or the target memory pool is set to be used by the code segment and / or data segment in the target process, and the extended memory is allocated to the target memory pool corresponding to the target operating system, so that the code segment and / or data segment in the target process uses the extended memory in the target memory pool.
9. The memory expansion method according to claim 7, wherein allocating the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism comprises: adjusting the capacity configuration of the target memory pool according to the memory expansion parameter of the extended memory so that the capacity of the target memory pool matches the size of the extended memory; Allocate the extended memory to the adjusted target memory pool corresponding to the target operating system.
10. The memory expansion method according to claim 1, after allocating the extended memory to the target memory pool corresponding to the target operating system, further comprising: When a target process running in the target operating system uses the extended memory in the target memory pool and triggers a page fault exception, calling an exception handling function corresponding to the page fault exception according to the page fault exception; Based on the exception handling function, a target memory block is determined through the memory management function, and a page table entry corresponding to the extended memory and the target memory block is established, wherein the target memory block is a memory block in an idle state; and the extended memory is mapped to the target memory block through the page table entry corresponding to the extended memory and the target memory block.
11. The memory expansion method according to claim 1, further comprising: Setting memory free space in the physical memory corresponding to the target operating system by using the memory management function; When the memory free space is lower than a first threshold and higher than a second threshold, triggering a memory reclaiming operation to release the physical memory in the idle state; When the memory free space is lower than the second threshold, a processing notification is sent to the operation and maintenance program, so that the operation and maintenance program performs process migration and data protection operations according to the processing notification.
12. A memory expansion method, comprising: Receive configuration change instructions submitted by the operating system running in physical mode; converting the operating system to a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function; upon receiving a memory expansion instruction submitted by the memory management function, determining memory expansion parameters according to the memory expansion instruction, and calling a memory management interface of the target operating system to add extended memory corresponding to the memory expansion parameters to the target operating system; Based on a memory management function preset by the memory management function, the extended memory is allocated to a target memory pool corresponding to the target operating system, wherein the target memory contained in the target memory pool is used by the target operating system.
13. A memory expansion device, comprising: The receiving module is configured to receive a memory expansion instruction, wherein the memory expansion instruction is associated with a target operating system. system, and the target operating system is obtained by converting an operating system running in a physical mode to running in a virtual mode; a determining module is configured to determine a memory extension parameter according to the memory extension instruction, and call a memory management interface of the target operating system to add extended memory corresponding to the memory extension parameter for the target operating system; an allocating module is configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by a memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.
14. A memory expansion device, comprising: a receiving module configured to receive a configuration change instruction submitted by an operating system running in a physical mode; A conversion module is configured to convert the operating system into a target operating system running in a virtual mode according to the configuration change instruction, wherein the target operating system is configured with a memory management function; a determination module is configured to, upon receiving a memory extension instruction submitted through the memory management function, determine memory extension parameters according to the memory extension instruction, and call a memory management interface of the target operating system to add extended memory corresponding to the memory extension parameters for the target operating system; an allocation module is configured to allocate the extended memory to a target memory pool corresponding to the target operating system based on a memory management function preset by the memory management function, wherein the target memory contained in the target memory pool is for use by the target operating system.
15. 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 programs / instructions are executed by the processor, the steps of the memory expansion method according to any one of claims 1 to 12 are implemented.
16. 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 memory expansion method according to any one of claims 1 to 12.
17. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the memory expansion method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Secure memory expansion method and device, secure memory release method and device and electronic equipment
CN111459673A
Method and device for expanding memory and related equipment
CN115794669A
Virtual machine migration method and device and storage medium
CN116401010A