Memory extension method and device, computing equipment, computer readable storage medium and computer program product

By converting the physical mode operating system to virtual mode and receiving memory expansion instructions, the problem that the host operating system cannot dynamically expand memory in a virtualized scenario is solved, smooth memory expansion is achieved, and the stability and process performance of the operating system are improved.

CN120560773APending Publication Date: 2025-08-29HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410225776.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-28
Publication Date
2025-08-29

AI Technical Summary

Technical Problem

In the prior art, the host operating system memory cannot be dynamically expanded in virtualized scenarios, and the operating system running in physical mode cannot add memory online, resulting in insufficient operating system stability and reliability.

Method used

Smooth memory expansion is achieved by converting the operating system running in physical mode into virtual mode, receiving memory expansion instructions, using memory management functions to add extended memory to the target operating system, and allocating it to the target memory pool.

Benefits of technology

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 user is sensitive to operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120560773A_ABST
    Figure CN120560773A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory extension method and device, computing equipment, a computer readable storage medium and a computer program product, and the memory extension method comprises the steps that a memory extension instruction is received, and the memory extension instruction is associated with a target operating system; the target operating system is obtained by converting an operating system running in a physical mode into running in a virtual mode; determining a memory extension parameter according to the memory extension instruction, calling a memory management interface of the target operating system, and adding an extension memory corresponding to the memory extension parameter for the target operating system; 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, and the memory contained in the target memory pool is used by the target operating system; smooth and flexible memory expansion is carried out under the condition that the operation of the target operating system is not stopped.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a memory expansion method, a memory expansion device, a computing device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In traditional operating systems, memory expansion can only be done online when physical memory is confirmed to exist. In virtualization scenarios, the memory hot-swap feature 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 feature is virtual memory, which is subject to the limitations and support level of the virtualization platform and cannot be used by the host operating system.

[0003] 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. Summary of the Invention

[0004] In view of this, embodiments of this specification provide a memory expansion method. One or more embodiments of this specification 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.

[0005] According to a first aspect of an embodiment of this specification, a memory expansion method is provided, comprising:

[0006] 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;

[0007] Determining memory extension parameters 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 parameters for the target operating system;

[0008] 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.

[0009] According to a second aspect of an embodiment of this specification, a memory expansion device is provided, including:

[0010] 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;

[0011] a determination module configured to 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;

[0012] The 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 a memory management function, wherein the target memory contained in the target memory pool is used by the target operating system.

[0013] According to a third aspect of an embodiment of this specification, another memory expansion method is provided, including:

[0014] Receive configuration change instructions submitted for the operating system running in physical mode;

[0015] 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;

[0016] Upon receiving a memory extension instruction submitted through the memory management function, determining memory extension parameters 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 parameters for the target operating system;

[0017] 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.

[0018] According to a fourth aspect of an embodiment of this specification, another memory expansion device is provided, comprising:

[0019] A receiving module configured to receive a configuration change instruction submitted by an operating system running in a physical mode;

[0020] 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;

[0021] a determination module 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;

[0022] 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 used by the target operating system.

[0023] According to a fifth aspect of the embodiments of this specification, there is provided a computing device, including:

[0024] memory and processor;

[0025] 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 above-mentioned memory expansion method are implemented.

[0026] According to a sixth aspect of the embodiments of this specification, 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.

[0027] According to a seventh aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by a processor.

[0028] One embodiment of the present specification provides a memory expansion method, which comprises 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 a virtual mode; 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; 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.

[0029] A memory expansion method provided in an embodiment of the present specification 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 operation of the target operating system, ensuring that services in the operating system are not interrupted, achieving user-friendly operation, reducing various unstable factors caused by restarting the operating system, enhancing the stability and reliability of the operating system, and allocating 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 This is a schematic diagram of a scenario of a memory expansion method provided by an embodiment of this specification;

[0031] Figure 2 This is a flowchart of a memory expansion method provided by one embodiment of this specification;

[0032] Figure 3 This is a flowchart of a processing process of a memory expansion method provided by one embodiment of this specification;

[0033] Figure 4 is a flowchart of another memory expansion method provided by an embodiment of this specification;

[0034] Figure 5 This is a schematic diagram of the structure of a memory expansion device provided by one embodiment of this specification;

[0035] Figure 6 This is a schematic diagram of the structure of another memory expansion device provided by one embodiment of this specification;

[0036] Figure 7 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION

