A memory allocation method, host machine, distributed system and program product
By dividing virtual memory into multiple regions and allocating physical memory according to data attributes, the host's inefficiency problem when allocating physical memory is solved, and the operation efficiency and security of the client are improved.
Patent Information
- Application Number
- CN202210471159.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-04-28
AI Technical Summary
When the host allocates physical memory for virtual memory, it fails to consider the different attributes of the data, resulting in low physical memory allocation and management efficiency, affecting the operating performance of the client.
Dividing virtual memory into multiple regions, each region stores data with different attributes, and allocating physical memory matching continuity, recyclability and execution permissions based on the attributes of the target data and the preset physical memory allocation strategy.
Optimize the allocation and management strategies of physical memory, improve the operation efficiency and security of the client, and reduce the memory access delay and the execution risks of malicious code.
Smart Images

Figure CN114860439B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of virtual machine technology, and in particular to a memory allocation method, a host machine, a distributed system, and a program product. Background Art
[0002] Cloud computing has become the core technology framework of the modern information technology industry, and in the future, an increasing number of information technology applications will be deployed in the cloud. The core technology of cloud computing is virtualization. Virtualization is a resource management technology that abstracts, transforms, and partitions and combines physical resources such as a computer's central processing unit (CPU), memory, disk space, and network adapters into one or more computer configuration environments. Using virtualization technology, a virtual machine (VM) with complete hardware system functionality can be simulated within a computer through software. A VM is also called a guest machine, and a computer running one or more VMs is called a host machine. While a guest machine is running, the host machine must constantly schedule and plan physical resources. The host machine's allocation and management of physical memory has a significant impact on the guest machine's performance. Optimizing the host machine's physical memory allocation and management strategy is a pressing technical issue in this field. Summary of the Invention
[0003] The embodiments of this specification provide a memory allocation method, a host machine, a distributed system, and a program product, which enable the host machine to optimize the allocation and management strategy of physical memory.
[0004] According to a first aspect of an embodiment of this specification, a memory allocation method is provided, which is applied to a host machine, wherein the host machine runs a client, and the virtual memory allocated to the client is divided into multiple areas, each area storing data of different attributes. The method includes:
[0005] Monitoring the client's call to the target data in the virtual memory;
[0006] Based on the attributes of the target data and a preset physical memory allocation strategy, physical memory is allocated to the area to which the target data belongs; wherein the physical memory allocation strategy matches the attributes of the data, and the physical memory allocation strategy is used to set the continuity, recyclability and / or execution permissions of the physical memory.
[0007] In some examples, allocating physical memory to the region to which the target data belongs based on the attributes of the target data and a preset physical memory allocation strategy includes:
[0008] When the plurality of areas include a first area storing target data of a kernel program, allocating continuous physical memory to the first area; and / or
[0009] When the multiple areas include a second area storing target data with a high access frequency, locking the physical memory allocated to the second area so that the physical memory corresponding to the second area cannot be reclaimed; wherein the access frequency of the target data with a high access frequency is greater than a preset access frequency threshold; and / or
[0010] When the plurality of areas include a third area storing read-write-only target data, the execution permission of the physical memory allocated to the third area is set to non-executable.
[0011] In some examples, the physical memory of the host machine includes a first physical memory and a second physical memory, and a read speed of the first physical memory is faster than a read speed of the second physical memory; and allocating physical memory to the area to which the target data belongs based on the attributes of the target data and a preset physical memory allocation policy includes:
[0012] When the plurality of areas include a fourth area for storing target data having a higher read frequency than a write frequency, a physical memory is allocated to the fourth area from the first physical memory.
[0013] In some examples, the virtual memory is divided into the first area, the second area, the fourth area, and the third area in order from low to high.
[0014] In some examples, the host machine adopts a NUMA architecture, the NUMA architecture includes at least two NUMA nodes, each of the NUMA nodes includes physical memory; the client runs on at least two of the NUMA nodes; at least two target areas among the multiple areas are used to store data with the same attributes, and different target areas are allocated to the physical memory of different NUMA nodes on which the client runs.
[0015] In some examples, the multiple zones are divided by the host machine and / or the client machine.
[0016] In some examples, the first region is divided by the host machine;
[0017] After the second area and / or the third area are divided by the client, the client sends area information to the host machine, where the area information includes location information and size information of each divided area.
[0018] According to a second aspect of an embodiment of this specification, there is provided an electronic device running a client, wherein the host computer includes:
[0019] processor;
[0020] a memory for storing processor-executable instructions;
[0021] Wherein, when the processor calls the executable instruction, it implements the operation of any method described in the first aspect.
[0022] According to a third aspect of the embodiments of this specification, a distributed system is provided, comprising at least one electronic device according to the second aspect.
[0023] According to a fourth aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0024] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a plurality of computer instructions are stored. When the computer instructions are executed, any method described in the first aspect is performed.
[0025] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0026] The embodiments of this specification provide a memory allocation method, a host machine, a distributed system and a program product, which divide the virtual memory allocated to the client into multiple areas, each area storing data of different attributes. When the host machine detects that the client calls the target data in the virtual memory, it allocates physical memory to the area of the target data based on the attributes of the target data and a preset physical memory allocation strategy. The physical memory allocation strategy matches the attributes of the data and is used to set one or more of the continuity, recyclability and execution permissions of the physical memory. Since the virtual memory is divided into multiple areas for storing data of different attributes, when allocating physical memory, the host machine can allocate appropriate physical memory to the area to which the target data belongs based on the attributes of the target data, from the perspective of physical memory continuity, recyclability and execution permissions, thereby optimizing the allocation and management strategy of the physical memory.
[0027] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory and are not restrictive of the embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings herein are incorporated in and constitute a part of the embodiments of this specification, illustrate embodiments consistent with the embodiments of this specification, and together with the description, serve to explain the principles of the embodiments of this specification.
[0029] Figure 1Schematic diagram of a host machine according to an embodiment of the present specification.
[0030] Figure 2 This is a flowchart of a memory allocation method according to an embodiment of the present specification.
[0031] Figure 3 FIG. 4 is a schematic diagram of a virtual memory according to an embodiment of the present disclosure.
[0032] Figure 4 FIG. 2 is a schematic diagram of a NUMA architecture according to an embodiment of the present specification.
[0033] Figure 5 This is a hardware structure diagram of an electronic device according to an embodiment of the present specification.
[0034] Figure 6 This is a schematic diagram of a distributed system according to an embodiment of the present specification. DETAILED DESCRIPTION
[0035] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible implementations consistent with the embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of the embodiments of this specification, as detailed in the appended claims.
[0036] The terms used in the embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit the embodiments of this specification. The singular forms "a," "the," and "the" used in the 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 herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0037] It should be understood that although the terms first, second, third, etc. may be used to describe various information in the 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 the embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein can be interpreted as "when..." or "when..." or "in response to determining."
[0038] Cloud computing has become the core technology framework of the modern information technology industry, and in the future, an increasing number of information technology applications will be deployed in the cloud. The core technology of cloud computing is virtualization. Virtualization is a resource management technology that abstracts, transforms, and partitions and combines various physical computer resources, such as the processor (CPU), memory, disk space, and network adapters, into one or more computer configurations. Using virtualization technology, software can simulate virtual machines (VMs) within a computer, with complete hardware system functionality. A VM is also called a guest machine, and a computer running one or more VMs is called a host machine.
[0039] The host machine can allocate memory to the client machine, and the allocated memory can be called virtual memory to store the data required by the client machine during operation and the data generated. The inventors found that the data stored in the virtual memory has different attributes, including but not limited to read and write frequency, importance, security and other attributes. However, when the host machine allocates physical memory to the virtual memory storing data with different attributes, it does not take into account that different data have different attributes, but allocates available physical memory to the virtual memory indiscriminately. The inventors found that during the operation of the client machine, the allocation and management of physical memory by the host machine has an important impact on the operating performance of the client machine. How to optimize the host machine's allocation and management strategy for physical memory is a technical problem that urgently needs to be solved in this field.
[0040] To this end, the embodiment of this specification provides a memory allocation method, which is applied to a host machine, such as Figure 1As shown, a client 110 is running on the host machine 100. Virtualization software can be used to establish and run one or more clients 110 (only one client is shown in the figure for example) on the host machine 100. For example, virtualization software may include QEMU (Quick Emulator) and Virtual PC. QEMU can work with a kernel-based virtual machine (KVM) to complete virtualization. The host machine 100 also includes a physical CPU 120 and physical memory 130. During the initialization phase of the client 110, the host machine 100 can allocate physical resources to the client 110, such as mapping the virtual CPU 111 of the client 110 to the physical CPU 120 for execution, allocating virtual memory 112 to the client 110, and so on. When allocating virtual memory 112 to the client 110, the host machine 100 may allocate some address bits in the physical memory 130 to the client 110 as virtual memory 112. Alternatively, memory over-provisioning technology can be used to achieve on-demand allocation of physical memory resources. The so-called memory over-allocation technology means that the total virtual memory of all clients running on the host machine is greater than the physical memory of the host machine. Using the memory over-allocation technology, the host machine can allocate and reclaim physical memory for the client machine according to the client machine's demand for memory, so as to realize on-demand allocation of physical memory. In the embodiment of this specification, the virtual memory allocated to the client machine can be divided into multiple areas, wherein each area can store data of different attributes respectively. Data of different attributes have different characteristics in terms of read and write frequency, importance and security. The method includes the following steps: Figure 2 Steps shown:
[0041] Step 210: monitoring the client's call to the target data in the virtual memory;
[0042] Step 220: Allocate physical memory to the area to which the target data belongs based on the attributes of the target data and a preset physical memory allocation strategy;
[0043] The physical memory allocation policy matches the attributes of the data, and is used to set the continuity, recyclability and / or execution authority of the physical memory.
[0044] During the creation of the client, the host can divide the virtual memory into regions; or after the client is created, the host and / or the client can divide the virtual memory into regions. Different regions can store data with different attributes, and the attributes of the data may include but are not limited to read and write frequency, importance, and security. During the operation of the client, when the client calls any target data in the virtual memory, the host can monitor the client's call behavior on the target data. Subsequently, the host can allocate appropriate physical memory to the area to which the target data belongs based on the attributes of the target data and the physical memory allocation strategy, from the perspective of physical memory continuity, recyclability, and execution permissions, thereby optimizing the allocation and management strategy of physical memory.
[0045] The attributes of the data may include, but are not limited to, read and write frequency, importance, and security level. In some embodiments, the data may include one or more of the following: kernel program data, high-access frequency data, read-write-only data, and data with a higher read frequency than a write frequency. In virtual memory, the area divided for storing kernel program target data may be referred to as a first area; the area divided for storing high-access frequency target data may be referred to as a second area; the area divided for storing read-write-only target data may be referred to as a third area; and the area divided for storing target data with a higher read frequency than a write frequency may be referred to as a fourth area.
[0046] Because the client virtualized from the host machine has complete hardware system functions and an operating system, the client machine can run kernel programs. Thus, the kernel program data can be the client machine's kernel program, and the kernel program data is of higher importance. Accordingly, the first area can also be referred to as the kernel area. To improve the kernel program's operating efficiency, in some embodiments, if the first area is included in multiple virtual memory areas, the host machine can allocate contiguous physical memory to the first area. As an example, the contiguous physical memory can be huge pages. Typically, the size of a normal page is 4KB, while the size of a huge page can be up to 1GB. Allocating contiguous huge pages to the kernel area can effectively reduce the number of page faults during kernel program execution, reduce page table entries, conserve memory space occupied by the page table, and reduce the number of memory address translations, thereby improving the kernel program's operating efficiency.
[0047] Highly accessed data may be data whose client access frequency is greater than a preset access frequency threshold, such as a page table. Each process run by the client can generate a page table to store the correspondence between logical pages and physical page frames. During the execution of a process, the client needs to frequently access the corresponding page table, including performing read and write operations on the page table. Page tables are highly accessed data. Accordingly, the second area can also be referred to as a page table area, which can store page tables corresponding to multiple processes run by the client. Because the client accesses the corresponding page table when each process runs, the client will frequently access the page table area.
[0048] As described above, when the host machine allocates physical memory on demand, it may continuously allocate and reclaim physical memory. Since the client machine frequently accesses the page table area, if the host machine reclaims the physical memory corresponding to the page table area every time the client machine has accessed the page table area, it will cause a memory page fault the next time the client machine accesses the page table in the page table area. After the memory page fault occurs, the host machine reallocates physical memory to the page table that the client machine needs to access. Obviously, the host machine needs to reallocate physical memory every time the client machine accesses the page table, which will greatly slow down the access speed of the page table and affect the running performance of the process. To this end, in some embodiments, if the second area is included in the multiple areas of virtual memory, the host machine can lock the physical memory allocated to the second area so that the physical memory corresponding to the second area cannot be reclaimed. In this way, the host machine can avoid frequent reallocation of physical memory and speed up the running efficiency of the process.
[0049] Read-write-only data can be data that is only read and written and cannot be executed, such as user data generated by a client's user process during operation. This data is often only read and written by the user process. Accordingly, the third area can also be referred to as the user data area. The user data area is used to store read-write-only user data and does not store executable instruction code. However, in some scenarios, malicious processes may package malicious code as user data and write it into the user data area. If this malicious code is executed, it will cause harm to the process and even the entire operating system. To this end, in some embodiments, if the third area is included in multiple areas of virtual memory, the host machine can set the execution permissions of the physical memory allocated for the third area to non-executable. In this way, after setting the execution permissions, even if malicious code is written to the user data area, the client cannot execute the malicious code in the user data area. The malicious code is stored in the user data area as "data" and cannot be executed, thereby strengthening security protection.
[0050] Data access includes both reading and writing. Some data in virtual memory, such as the code of user processes (hereinafter referred to as user code), is frequently invoked and executed by the client and rarely modified or written. Therefore, in some embodiments, data that is read more frequently than written may include user code. Accordingly, the fourth area may also be referred to as the user code area.
[0051] In some embodiments, the physical memory of the host machine includes heterogeneous memory, and the heterogeneous memory includes a first physical memory and a second physical memory. The read speed of the first physical memory is faster than the read speed of the second physical memory. The first physical memory may also be referred to as high-speed memory, and the second physical memory may also be referred to as low-speed memory. In some embodiments, the read speed and write speed of the low-speed memory may be the same, the read speed of the high-speed memory is higher than the read speed of the low-speed memory, and the write speed of the high-speed memory is lower than the write speed of the low-speed memory. In some embodiments, the high-speed memory has the characteristics of high performance but small capacity and high cost, for example, DRAM (Dynamic Random Access Memory), DDR SDRAM (Double Data Rate Synchronous Dynamic Random Access Memory), etc. can be used; the low-speed memory has the characteristics of low performance but large capacity and low cost, for example, persistent memory, etc.
[0052] Given that user code is read more frequently than written, in some embodiments, if the fourth area is included in the multiple virtual memory areas, the host machine can allocate physical memory to the fourth area from the first physical memory, that is, from the high-speed memory. This allows data such as user code, which is read more frequently than written, to be stored in the faster-read physical memory, speeding up the client's access to this data, thereby improving process efficiency and optimizing process performance.
[0053] Virtual memory may include, but is not limited to, the kernel area, page table area, user data area, and user code area listed in the above embodiments, and may also include other areas for storing other attribute data. In some embodiments, the virtual memory space corresponding to the kernel area may also be referred to as kernel space; the sum of the virtual memory spaces corresponding to the page table area, user data area, and user code area may be collectively referred to as user space. The size of the client kernel program stored in the kernel area is generally fixed, and the memory size required for the kernel program generally does not change much each time the client runs. Therefore, in some embodiments, such as Figure 3As shown in , the kernel area can be divided into the low-order addresses of the virtual memory. In contrast, the user space is used to store the client processes running on the client. The size of the page table area, user data area, and user code area in the user space is related to the number of client processes running and the amount of intermediate data generated by each client process. Therefore, the user space can be divided into memory addresses in the virtual memory that are higher than the kernel area in order to adjust the size of the memory space in each area. As an example, Figure 3 As shown, the virtual memory 300 can be divided into a kernel area 310 (first area), a page table area 320 (second area), a user code area 330 (fourth area) and a user data area 340 (third area) from low to high. At the same time, the virtual memory 300 can also include other areas 350 for storing other attribute data. In some embodiments, the front and back areas of the multiple areas divided by the virtual memory can be distributed non-contiguously, that is, there can be a blank virtual memory between the front and back areas, such as the blank area 360 ( Figure 3 There are 6 blank areas 360 in total. The front and back areas of the multiple areas may also be continuously distributed, that is, there is no blank area between the two areas.
[0054] As described above, the virtual memory of the client can be divided by the host. In some embodiments, the virtual memory can be divided into regions by the host during the creation of the client. In other embodiments, the virtual memory can be divided into regions by the host after the creation of the client is completed.
[0055] In addition, the client's virtual memory can also be divided by the client. For example, after the client is created, the client can divide the virtual memory into regions.
[0056] Virtual memory can also be divided jointly by the host and the client. For example, different areas in virtual memory can be divided by the host or the client. As described above, since the memory size required by the client kernel program stored in the kernel area is generally fixed, during the client creation process, the host can first divide the kernel area in the virtual memory, including determining the location and size of the kernel area in the virtual memory. Subsequently, after the client is created, the client can estimate the size of each area in the user space based on the number of running processes and divide the virtual memory into one or more of the page table area, user data area, and user code area. After the division is completed, the client can send the area information to the host so that the host can allocate the corresponding physical memory for each area. The area information may include the location and size information of each area.
[0057] In some embodiments, the client can also adjust the size and / or position of the multiple divided regions according to actual conditions, and update the adjusted region information of each region to the host machine. In some embodiments, the client can send the region information to the host machine through a hypercall or other method.
[0058] In some embodiments, the host machine may include a multi-core processor that can process tasks in parallel. A multi-core processor refers to a CPU circuit board that integrates two or more complete computing engines (cores), that is, more than two physical CPUs. In the embodiments of this specification, for electronic devices including multi-core processors, the physical CPU refers to the core in the multi-core processor. For a host machine including multiple physical CPUs, a non-uniform memory access architecture (NUMA) architecture can be used. The NUMA architecture includes at least two NUMA nodes, such as Figure 4 As shown, taking two NUMA nodes as an example, the host machine may include NUMA node 410 and NUMA node 420. Under the NUMA architecture, multiple physical CPUs and multiple memories of the host machine belong to different NUMA nodes. Each NUMA node includes at least one physical CPU and at least one physical memory. Figure 4 Taking a NUMA node consisting of a physical CPU and physical memory as an example, NUMA node 410 includes physical CPU 411 and physical memory 412. NUMA node 420 includes physical CPU 421 and physical memory 422. Within a NUMA node, the physical CPU and physical memory communicate using the Integrated Memory Controller Bus (IMC Bus), while NUMA nodes communicate using the Quick Path Interconnect (QPI). Because the latency of QPI is higher than the latency of the IMC Bus, the physical CPU on the host machine has different access speeds to memory (remote / local). The physical CPU accesses the physical memory of its own node faster, which is called local memory access; the physical CPU accesses the physical memory of other NUMA nodes slower, which is called remote memory access.
[0059] In some embodiments, the client can run on either NUMA node 410 or NUMA node 420. That is, the client's virtual CPU can be mapped and run on either physical CPU 411 or physical CPU 421. When the host allocates physical memory to the client's virtual memory, physical memory belonging to the same NUMA node as the physical CPU to which the virtual CPU is mapped can be allocated to the virtual memory to improve the physical CPU's memory access speed.
[0060] In some embodiments, the client may include multiple virtual CPUs and the client may run on at least two NUMA nodes. For example, the client may run on Figure 4 NUMA nodes 410 and 420 are shown. For example, multiple virtual CPUs included in a client can be mapped to physical CPU 411 and physical CPU 421 for execution, respectively. The client's virtual memory can be mapped to physical memory 412 and physical memory 422. Thus, among the multiple areas of virtual memory, at least two target areas are used to store data with the same attributes. The number of target areas is consistent with the number of NUMA nodes on which the client runs, and different target areas are allocated to the physical memory of different NUMA nodes on which the client runs. The target area can be one or more of the following: kernel area, page table area, user code area, and user data area.
[0061] As in the example described above, the client runs on NUMA node 410 and NUMA node 420, and the target area may include a kernel area, a page table area, a user code area, and a user data area. The virtual memory can be divided into two kernel areas, two page table areas, two user code areas, and two user data areas. Two areas of the same type can be allocated physical memory on different nodes. For example, the host machine can allocate part of the addresses in physical memory 412 to one of the two kernel areas according to the method provided in the above embodiment, and allocate part of the addresses in physical memory 422 to the other of the two kernel areas according to the method provided in the above embodiment. Physical memory allocation for other areas is also performed according to a similar process, which will not be described in detail here.
[0062] A memory allocation method provided in an embodiment of this specification divides the virtual memory allocated to the client into multiple areas, each area stores data of different attributes, and data of different attributes have different characteristics. When the host machine detects the client's call to the target data in the virtual memory, it allocates physical memory to the area of the target data based on the attributes of the target data and the preset physical memory allocation strategy. The physical memory allocation strategy matches the attributes of the data and is used to set one or more of the continuity, recyclability and execution permissions of the physical memory. The virtual memory is divided into multiple areas for storing data of different attributes according to the characteristics of the data. After the virtual memory is clearly divided, when allocating physical memory, the host machine can allocate appropriate physical memory to the area to which the target data belongs based on the attributes of the target data, from the perspective of physical memory continuity, recyclability and execution permissions, thereby optimizing the host machine's allocation and management strategy for physical memory.
[0063] Based on a memory allocation method described in any of the above embodiments, this specification also provides the following embodiments: Figure 5 The electronic device is a schematic diagram of a structure of an electronic device. The electronic device runs a client. Figure 5 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for its services. The processor reads the corresponding computer program from the non-volatile storage into the internal memory and then runs it, thereby implementing a memory allocation method described in any of the above embodiments.
[0064] In some embodiments, the above-mentioned electronic device may also be an electronic device in a distributed system. Figure 6 A schematic diagram of a distributed system is shown. Distributed system 600 may include multiple electronic devices, such as electronic devices 610-640 shown in the figure. Distributed system 600 can be used to maintain and manage big data. Each electronic device in distributed system 600 can store a portion of the data and maintain the stored data. In this embodiment, at least some of electronic devices 610-640 can run a client and execute a memory allocation method provided in any of the above embodiments.
[0065] Based on a memory allocation method described in any of the above embodiments, an embodiment of this specification further provides a computer program product, including a computer program, which can be used to execute a memory allocation method described in any of the above embodiments when executed by a processor.
[0066] Based on a memory allocation method described in any of the above embodiments, an embodiment of this specification further provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute a memory allocation method described in any of the above embodiments.
[0067] The foregoing description of specific embodiments of the present disclosure is provided herein. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may 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 shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0068] Those skilled in the art will readily recognize other embodiments of the embodiments described herein after considering the specification and practicing the inventions claimed herein. The embodiments described herein are intended to encompass any variations, uses, or adaptations of the embodiments described herein that follow the general principles of the embodiments described herein and include common knowledge or customary techniques in the art that are not claimed in the embodiments described herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the embodiments described herein being indicated by the following claims.
Claims
1. A memory allocation method, applied to a host computer, wherein the host computer runs a client computer, wherein the virtual memory allocated to the client computer is divided into a plurality of regions, each region storing data of different attributes, the method comprising: Monitoring the client's call to the target data in the virtual memory; Allocating physical memory to the area to which the target data belongs based on the attributes of the target data and a preset physical memory allocation policy; wherein the physical memory allocation policy matches the attributes of the data, and the physical memory allocation policy is used to set the continuity, recyclability, and execution permissions of the physical memory; Allocating physical memory to the area to which the target data belongs based on the attributes of the target data and a preset physical memory allocation strategy includes: When the plurality of areas include a first area storing target data of a kernel program, allocating continuous physical memory to the first area; When the multiple areas include a second area storing target data with a high access frequency, locking the physical memory allocated to the second area so that the physical memory corresponding to the second area cannot be reclaimed; wherein the access frequency of the target data with a high access frequency is greater than a preset access frequency threshold; When the plurality of areas include a third area storing read-write-only target data, the execution permission of the physical memory allocated to the third area is set to non-executable.
2. The method according to claim 1, wherein the physical memory of the host machine includes a first physical memory and a second physical memory, and a read speed of the first physical memory is faster than a read speed of the second physical memory; and allocating physical memory to the area to which the target data belongs based on the attributes of the target data and a preset physical memory allocation policy comprises: When the plurality of areas include a fourth area for storing target data having a higher read frequency than a write frequency, a physical memory is allocated to the fourth area from the first physical memory. 3 . The method according to claim 2 , wherein the virtual memory is divided into the first area, the second area, the fourth area, and the third area in order from low to high.
4. The method according to claim 1, wherein the host machine adopts a NUMA architecture, the NUMA architecture includes at least two NUMA nodes, and each of the NUMA nodes includes physical memory; the client runs on at least two of the NUMA nodes; at least two target areas among the multiple areas are used to store data with the same attributes, and different target areas are allocated to the physical memory of different NUMA nodes on which the client runs. 5 . The method according to claim 1 , wherein the multiple areas are divided by the host machine and / or the client machine.
6. The method according to claim 5, wherein the first area is divided by the host machine; After the second area and / or the third area are divided by the client, the client sends area information to the host machine, where the area information includes location information and size information of each divided area.
7. An electronic device, running a client, wherein the host comprises: processor; a memory for storing processor-executable instructions; Wherein, when the processor calls the executable instruction, the operation of the method according to any one of claims 1 to 6 is implemented.
8. A distributed system comprising at least one electronic device according to claim 7.
9. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, wherein a plurality of computer instructions are stored on the computer-readable storage medium, and when the computer instructions are executed, the method according to any one of claims 1 to 6 is performed.
Citation Information
Patent Citations
Method and device for managing memories
CN104750557A