[0037] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0038] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0039] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0040] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0041] First, the terms involved in one or more embodiments of this specification are explained.

[0042] GPA: Guest Physical Address, client physical address.

[0043] HPA: Host Physical Address, host physical address.

[0044] 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).

[0045] The page table is a concept of virtual memory technology. In order to allow programs to obtain more available memory and expand physical memory into larger logical memory, the operating system also uses virtual memory technology, which abstracts physical memory into an address space. The operating system allocates an independent set of virtual addresses to each process, and the virtual addresses of different processes are mapped to the physical addresses of different memories. If a program wants to access a virtual address, the operating system converts it into a different physical address. There are two concepts of addresses involved here:

[0046] The memory addresses used by the program are called virtual addresses;

[0047] The actual space address in the hardware is called the physical address.

[0048] Virtual addresses and physical addresses are mapped through a page table, which is stored in memory. When the virtual address that the process wants to access 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.

[0049] VMCS (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.

[0050] VMCS contains a large number of fields and information related to the virtual machine execution environment, such as:

[0051] Virtual machine processor state: includes the internal state of the CPU (central processing unit), such as general registers, instruction pointers, and flag registers.

[0052] Memory management information: such as the EPT page table base address, address translation control field, etc., used to support memory virtualization and address translation.

[0053] Execution control information: such as entry points into and out of the virtual machine, event injection, exception and interrupt handling mechanisms, etc.

[0054] Virtual machine operation mode settings: such as operation permissions and behavior rules in non-root (virtual) mode and root (physical) mode.

[0055] Virtual machine execution control field: such as whether to enable specific functions, virtualization extensions, etc.

[0056] In the embodiment of this specification, 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.

[0057] Memory hot-swap technology allows memory modules to be added or removed while the computer is running without shutting down. It's commonly used in servers and high-end computer systems to improve system availability and resource flexibility. The key to achieving this functionality is a motherboard design that includes pluggable memory slots and a dedicated hot-swap controller to monitor memory insertion and removal and communicate with the motherboard firmware.

[0058] In practice, simply insert a new memory module into an empty memory slot. The hot-swap controller detects the insertion and notifies the motherboard firmware. The firmware then automatically recognizes the newly inserted memory module and completes the necessary settings, such as initialization and physical address space allocation.

[0059] In a virtualized environment, the virtualization platform typically allows for hot-swapping of memory resources while a virtual machine is running, allowing for the addition or removal of memory without stopping the virtual machine. Virtualization platforms (such as VMware ESXi, KVM, and Hyper-V) provide functions and interfaces that allow a virtual machine to dynamically increase or decrease memory resources. The specific steps are as follows:

[0060] First, ensure that the virtual machine's configuration allows memory hot-plugging. This usually requires setting the virtual machine's memory hot-plugging parameters and ensuring that the virtual machine's operating system and applications support memory hot-plugging. Next, in the virtualization management tool or console, select the virtual machine whose memory you want to adjust and follow the instructions of the virtualization platform to increase or decrease memory. After receiving the memory changes, 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 utilized by the operating system and applications.

[0061] It should be noted that the memory hot-swap operation for a virtual machine in a virtual environment is actually an operation for virtual memory rather than the physical memory of the host machine. What is expanded is the virtual memory, and its functionality is affected by the limitations and support level of the virtualization platform and cannot be used for the host operating system.

[0062] Therefore, there is an urgent need for a memory expansion method that allows a running host operating system to have hot upgrade capabilities and to use hot-pluggable memory (newly added extended memory) for specific programs.

[0063] In this specification, a memory expansion method is provided. This specification 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.

[0064] See also Figure 1 , Figure 1 A schematic diagram of a scenario of a memory expansion method provided according to an embodiment of this specification is shown.

[0065] Specifically, the memory expansion method is implemented by an end-side device 102 and a server 104, where the end-side device 102 is used to send a memory expansion instruction to the server 104, i.e., to expand the memory in the server 104; the server 104 receives the 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 a virtual mode; memory expansion parameters are determined according to the memory expansion instruction, and a memory management interface of the target operating system is called to add extended memory corresponding to the memory expansion parameters to the target operating system; 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, and the extension result, such as a message of successful extension and available memory after extension, is returned to the end-side device 102.

[0066] The end-side device 102 may include a browser, an APP (Application), or a web application such as an H5 (Hyper Text Markup Language 5, version 5 of Hypertext Markup Language) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The end-side device may be based on the software development kit (SDK) of the corresponding service provided by the server, such as developed based on the real-time communication (RTC) SDK, etc. The end-side device can be deployed in an electronic device and needs to rely on the device to run or certain APPs in the device to run. The electronic device may have a display screen and support information browsing, etc., such as a personal mobile terminal such as a mobile phone, tablet computer, personal computer, etc. Various other types of applications can usually be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0067] 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 for 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 for a distributed system or a server integrated with blockchain. Server 104 can also be a cloud server for 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.

[0068] A memory expansion method provided in an embodiment of the present specification switches a running host operating system 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 operation of the target operating system, ensuring that services in the operating system are not interrupted, achieving user-friendly operation, reducing various unstable factors caused by restarting the operating system, enhancing the stability and reliability of the operating system, and allocating 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 running performance of the target process.

[0069] See also Figure 2 , Figure 2 A flowchart of a memory expansion method provided by an embodiment of this specification is shown, which specifically includes the following steps.

[0070] 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.

[0071] Among them, the memory expansion instruction can be understood as an instruction used to enable the target operating system to expand the memory; wherein, the memory expansion instruction can carry memory expansion parameters, and the memory expansion parameters can include the starting address of the memory to be expanded and the size of the memory to be expanded.

[0072] The operating system is configured with memory management functions, which can realize 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 conversion between virtual addresses and physical addresses through data structures such as page tables.

[0073] 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.

[0074] Specifically, a memory expansion instruction submitted through a memory management function and directed to a target operating system running in a non-root mode is received, so that the target operating system performs memory expansion.

[0075] In one or more embodiments of this specification, before receiving the memory expansion instruction, it is necessary to convert the operating system running in root mode to the target operating system running in non-root mode according to the received configuration change instruction. The specific implementation method is as follows:

[0076] Before receiving the memory expansion instruction, the method further includes:

[0077] receiving a configuration change instruction submitted by an operating system running in the physical mode;

[0078] The operating system is converted into a target operating system running in a virtual mode according to the configuration change instruction.

[0079] The configuration change instruction may be understood as a change instruction for causing the operating system to perform a mode switch.

[0080] Specifically, when memory expansion is required, since an operating system running in root mode can only add memory online when physical memory exists, 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.

[0081] 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, so that the operating mode of the operating system is switched according to the configuration change instruction.

[0082] The memory expansion method provided in the embodiments of this specification can dynamically convert an operating system running in physical mode to running in virtual mode according to actual needs by receiving configuration change instructions, thereby achieving flexible scheduling and efficient utilization of resources.

[0083] In one or more embodiments of this specification, 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 be performed first to complete the mode switch. The specific implementation method is as follows:

[0084] The step of converting the operating system into a target operating system running in a virtual mode according to the configuration change instruction includes:

[0085] 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;

[0086] Establishing a target data structure according to the address mapping page table and the initial data;

[0087] The target data in the target data structure is configured, and the configured target data structure is loaded into a central processing unit, 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.

[0088] Among them, the address mapping page table can be understood as the EPT page table. There are page table entries in the EPT page table for recording the mapping of virtual addresses to physical addresses. 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 in the EPT page table is equal to the HPA.

[0089] 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; the target data can be understood as the fields and information related to controlling the virtual execution environment.

[0090] Specifically, when a configuration change instruction is received, an EPT page table with a one-to-one mapping from GPA to HPA is established, and all status information of the currently running CPU is saved, including but not limited to all general registers, control registers, flag registers, and other data that affects the CPU execution state; a VMCS running in virtual mode is established based on the values ​​of these registers and the EPT page table.

[0091] VMCS contains a large number of fields and information related to the virtual execution environment. The control of the VCPU (central processing unit running in virtual mode) is achieved by configuring the fields in VMCS, such as setting the VM-entry / VM-exit (virtual machine entry / virtual machine exit) control bits in VMCS to specify which instructions should be intercepted, such as setting the exit processing function during the virtualization mode operation. When an EPT Violation (EPT violation, when the CPU tries to access an address, if the EPT mapping of the address is not set correctly or the permissions do not match, an EPT Violation exception will occur) exception causes VM Exit, the exit processing function is used as the EPT page fault processing function corresponding to the EPT Violation to handle the VM Exit caused by the EPT Violation exception.

[0092] 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 (a 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.

[0093] The memory expansion method provided in the embodiments of this specification establishes a target data structure by establishing an address mapping page table and saving the initial data of the register, and can accurately and effectively complete the conversion of the operating system mode by configuring the target data of the target data structure.

[0094] In one or more embodiments of this specification, in order to more effectively manage and organize memory space, the memory is divided into blocks of fixed granularity, and the memory status of the memory blocks is set to be in use. The specific implementation method is as follows:

[0095] After converting the operating system into a target operating system running in a virtual mode according to the configuration change instruction, the method further includes:

[0096] 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;

[0097] Set the memory state of the memory block to be in use.

[0098] The preset granularity can be set according to actual needs and is not limited here. For example, the preset granularity is 2MB (megabytes).

[0099] 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.

[0100] The memory expansion method provided in the embodiments of this specification divides the physical memory into blocks of fixed granularity, which is conducive to managing and organizing the memory space and reducing the generation of memory fragmentation; it can efficiently manage each memory block and thus more efficiently allocate physical memory resources.

[0101] In one or more embodiments of this specification, by searching for currently idle pages, deleting the page table entries in the address mapping page table corresponding to the idle pages, and updating the memory status, it is convenient to allocate the idle pages later. The specific implementation method is as follows:

[0102] After setting the memory state of the memory block to a used state, the method further includes:

[0103] Determining, by means of 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 is available for allocation by the target operating system to a process, the physical memory pages constituting the physical memory;

[0104] The page table entry in the address mapping page table corresponding to the idle page is deleted, and the memory state corresponding to the idle page is updated 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.

[0105] 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.

[0106] Specifically, the currently idle free pages in the host machine are traversed through the memory management function. When a physical page becomes idle, it means that the page is 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 the idle state. 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.

[0107] The memory expansion method provided in the embodiments of this specification ensures the effective management and rational use of physical memory, and provides the necessary basis for memory scheduling in a multi-tasking environment. By adding free pages to the global free list, it is convenient to quickly find allocatable physical memory pages during subsequent memory allocation operations.

[0108] 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.

[0109] The memory extension parameters include the address space of the extended memory and the size of the extended memory; the memory management interface can be understood as an extension interface, and the extended memory is added by calling the extension interface.

[0110] In actual applications, when expanding the memory of a virtual machine, it is necessary to notify the operating system of the expanded memory through a complex hardware interrupt mechanism notification 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 directly by calling the extension interface of the target operating system.

[0111] In one or more embodiments of this specification, in order to accurately add extended memory, the extended memory is added within the virtual memory address range corresponding to the target operating system to ensure that the target operating system can provide a larger available memory space for the application. The specific implementation method is as follows:

[0112] The determining of the memory extension parameter 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 parameter for the target operating system includes:

[0113] Determining memory expansion parameters according to the memory expansion instruction, wherein the memory expansion parameters include a virtual memory address range corresponding to the expanded memory;

[0114] The memory management interface of the target operating system is called to add the extended memory in the virtual memory address range corresponding to the target operating system.

[0115] 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.

[0116] When extended memory needs to be added, the GPA address space of the extended memory to be added and the size of the extended memory (i.e., memory extension parameters) need to be determined. First, the maximum physical page frame number (PFN) currently used by the target operating system needs to be determined. After obtaining the maximum PFN, an address range higher than the existing maximum PFN is selected as the new memory mapping area. For example, if the current 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 from after 40GB and allocated according to the memory size of the extended memory.

[0117] The memory expansion method provided in the embodiments of this specification meets the needs of application products in the host machine by expanding the memory. It can also avoid the problem of being unable to allocate the required memory to the process due to insufficient available memory, thereby triggering abnormal termination of the system or forced killing of some processes, or being unable to upgrade to the latest product.

[0118] Step 206: 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 memory contained in the target memory pool is used by the target operating system.

[0119] Among them, the memory management function can be understood as a processing function for extended memory, which is 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 hugetlb (Huge Translation Lookaside Buffer, a memory management mechanism used to support large page memory) or a dedicated pool.

[0120] The target memory pool can be understood as the above-mentioned specific memory pool, which can be used to meet the memory requirements of specific programs (such as programs for high-performance computing resources).

[0121] In actual applications, in order to allow the extended memory to enter a specific memory pool, a processing function of the extended memory is preset through the memory management function, so that the processing of the extended memory can be realized when the extended memory is added.

[0122] In one or more embodiments of this specification, the extended memory can be dynamically allocated by setting a target memory pool mechanism to achieve the processing allocation of the extended memory. The specific implementation method is as follows:

[0123] Allocating the extended memory to a target memory pool corresponding to the target operating system includes:

[0124] According to the target memory pool mechanism, the extended memory is allocated to the target memory pool corresponding to the target operating system.

[0125] Allocating the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism includes:

[0126] 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

[0127] The target memory pool is set to be used by the code segments and / or data segments 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 segments and / or data segments in the target process use the extended memory in the target memory pool.

[0128] The target process may be understood as a process that is set to be allowed to use the target memory pool.

[0129] Specifically, for a specific memory pool, the processes allowed to use the specific memory pool can be dynamically set, so that the target process uses the memory in the target memory pool; the code segment or data segment of the corresponding process can also be set to use the memory in the specific memory pool, so that the target process uses the memory in the target memory pool.

[0130] Of course, in actual applications, the extended memory may also be allocated to the general memory corresponding to the target operating system, which is not limited here.

[0131] The memory expansion method provided in the embodiments of this specification provides dedicated memory space for the target process by setting the target memory pool to a specific target process or the code segment and / or data segment in the target process, thereby reducing memory contention between different processes and helping to improve the data reading and writing speed and execution efficiency of the target process.

[0132] In one or more embodiments of this specification, 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 method is as follows:

[0133] Allocating the extended memory to a target memory pool corresponding to the target operating system according to a target memory pool mechanism includes:

[0134] 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;

[0135] Allocate the extended memory to the adjusted target memory pool corresponding to the target operating system.

[0136] 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.

[0137] In actual applications, the size of a 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, part of the memory in the specific memory pool is released to the general memory; otherwise, memory is obtained from the general huget lb and the extended memory is allocated to the target memory pool with the adjusted capacity. It should be noted that if there is a memory allocation request for a specific memory pool, and the request cannot be satisfied if the specific memory pool does not have enough memory, the target operating system will not immediately report a memory allocation failure. Instead, it will choose 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] The memory expansion method provided in the embodiments of this specification 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 performance of the system.

[0139] In one or more embodiments of this specification, 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 handle the problem. The specific implementation method is as follows:

[0140] After allocating the extended memory to the target memory pool corresponding to the target operating system, the method further includes:

[0141] 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;

[0142] 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 in an idle state;

[0143] The extended memory is mapped to the target memory block through page table entries corresponding to the extended memory and the target memory block.

[0144] 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. This will be used to establish the EPT page table entry corresponding to the extended memory and the target memory block, and record the mapping relationship between the virtual address and the newly allocated physical address (target memory block address). The operating system will restart the process that was suspended due to the page fault exception, allowing it to continue execution and successfully access the previously inaccessible extended memory area.

[0145] The memory expansion method provided in the embodiments of this specification 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.

[0146] In one or more embodiments of this specification, 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, by setting the memory free space, the size of the memory free space can be used to determine whether a reasonable amount of free memory is currently available, so as to perform corresponding processing operations. The specific implementation method is as follows:

[0147] The memory expansion method further includes:

[0148] Setting memory free space in the physical memory corresponding to the target operating system by using the memory management function;

[0149] When the memory free space is lower than a first threshold and higher than a second threshold, triggering a memory recycling operation to release the physical memory in the idle state;

[0150] 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.

[0151] Among them, the first threshold and the second threshold can be set according to actual conditions, and the first threshold and the second threshold can also be expressed as a ratio in actual applications; 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.

[0152] In practical applications, the free memory space can be visually represented by the memory water level. When the memory water level is higher than the first threshold, the memory water level is considered to be at a high water level, that is, there is a lot of free memory. At this time, the status quo can be maintained without any processing; when the memory water level is lower than the first threshold and higher than the second threshold, the memory water level is considered to be between the high water level and the low water level, then the memory recycling operation is triggered, that is, recycling the free memory, or compressing the memory, etc., to make room for the bottom-level free memory. Specifically, when recycling memory, cold pages (cold pages indicate free pages that are no longer in the cache) or free memory are recycled first.

[0153] When the memory water level is lower than the second threshold, it is considered that the memory water level is lower than the emergency water level, and the EPT page fault will return a failure in order to reserve a backup memory 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.

[0154] The memory expansion method provided in one embodiment of this specification monitors and adjusts the usage of physical memory in real time by setting memory free space, ensuring that the system can dynamically allocate and reclaim memory resources according to actual needs, thereby improving memory utilization; and by sending processing notifications, it can greatly enhance the stability and availability of the system and reduce operation and maintenance costs.

[0155] A memory expansion method provided in an embodiment of the present specification 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 operation of the target operating system, 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, when the extended memory can be allocated to the target memory pool on demand, the extended memory in the target memory pool is made available to the target process by setting the usage permissions of the memory in the target memory pool, thereby significantly improving the running performance of the target process.

[0156] See also Figure 3 , Figure 3 A flowchart of a memory expansion method according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0157] Step 302: Create an address mapping table.

[0158] Specifically, when a configuration change instruction is received, an EPT page table is established that maps one GPA to one HPA. 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.

[0159] Step 304: Save the register value and create a target data structure.

[0160] When the operating mode of the current operating system needs to be switched, all state information of the currently running CPU needs to be saved first, including but not limited to all general registers, control registers, flag registers and other data that affect the CPU execution state.

[0161] A VMCS running in virtual mode is established based on the data in these registers and the EPT. During the VMCS establishment process, the correctness of the target operating system's memory access after switching needs to be ensured based on the EPT configuration. After the VMCS is established, the target operating system's execution environment is restored by loading the register values ​​of the VCPU (virtual central processing unit) corresponding to the target operating system based on the information in the VMCS. In this way, when the target operating system is rescheduled back, execution can continue from the previously saved state, ensuring the continuity and independence of the target operating system's execution.

[0162] Step 306: Configure the target data structure and set the exit function.

[0163] The exit function may 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.

[0164] VMCS contains a large number of fields and information related to the virtual execution environment. The VCPU is controlled by configuring the fields in VMCS, such as setting the VM-entry / VM-exit control bits in VMCS to specify which instructions should be intercepted. For example, during the process of setting and initializing VMCS, the relevant VMExit information needs to be correctly configured. For EPT Violation (EPT violation, when the CPU tries to access an address, if the EPT mapping of the address is not set correctly or the permissions do not match, an EPT Violation exception will occur), it is necessary to enable the corresponding VM Exit control bit and configure the corresponding exit fields to capture different types of EPT violations, such as read, write or execute permissions.

[0165] 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.

[0166] Step 308: Switch the operating mode.

[0167] 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 means that the running CPU is switched to a VCPU running in virtual mode, causing the running physical machine to enter virtual mode.

[0168] Step 310: Divide the memory blocks and set the memory status of the memory blocks.

[0169] A memory block management function is established for all real physical memories 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.

[0170] Step 312: Determine the free pages and update the memory status of the memory block.

[0171] 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.

[0172] Step 314: Set the memory management function and determine the memory expansion parameters of the expanded memory.

[0173] The memory management function can be understood as an extended memory processing function used to place the 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.

[0174] In actual applications, you can manage the newly added extended memory by setting the extended memory processing function, so that the newly added extended memory enters the dedicated memory pool. The dedicated memory pool will be configured with the required memory capacity, and the extended memory will be given priority in entering the dedicated pool. If there is still some extended memory left, it will be placed in the general hugetlb, ensuring that the added extended memory enters the dedicated memory pool first.

[0175] When extended memory needs to be added, the GPA address space of the extended memory to be added and the size of the extended memory (i.e., memory expansion parameters) need to be determined. First, the maximum physical page frame number (PFN) currently used by the target operating system needs to be determined. After obtaining the maximum PFN, an address range higher than the existing maximum PFN is selected as the new memory mapping area. For example, if the current 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 from after 40GB.

[0176] Step 316: Add virtual memory to the specific memory pool.

[0177] In actual applications, when expanding the memory of a virtual machine, it is necessary to notify the operating system of the expanded memory through a complex hardware interrupt mechanism notification mechanism. In the case where 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, thereby avoiding the problem of large-scale OOM in the online host machine due to insufficient memory (due to insufficient available memory, the required memory cannot be allocated to the process, thereby triggering the abnormal termination of the system or forcibly killing some processes).

[0178] 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.

[0179] Step 318: Configure a specific memory pool.

[0180] Specifically, a 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 memory in the specific memory pool.

[0181] When the newly added extended memory is smaller than 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; and the size of the 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, part of the 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 a specific memory pool, and the request cannot be met when the memory in the specific memory pool is insufficient, the target operating system will not immediately report a memory allocation failure, but will choose to fall back to the regular memory allocation path and find a suitable memory area from the overall available memory to complete the allocation.

[0182] Step 320: Use extended memory to trigger a page fault exception.

[0183] 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.

[0184] Step 322: Determine unused memory blocks according to the page fault handling function.

[0185] According to the EPT violation exception, the EPT page fault processing 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.

[0186] Step 324: Set the memory water level.

[0187] Specifically, through the memory block management function, a memory water level can be set for the physical memory to ensure that there is a reasonable amount of free memory in the memory block management function, wherein the memory water level represents the free space of the current free memory; if the memory water level is at a high water level, it means that the current amount of free memory is large and the status quo is temporarily maintained; if the memory water level is lower than the high water level but higher than the low water level, the free memory will be reclaimed, or the memory will be compressed, etc., to obtain more free memory; if the memory water level is lower than the low water level but higher than the emergency water level, memory recovery will be accelerated; specifically, when reclaiming memory, cold pages (cold pages represent free pages that are no longer in the cache) or free memory will be recycled first to ensure that the memory water level is at a reasonable position; if the memory water level is lower than the emergency water level, then when the EPT page fault exception is triggered, no memory block will be allocated for the extended memory, and a failure will be returned in order to reserve the preset memory to ensure that the system can run for a period of time. At the same time, it is necessary to notify the upper-level operation and maintenance program and inform the upper-level operation and maintenance program of the severe memory shortage status so that the upper-level operation and maintenance program can perform emergency migration and other processing before the system crashes.

[0188] Of course, in actual applications, when system resources are in a relatively idle state, the extended memory can be recycled. In this way, the system can make more concentrated use of the original physical memory resources; and when cold pages are identified through predetermined strategies, the higher the recognition accuracy, the lower the probability of page fault exceptions, thereby reducing the system's operating overhead and performance loss. That is, when system resources are sufficient and utilization is not high, reasonably adjusting the memory allocation strategy and restricting more operations to the real physical memory range will help improve the overall system performance and response speed.

[0189] A memory expansion method provided in an embodiment of the present specification switches the operating mode of the operating system. For the switched target operating system, the method adds corresponding extended memory to the target operating system by calling an interface according to memory extension instructions without stopping the operation of the target operating system. Compared with the method in which the virtual machine notifies the operating system of the expanded memory through a complex hardware interrupt mechanism, this method not only greatly improves the expansion efficiency but also realizes user-friendly operation, reduces various unstable factors caused by restarting the operating system, and enhances the stability and reliability of the operating system.

[0190] See also Figure 4 , Figure 4 A flowchart of another memory expansion method provided by an embodiment of this specification is shown, which specifically includes the following steps.

[0191] Step 402: Receive a configuration change instruction submitted for an operating system running in physical mode;

[0192] Step 404: 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;

[0193] 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;

[0194] 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.

[0195] For details, please refer to the above embodiments and will not be described again here.

[0196] A memory expansion method provided in an embodiment of the present specification can realize the conversion of the 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; and the 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 waste of memory resources, and also improving the overall performance and stability of the system.

[0197] Corresponding to the above method embodiment, this specification also provides a memory expansion device embodiment, Figure 5 FIG. 1 shows a schematic diagram of the structure of a memory expansion device provided by an embodiment of this specification. Figure 5 As shown, the device includes:

[0198] The receiving module 502 is 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;

[0199] a determination module 504 configured to determine memory extension parameters according to the memory extension instruction, and to 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;

[0200] The allocation module 506 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 used by the target operating system.

[0201] The device further comprises:

[0202] The conversion module is configured to receive a configuration change instruction submitted for an operating system running in physical mode; and 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.

[0203] Optionally, the conversion module is further configured to:

[0204] Establishing an address mapping page table for the operating system according to the configuration change instruction, and saving 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;

[0205] Establishing a target data structure according to the address mapping page table and the initial data;

[0206] The target data in the target data structure is configured, and the configured target data structure is loaded into the target processor, triggering the operating system to be converted into a target operating system running in a virtual mode.

[0207] The device further comprises:

[0208] The management module is configured to divide the physical memory of the target operating system into memory blocks of 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.

[0209] Optionally, the management module is further configured to:

[0210] Determining, by means of the memory management function, current free pages of the target operating system, wherein the free pages are physical memory pages that are not currently occupied by any process and are available for allocation by the target operating system, and the physical memory pages are obtained by dividing the physical memory into blocks of fixed size;

[0211] The page table entry in the address mapping page table corresponding to the idle page is deleted, and the memory state of the memory block corresponding to the idle page is updated to an idle state.

[0212] Optionally, the determining module 504 is further configured to:

[0213] Determining memory expansion parameters according to the memory expansion instruction, wherein the memory expansion parameters include a virtual memory address range corresponding to the expanded memory;

[0214] The memory management interface of the target operating system is called to add the extended memory in the virtual memory address range corresponding to the target operating system.

[0215] Optionally, the allocation module 506 is further configured to:

[0216] According to the target memory pool mechanism, the extended memory is allocated to the target memory pool corresponding to the target operating system.

[0217] Optionally, the allocation module 506 is further configured to:

[0218] The target memory pool is set to be used by the target process, or 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 target process, or the code segment and / or data segment in the target process uses the extended memory in the target memory pool.

[0219] Optionally, the allocation module 506 is further configured to:

[0220] 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;

[0221] Allocate the extended memory to a target memory pool corresponding to the target operating system.

[0222] The device further comprises:

[0223] 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 according to the page fault exception;

[0224] 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 to map the virtual memory to the target memory block.

[0225] The device further comprises:

[0226] A setting module 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 a water level of free physical memory;

[0227] When the memory water level is lower than the first threshold and higher than the second threshold, triggering a memory recycling operation to release the physical memory in the idle state;

[0228] When the memory water level is lower than the second threshold, a processing notification is sent to the operation and maintenance program, and process migration and data protection operations are performed according to the processing notification.

[0229] A memory expansion device provided in an embodiment of the present specification 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 operation of the target operating system, ensuring that services in the operating system are not interrupted, achieving user-friendly operation, reducing various unstable factors caused by restarting the operating system, enhancing the stability and reliability of the operating system, and allocating 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 running performance of the target process.

[0230] 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 memory expansion method described above are based on 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 memory expansion method described above.

[0231] Corresponding to the above method embodiment, this specification also provides another memory expansion device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of another memory expansion device provided by an embodiment of this specification. Figure 6 As shown, the device includes:

[0232] The receiving module 602 is configured to receive a configuration change instruction submitted for an operating system running in a physical mode;

[0233] a conversion module 604 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;

[0234] a determination module 606 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;

[0235] The allocation module 608 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 used by the target operating system.

[0236] A memory expansion device provided in an embodiment of the present specification can realize the conversion of the 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; and the 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 waste of memory resources, and also improving the overall performance and stability of the system.

[0237] 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 memory expansion method described above are based on 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 memory expansion method described above.

[0238] Figure 7 7 shows a block diagram of a computing device 700 according to one 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, and a database 750 is used to store data.

[0239] 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.

[0240] In one embodiment of the present specification, the above components of the computing device 700 and Figure 7 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 7 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.

[0241] Computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 700 may also be a mobile or stationary server.

[0242] 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.

[0243] The various embodiments in this specification 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.

[0244] An embodiment of the present specification 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.

[0245] The various embodiments in this specification 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.

[0246] An embodiment of the present specification further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned memory expansion method when executed by a processor.

[0247] The above is a schematic diagram of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product and the technical solution of the aforementioned memory expansion method are based on 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.

[0248] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0249] The computer instructions include computer program codes, which may be in source code form, object code form, executable files, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0250] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0251] 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.

[0252] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A memory 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 memory extension parameters 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 parameters for the target operating system; 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.

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; Establishing a target data structure according to the address mapping page table and the initial data; The target data in the target data structure is configured, and the configured target data structure is loaded into a central processing unit, 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 into a target operating system running in a virtual mode according to the configuration change instruction, the method further includes: 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; Determining, by means of 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 is available for allocation by the target operating system to a process, the physical memory pages constituting the physical memory; The page table entry in the address mapping page table corresponding to the idle page is deleted, and the memory state corresponding to the idle page is updated 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 expansion parameters according to the memory expansion instruction, wherein the memory expansion parameters include a virtual memory address range corresponding to the expanded memory; The memory management interface of the target operating system is called to add the extended memory in the virtual memory address range corresponding to the target operating system.

7. The memory expansion method according to claim 1, wherein allocating the extended memory to a target memory pool corresponding to the target operating system comprises: 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 the target memory pool corresponding to the target operating system according to the 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 segments and / or data segments 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 segments and / or data segments in the target process use 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, 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 in an idle state; The extended memory is mapped to the target memory block through page table entries 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 recycling 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 for the operating system running in 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 extension instruction submitted through the memory management function, determining memory extension parameters 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 parameters for 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: 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 determination module configured to 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; The 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 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 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 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 used 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 program / 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 implements the steps of the memory expansion method according to any one of claims 1 to 12 when executed by a processor.

Citation Information

Cited By

  • Equipment resource allocation method and server

    CN121579223A