WO2022199560A1 - 一种内存管理的方法及设备 - Google Patents
一种内存管理的方法及设备 Download PDFInfo
- Publication number
- WO2022199560A1 WO2022199560A1 PCT/CN2022/082140 CN2022082140W WO2022199560A1 WO 2022199560 A1 WO2022199560 A1 WO 2022199560A1 CN 2022082140 W CN2022082140 W CN 2022082140W WO 2022199560 A1 WO2022199560 A1 WO 2022199560A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- physical
- memory space
- memory
- pages
- type
- Prior art date
Links
- 238000007726 management method Methods 0.000 title abstract description 51
- 238000000034 method Methods 0.000 claims abstract description 290
- 238000012545 processing Methods 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 9
- 238000004064 recycling Methods 0.000 claims description 9
- 238000012544 monitoring process Methods 0.000 claims description 5
- 238000011084 recovery Methods 0.000 claims 1
- 238000013467 fragmentation Methods 0.000 abstract description 14
- 238000006062 fragmentation reaction Methods 0.000 abstract description 14
- 238000006243 chemical reaction Methods 0.000 description 14
- 238000010586 diagram Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 7
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000000737 periodic effect Effects 0.000 description 2
- 238000013468 resource allocation Methods 0.000 description 2
- 238000013519 translation Methods 0.000 description 2
- 101150053844 APP1 gene Proteins 0.000 description 1
- 101100055496 Arabidopsis thaliana APP2 gene Proteins 0.000 description 1
- 101100189105 Homo sapiens PABPC4 gene Proteins 0.000 description 1
- 102100039424 Polyadenylate-binding protein 4 Human genes 0.000 description 1
- 101100016250 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) GYL1 gene Proteins 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000000758 substrate Substances 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0877—Cache access modes
- G06F12/0882—Page mode
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0608—Saving storage space on storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
Definitions
- the present application relates to the field of computer technologies, and in particular, to a method and device for memory management.
- the memory of a computer system is usually managed by physical pages, and the size of a physical page is usually 4K, which can also be called a 4K page.
- a computer system allocates a physical page to a process, it records the allocation information of the corresponding physical page in the page table of the process in the form of a page table entry, and the page table entry is the row information in the page table. In this way, when a process wants to access a certain physical page, it can find the corresponding page table entry by querying the page table of the process, and then access the corresponding physical page.
- the computer system will first query the page table cache (translation lookaside buffer, TLB), and the TLB will cache the recently accessed page table entries. If the corresponding page is not queried in the TLB table entry, the page table of the process will be further queried. Due to the increasing use of memory by various processes, the number of page table entries has increased significantly, and the cache space of TLB is limited, so that the page table entry to be queried cannot be hit with a high probability by querying the TLB, that is, the TLB query miss (TLB miss) ) increases, which affects the memory access performance.
- TLB miss TLB query miss
- a solution commonly used in the industry is to use huge pages (2M pages or 1G pages) to replace continuous ordinary pages (4K pages).
- 2M pages or 1G pages which require multiple page table entry management
- huge pages only need one page table entry. management, thereby effectively improving the hit rate when querying the TLB.
- the memory will be fragmented, and there is often no contiguous memory space when allocating large pages, resulting in failure to allocate large pages.
- the embodiments of the present application provide a method for memory management, which is used to solve global memory fragmentation, and also solves the problem of reservation failure caused by memory fragmentation.
- Embodiments of the present application also provide corresponding apparatuses, computer equipment, computer-readable storage media, computer program products, and the like.
- a first aspect of the present application provides a memory management method, including: determining that a first process to access physical memory belongs to a target process group, the target process group is bound with at least one process, and the target process group corresponds to the first memory space,
- the first memory space is a storage area in the physical memory, and the first memory space includes at least one physical page larger than 4K; according to the physical memory requirements of the first process, physical pages are allocated for the first process from the first memory space .
- the memory management method provided in the first aspect above can be applied to a computer system, and the computer system can be a server, a terminal device, a virtual machine (virtual machine, VM) or a container (container). Physical memory is also often referred to as "memory".
- the first process may be any process in the computer system.
- a process refers to a program that has been run in a computer system, and is the basic unit of resource allocation and scheduling in a computer system.
- the target process group may be a pre-created process group, and the target process group will be bound with one or more processes.
- a plurality of processes includes two or more, and can also be described as at least two.
- the target process corresponds to the first memory space, and at least one process bound to the target process group can only use memory resources in the first memory space.
- the first memory space is a storage area in the physical memory.
- the first memory space includes at least one physical page larger than 4K; the division of physical pages is usually required, 4K pages are usually referred to as ordinary pages, and pages larger than 4K are usually referred to as "large pages". For example, 2M pages and 1G pages are called huge pages. Of course, huge pages can have other specifications, but they will all be integer multiples of 4K.
- the physical memory requirement of the first process refers to the amount of physical memory required by the first process, such as 56K, 1M, 2M or other possible values.
- the computer system will allocate one or more physical pages according to the physical memory requirements of the first process. For example, if the physical memory requirement is 56K, 14 4K physical pages can be allocated. If the physical memory requirement is 2M , you can allocate a large page of 2M.
- the use of the physical memory by the process is limited to the corresponding memory space, instead of randomly allocating physical pages from the entire physical memory, thereby solving the problem of physical memory.
- the problem of global fragmentation of memory because the first memory space includes at least one physical page larger than 4K, the allocation of large pages is guaranteed, because large pages can be allocated normally, and the page table cache (translation lookaside buffer, TLB) can also be reduced. In this way, when a process wants to access a physical page, the hit rate of querying the corresponding page table entry in the TLB can be improved, thereby improving the performance of memory access. It can avoid the problem of excessive processor usage caused by dynamic allocation of huge pages.
- the at least one physical page larger than 4K includes at least one of a 2M physical page and a 1G physical page.
- the above step allocating physical pages for the first process from the first memory space according to the physical memory requirements of the first process, including: detecting that the first memory space is blank If the type of the physical page in the blank state does not meet the physical memory requirements of the first process, the physical page of the first type in the physical page in the blank state in the first memory space is converted to the second type.
- the size of the physical page of the second type is different from the size of the physical page of the first type; the physical page of the second type is allocated to the first process.
- the computer system when allocating a physical page to the first process, the computer system will detect a physical page in a blank state in the first memory space, and a physical page in a blank state refers to a physical page that has not yet stored data , the physical page in the blank state can have 4K pages or other types of large pages. If it is determined that multiple 4K pages need to be allocated according to the physical memory requirements of the first process, and the number of 4K pages in the blank state is not satisfied If the first process needs physical memory, other types of physical pages can be converted into 4K pages, for example, 2M pages or 1G pages can be split into 4K pages.
- the first type and the second type have no fixed restrictions, and the physical page sizes of the two types may be different.
- the physical page of the first type is a 4K page
- the physical page of the second type may be a 2M page or a 1G page, or other physical pages of a size other than 4K.
- the physical page of the first type is a 2M page
- the physical page of the second type may be a 4K page or a 1G page, or other physical pages of a size other than 2M.
- the physical page of the first type is a 1G page
- the physical page of the second type may be a 4K page or a 2M page, or other physical pages of a size other than 1G.
- the computer system can control the merging or splitting of physical pages in the first memory space, so as to realize the conversion between different types of physical pages, in this way, there is no need to reserve too many huge pages , which avoids the problem of insufficient ordinary pages due to too many reserved huge pages, improves the ability to control various types of physical pages, and reduces the complexity of physical page management.
- the method further includes: monitoring the number of physical pages of various types that are in a blank state in the first memory space; when the number of physical pages of the first type is lower than the corresponding When the threshold value is reached, some of the second type physical pages are converted into the first type physical pages, and the size of the second type physical pages is different from that of the first type physical pages.
- various types of physical pages are included in the first memory space, and the number of various types of physical pages can be guaranteed by configuring a threshold or a watermark, such as a threshold of 4K pages
- the threshold is 200
- the threshold for 2M pages is 5
- the threshold for 1G pages is 2.
- the computer system adjusts the number of physical pages of various types by means of periodic monitoring, so as to keep the number of physical pages of various types in the first memory space not lower than the corresponding threshold. If the number of 4K pages detected is less than 200, more 4K pages can be obtained by splitting 2M pages or 1G pages.
- 4K pages can also be merged or split. Divide 1G pages to get more 2M pages.
- the physical pages of various types are converted to each other, it is guaranteed that the physical pages of the converted types are not lower than their corresponding thresholds. For example, when 4K pages are obtained by splitting 2M pages, the number of 2M pages is guaranteed to be no less than 5.
- the method further includes: after all the processes bound to the target process group are running and each physical page in the first memory space is in an idle state, unbinding Correspondence between the first memory space and the target process group; release the first memory space.
- each physical page is in an idle state, indicating that no process uses the physical page in the first memory space.
- the processes bound to the target process group are all running, it means that the processes bound to the target process group will no longer use the first memory space, so the corresponding relationship between the first memory space and the target process group can be unbound, and then After releasing the first memory space, the memory resources of the released first memory space can be reallocated to other process groups or processes for use. It can be seen that the fragmentation of the first memory space will end with the end of the life cycle of the process group, and it is not necessary to wait until the computer system is restarted to solve the problem of physical memory fragmentation as in the prior art. In this way, the performance of the physical memory is further improved.
- the above step: releasing the first memory space includes: restoring the physical pages in the first memory space to the initial state when the first memory space was allocated; releasing and restoring to the initial state The first memory space for the state.
- the first memory space before releasing the first memory space, the first memory space will be restored to the initial state when the first memory space was allocated, and the initial state usually has only large pages, such as multiple 1G pages.
- a 1G page may be split into multiple 2M pages and multiple 4K pages.
- the process of restoring to the initial state refers to merging the split physical pages into the original ones.
- the process of large pages such as: merging 4K pages and 2M pages into 1G pages in the initial state. In this way, the freed memory resources can be quickly allocated to the memory space for other process groups.
- the method further includes: creating the target process group, establishing a corresponding relationship between the target process group and the first memory space; configuring the target process group bound determined process.
- a target process group can be created to establish a corresponding relationship between the target process group and the first memory space, and then the process bound to the target process group is configured.
- the memory resources in the first memory space can be used, thereby effectively avoiding global fragmentation of the physical memory.
- a second aspect of the present application provides an apparatus for memory management, where the apparatus for memory management has the function of implementing the method of the first aspect or any possible implementation manner of the first aspect.
- This function can be implemented by hardware or by executing corresponding software by hardware.
- the hardware or software includes one or more modules corresponding to the above functions, such as a receiving unit and a processing unit.
- a third aspect of the present application provides a computer device, the computer device comprising at least one processor, a storage system, an input/output (I/O) interface, and a computer stored in the storage system and executable on the processor
- the computer executes the instructions, and when the computer executes the instructions are executed by the processor, the processor executes the method according to the first aspect or any possible implementation manner of the first aspect.
- a fourth aspect of the present application provides a computer-readable storage medium that stores one or more computer-executable instructions.
- the processor executes the first aspect or any one of the possible operations of the first aspect. method of implementation.
- a fifth aspect of the present application provides a computer program product that stores one or more computer-executable instructions.
- the processor executes the first aspect or any possible implementation manner of the first aspect. Methods.
- a sixth aspect of the present application provides a chip system, the chip system includes at least one processor, and the at least one processor is used to support the memory management device to implement the first aspect or any of the possible implementation manners of the first aspect. function.
- the chip system may further include a memory, which is used for saving necessary program instructions and data of the memory management device.
- the chip system may be composed of chips, or may include chips and other discrete devices.
- the solution provided by the embodiment of the present application by establishing the corresponding relationship between the process group and the memory space, limits the use of the physical memory by the process to the corresponding memory space, instead of randomly allocating physical pages from the entire physical memory, thereby solving the problem of physical memory.
- the problem of global fragmentation of memory because the first memory space includes at least one physical page larger than 4K, the allocation of large pages is guaranteed, because the large pages can be allocated normally, and the page table entries in the page table cache can also be reduced. In this way, when a process wants to access When the physical page is used, the hit rate of querying the corresponding page table entry in the TLB can be improved, thereby improving the performance of memory access.
- FIG. 1 is a schematic structural diagram of a computer system provided by an embodiment of the present application.
- FIG. 2 is a schematic diagram of a cloud scenario provided by an embodiment of the present application.
- FIG. 3 is a schematic diagram of an embodiment of a memory management method provided by an embodiment of the present application.
- FIG. 4 is a schematic diagram of another embodiment of a memory management method provided by an embodiment of the present application.
- FIG. 5 is a schematic diagram of another embodiment of a memory management method provided by an embodiment of the present application.
- FIG. 6 is a schematic diagram of another embodiment of the method for memory management provided by an embodiment of the present application.
- FIG. 7 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
- FIG. 8 is a schematic diagram of an embodiment of an apparatus for memory management provided by an embodiment of the present application.
- FIG. 9 is another schematic structural diagram of a computer device provided by an embodiment of the present application.
- the embodiments of the present application provide a method for memory management, which is used to solve global memory fragmentation, and also solves the problem of reservation failure caused by memory fragmentation.
- Embodiments of the present application also provide corresponding apparatuses, computer equipment, computer-readable storage media, computer program products, and the like.
- the memory management method provided by the embodiment of the present application is applied to a computer system, and the computer system may be a server, a terminal device, a virtual machine (virtual machine, VM) or a container (container).
- the architecture of the computer system can be understood with reference to FIG. 1 .
- FIG. 1 is a schematic structural diagram of a computer system.
- the architecture of the computer system 10 may include an application layer 101 , a kernel layer 102 and a hardware layer 103 .
- the application layer 101 includes a configuration interface and/or an application (application, APP), and the application may include various types of applications, such as an instant messaging application, a map application, and a shopping application.
- the configuration interface can be used by users to create process groups and set memory spaces, establish the corresponding relationship between process groups and memory spaces, and bind processes and process groups.
- the kernel layer 102 includes a resource management module, a process scheduling module and a memory management module, all of which can be implemented by software.
- the resource management module can be used to manage process groups
- the process scheduling module can be used to schedule processes
- the memory management module can be used to manage physical memory.
- the kernel layer 102 in this application may be an open source Linux kernel.
- the device layer 103 includes a communication interface 1031, a processor 1032, a physical memory 1033, a bus 1034, and the like.
- the communication interface 1031 , the processor 1032 and the physical memory 1033 are connected through a bus 1034 .
- the processor 1032 may include any type of general-purpose computing circuit or special-purpose logic circuit, such as: a field-programmable gate array (FPGA) or an application-specific integrated circuit (ASIC). It can also be one or more processors, such as a central processing unit (CPU), coupled to one or more semiconductor substrates.
- the physical memory may be configured as a plurality of memory spaces, such as the first memory space to the nth memory space as shown in FIG. 1 , and each memory space is a storage area in the physical memory. Different memory spaces correspond to different process groups. Of course, these memory spaces can be dynamically allocated or released and do not need to be fixed in physical memory.
- the computer system can create a process group through a resource management module at the kernel layer, configure a memory space for the process group in physical memory through the memory management module, and establish a corresponding relationship between the process group and the memory space, through the process scheduling
- the memory management module allocates physical pages from the corresponding memory space for the processes in the process group.
- the above-mentioned computer system may be a terminal device that has a physical memory and needs to run a process.
- the terminal device also referred to as user equipment (UE)
- UE user equipment
- the terminal equipment can be a personal computer (PC), a mobile phone (mobile phone), a tablet computer (pad), a computer with wireless transceiver function, a virtual reality (VR) terminal, and an augmented reality (AR) terminal.
- PC personal computer
- mobile phone mobile phone
- tablet computer pad
- AR augmented reality
- wireless terminals in industrial control wireless terminals in self-driving, wireless terminals in remote medical, wireless terminals in smart grid, transportation security wireless terminal in safety), wireless terminal in smart city (smart city), wireless terminal in smart home (smart home), wireless terminal in internet of things (IoT), etc.
- the above-mentioned computer system may be a server in a cloud environment.
- the cloud environment may include multiple servers, and these servers may be leased to a user in a virtualized form, and the user may be an enterprise. It can also be an individual, and the user can put forward a rental demand according to the usage demand, and the rental demand includes information such as the demand for physical memory and the demand for other resources. According to the rental requirements, engineers can create a container for the user in the cloud environment, and the container will contain the hardware resources required by the user.
- the container may correspond to a part of hardware resources in one server, or may correspond to hardware resources in multiple servers, which is not limited in this application.
- the server in the cloud environment can create a process group for the container according to the configuration of the engineer, allocate memory space from physical memory, and establish the corresponding relationship between the process group and the memory space. Allocate physical pages from the corresponding memory space.
- the content configured by the engineer may include: the identification of the process group, the size of the memory space, the number of various types of physical pages in the memory space, and the like.
- processes that use the same container can belong to a process group.
- the process group can be divided in various ways, not limited to being associated with a container. For example, it is divided according to the service type to which the process belongs, for example, a process corresponding to a video service is assigned to a process group, and a process corresponding to an instant messaging service is assigned to a process group. Or according to the application corresponding to the process, for example, the process corresponding to APP1 is divided into a process group, and the process corresponding to APP2 is divided into a process group. In this application, the division manner of the process group is not limited.
- the memory management method provided by the embodiment of the present application may include the following aspects: 1. Creating a process group and determining a memory space; 2. Allocation of physical pages; 3. Conversion of different types of physical pages; 4. Release of memory space . They are introduced separately below.
- the process group can be created by an engineer triggering the server, for example, creating a process group for a tenant's container.
- the process group may be created by a consumer user, or the terminal device may be created according to a pre-configured creation policy, which may be to create a process group by process type, create a process group by application, and so on.
- the memory space can be determined from the physical memory by the server or the terminal device according to the requirements of the process group.
- the process of determining the memory space can be understood as the process of selecting a continuous storage area.
- an embodiment of the memory management method provided by the embodiment of the present application includes:
- the target process group is bound with at least one process, the target process group corresponds to a first memory space, the first memory space is a storage area in the physical memory, and the first memory space includes at least one physical page larger than 4K.
- At least one physical page larger than 4K includes at least one of a 2M physical page and a 1G physical page.
- the first process may be any process in the computer system.
- a process refers to a program that has been run in a computer system, and is the basic unit of resource allocation and scheduling in a computer system.
- the target process group may be a pre-created process group, and the target process group will be bound with one or more processes.
- a plurality of processes includes two or more, and can also be described as at least two.
- the target process corresponds to the first memory space, and at least one process bound to the target process group can only use memory resources in the first memory space.
- the first memory space is a storage area in the physical memory.
- the first memory space includes at least one physical page larger than 4K; the division of physical pages is usually required, 4K pages are usually referred to as ordinary pages, and pages larger than 4K are usually referred to as "large pages".
- 4K pages are usually referred to as ordinary pages
- pages larger than 4K are usually referred to as "large pages”.
- 2M pages and 1G pages are called huge pages.
- huge pages can have other specifications, but they will all be integer multiples of 4K.
- the physical memory requirement of the first process refers to the amount of physical memory required by the first process, such as 56K, 1M, 2M or other possible values.
- the computer system will allocate one or more physical pages according to the physical memory requirements of the first process. For example, if the physical memory requirement is 56K, 14 4K physical pages can be allocated. If the physical memory requirement is 2M , you can allocate a large page of 2M.
- the solution provided by the embodiment of the present application by establishing the corresponding relationship between the process group and the memory space, limits the use of the physical memory by the process to the corresponding memory space, instead of randomly allocating physical pages from the entire physical memory, thereby solving the problem of physical memory.
- the problem of global fragmentation of memory because the first memory space includes at least one physical page larger than 4K, the allocation of large pages is guaranteed, because the large pages can be allocated normally, and the page table entries in the page table cache can also be reduced. In this way, when a process wants to access When a physical page is used, the hit rate of querying the corresponding page table entry in the TLB can be improved, thereby improving the performance of memory access.
- the processor can be avoided due to dynamic allocation of large pages. The problem of over-occupancy.
- the conversion of different types of physical pages may be conversion when a physical page is allocated, or when it is detected that the number of physical pages is lower than a threshold. They are introduced separately below.
- another embodiment of the memory management method provided by the embodiment of the present application includes:
- the computer system When allocating physical pages for the first process, the computer system will detect the physical pages in the first memory space that are in the blank state.
- the physical pages in the blank state refer to the physical pages that have not stored data, and the physical pages in the blank state can be There are 4K pages, and there can be other types of huge pages.
- the size of the second type of physical pages is different from the size of the first type of physical pages.
- the first type and the second type have no fixed restrictions, and the physical page sizes of the two types may be different.
- the physical page of the first type is a 4K page
- the physical page of the second type may be a 2M page or a 1G page, or other physical pages of a size other than 4K.
- the physical page of the first type is a 2M page
- the physical page of the second type may be a 4K page or a 1G page, or other physical pages of a size other than 2M.
- the physical page of the first type is a 1G page
- the physical page of the second type may be a 4K page or a 2M page, or other physical pages of a size other than 1G.
- the type of the physical page in the blank state does not meet the physical memory requirements of the first process, which may include that the physical page in the blank state does not have a type that meets the requirements of the first process, for example: the first process requires 4K pages, and There are no 4K pages in the first memory space when physical pages are allocated.
- the number of physical pages of the type to be allocated in the physical pages in the blank state is insufficient, resulting in that the physical memory requirements of the first process cannot be satisfied. For example, 300 4K pages need to be allocated for the first process, and the first process There are only 230 4K pages in the memory space.
- Conversion in this application includes merging or splitting. If it is determined that multiple 4K pages need to be allocated according to the physical memory requirements of the first process, and the number of 4K pages in a blank state does not meet the physical memory requirements of the first process, other types of physical pages can be converted into 4K pages , such as: split 2M pages or 1G pages into 4K pages. If it is determined that multiple 2M pages need to be allocated according to the physical memory requirements of the first process, and the number of 2M pages in a blank state does not meet the physical memory requirements of the first process, other types of physical pages can be converted into 2M pages , such as: split 1G pages into 2M pages, or combine multiple 4K pages into one 2M page.
- another embodiment of the memory management method provided by the embodiment of the present application includes:
- the number of various types of physical pages can be guaranteed by configuring thresholds or watermarks, such as: the threshold of 4K pages is 200, and the threshold of 2M pages The threshold is 5, and the threshold for 1G pages is 2.
- the number of thresholds here is just an example, and the thresholds in this application can be set according to requirements.
- the computer system adjusts the number of physical pages of various types by means of periodic monitoring, so as to keep the number of physical pages of various types in the first memory space not lower than the corresponding threshold.
- the size of the second type of physical pages is different from the size of the first type of physical pages.
- another embodiment of the memory management method provided by the embodiment of the present application includes:
- Each physical page being free means that no process is using the physical page in the first memory space.
- the processes bound to the target process group are all running, it means that the processes bound to the target process group will no longer use the first memory space, so the corresponding relationship between the first memory space and the target process group can be unbound, and then After releasing the first memory space, the memory resources of the released first memory space can be reallocated to other process groups or processes for use.
- the fragmentation of the first memory space will end with the end of the life cycle of the process group, and it is not necessary to wait until the computer system is restarted to solve the physical memory fragmentation as in the prior art.
- the problem In this way, the performance of the physical memory is further improved.
- this step 502 may include restoring the physical pages in the first memory space to the initial state when the first memory space was allocated; releasing the first memory space restored to the initial state.
- the first memory space before releasing the first memory space, the first memory space will be restored to the initial state when the first memory space was allocated, and the initial state usually has only large pages, such as multiple 1G pages.
- a 1G page may be split into multiple 2M pages and multiple 4K pages.
- the process of restoring to the initial state refers to merging the split physical pages into the original ones.
- the process of large pages such as: merging 4K pages and 2M pages into 1G pages in the initial state. In this way, the freed memory resources can be quickly allocated to the memory space for other process groups.
- the computer device includes a kernel layer. and hardware layer
- the resource management module of the kernel layer includes a process group module 601
- the process scheduling module includes a page conversion module 602
- the memory management module includes an application/release module 603 and a reservation/recycling module 604 .
- the hardware layer includes physical memory.
- the hardware layer also includes other hardware as shown in FIG. 1 , which are not listed one by one in FIG. 7 .
- the computer device may be a server or a terminal device, as well as other possible forms described in the above computer system section, such as a virtual machine or a container.
- the process group module 601 can control and execute the management of the process group, create the process group as described in the above memory management method section, and determine the content of the memory space.
- the page conversion module 602 can control and perform conversion between different types of physical pages in the memory space, such as the above steps 301 to 303 , and the contents of the corresponding parts of steps 401 and 402 .
- the application/release module 603 can perform the allocation of physical pages and the release of physical pages, as described in the memory management method described in the above-mentioned part of FIG. 3 .
- the reservation/recycling module 604 can perform large page reservation and memory space reclamation, as described above in the corresponding parts of steps 501 and 502 in FIG. 6 .
- an embodiment of the present application provides an apparatus 70 for memory management.
- An embodiment of the apparatus 70 for memory management includes:
- the determining unit 701 is configured to determine that the first process to be accessed to the physical memory belongs to a target process group, the target process group is bound with at least one process, the target process group corresponds to a first memory space, and the first memory
- the space is a storage area in the physical memory, and the first memory space includes at least one physical page larger than 4K.
- the determining unit 701 may execute step 201 of the method embodiment part corresponding to FIG. 3 above.
- the allocation unit 702 is configured to allocate a physical page to the first process from the first memory space corresponding to the target process group determined by the determining unit 701 according to the physical memory requirement of the first process .
- the allocating unit 702 may execute step 202 in the method embodiment part corresponding to FIG. 3 above.
- the solution provided by the embodiment of the present application by establishing the corresponding relationship between the process group and the memory space, limits the use of the physical memory by the process to the corresponding memory space, instead of randomly allocating physical pages from the entire physical memory, thereby solving the problem of physical memory.
- the problem of global fragmentation of memory because the first memory space includes at least one physical page larger than 4K, the allocation of large pages is guaranteed, because the large pages can be allocated normally, and the page table entries in the page table cache can also be reduced. In this way, when a process wants to access When a physical page is used, the hit rate of querying the corresponding page table entry in the TLB can be improved, thereby improving the performance of memory access.
- the processor can be avoided due to dynamic allocation of large pages. The problem of over-occupancy.
- the allocation unit 702 is configured to: detect the physical page in the blank state in the first memory space; if the type of the physical page in the blank state does not meet the requirement of the first process for the physical memory , the physical pages of the first type in the physical pages in the blank state in the first memory space are converted into physical pages of the second type, and the size of the physical pages of the second type is the same as the physical pages of the first type.
- the pages are of different sizes; the first process is allocated a physical page of the second type.
- the allocating unit 702 may execute steps 301 to 303 in the method embodiment part corresponding to FIG. 4 above.
- the apparatus 70 further includes a first processing unit 703, and the first processing unit 703 is configured to: monitor the number of physical pages of various types that are in a blank state in the first memory space; when the number of physical pages of the first type is lower than When the corresponding threshold is reached, some of the second type physical pages are converted into the first type physical pages, and the size of the second type physical pages is different from that of the first type physical pages.
- the first processing unit 703 may execute steps 401 to 402 in the method embodiment part corresponding to FIG. 5 above.
- the apparatus 70 further includes a recycling unit 704, which is configured to: after the processes bound to the target process group are all running, and each physical page in the first memory space is in an idle state, then Unbinding the corresponding relationship between the first memory space and the target process group; releasing the first memory space.
- the recycling unit 704 may execute steps 501 to 502 in the method embodiment part corresponding to FIG. 5 above.
- the recycling unit 704 is configured to: restore the physical pages in the first memory space to the initial state when the first memory space was allocated; and release the first memory space restored to the initial state.
- the apparatus 70 further includes a second processing unit 705, and the second processing unit 705 is configured to: create the target process group, establish a corresponding relationship between the target process group and the first memory space; configure the target process group the bound process.
- the second processing unit 705 may correspond to the process group module 601 in the above-mentioned FIG. 6
- the recycling unit 704 may correspond to the reservation/recycling module 604 in the above-mentioned FIG. 6
- the first processing unit 703 may correspond to the above-mentioned FIG. 6
- the page conversion module 602, the allocation unit 702 can correspond to the page conversion module 602 in the above-mentioned FIG. 6, or the application/release module 603 in the above-mentioned FIG. 6, and the determination unit 701 can also correspond to the above-mentioned application/release in FIG. 6 Module 603.
- FIG. 9 is a schematic diagram of a possible logical structure of the computer device 80 provided by the embodiment of the present application.
- Computer device 80 includes: processor 801 , communication interface 802 , physical memory 803 , and bus 804 .
- the processor 801 , the communication interface 802 and the physical memory 803 are connected to each other through a bus 804 .
- the processor 801 is configured to control and manage the actions of the computer device 80 , for example, the processor 801 is configured to execute the steps in the method embodiments of FIGS. 3 to 5 .
- Communication interface 802 is used to support computer device 80 to communicate.
- the physical memory 803 is used to store program codes and data of the computer device 80 and provide memory space for the process group.
- the processor 801 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logical blocks, modules and circuits described in connection with this disclosure.
- the processor 801 or the second processor 8031 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and the like.
- the bus 804 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like.
- PCI Peripheral Component Interconnect
- EISA Extended Industry Standard Architecture
- a computer-readable storage medium is also provided, where computer-executable instructions are stored in the computer-readable storage medium.
- the processor of the device executes the computer-executable instructions
- the device executes the above-mentioned FIG. 3 to The steps performed by the processor in FIG. 6 .
- a computer program product includes computer-executable instructions, and the computer-executable instructions are stored in a computer-readable storage medium; when a processor of a device executes the computer-executable instructions , the device executes the steps executed by the processor in the above-mentioned FIG. 3 to FIG. 6 .
- a chip system is further provided, where the chip system includes a processor, and the processor is used for the apparatus for supporting memory management to implement the steps performed by the processor in the above-mentioned FIG. 3 to FIG. 6 .
- the chip system may further include a memory, the memory, and the necessary program instructions and data of the device for saving data writing.
- the chip system may be composed of chips, or may include chips and other discrete devices.
- Units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
- each functional unit in each embodiment of the embodiments of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
- the functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer-readable storage medium.
- the technical solutions of the embodiments of the present application can be embodied in the form of software products in essence, or the parts that make contributions to the prior art or the parts of the technical solutions, and the computer software products are stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the embodiments of the present application.
- the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes .
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
本申请公开了一种内存管理的方法,该方法应用于计算机系统,该方法包括:确定待访问物理内存的第一进程归属于目标进程组,目标进程组绑定有至少一个进程,目标进程组与第一内存空间对应,第一内存空间为物理内存中的一块存储区域,第一内存空间包括至少一种大于4K的物理页;根据第一进程对物理内存的需求,从第一内存空间中为第一进程分配物理页。该方案将进程对物理内存的使用限制在对应的内存空间中,而不是从整个物理内存中随机分配物理页,从而解决了物理内存全局碎片化的问题。另外,因为第一内存空间包括至少一种大于4K的物理页,保证了大页分配,提高了在TLB中查询页表项的命中率,从而提高了内存访问的性能。
Description
本申请要求于2021年3月24日提交中国专利局、申请号为202110313871.9、发明名称为“一种内存管理的方法及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,具体涉及一种内存管理的方法及设备。
计算机系统的内存通常是按物理页进行管理的,一个物理页的大小通常为4K,也可以称为4K页。计算机系统在为进程分配物理页时,会在该进程的页表中以页表项的形式记录相应物理页的分配信息,页表项为页表中的行信息。这样,当某个进程要访问某个物理页时,就可以通过查询该进程的页表来找到相应的页表项,进而访问相应的物理页。
由于页表的查询开销很大,所以,计算机系统会先查询页表缓存(translation lookaside buffer,TLB),TLB中会缓存近期被访问过的页表项,如果在TLB中未查询到相应的页表项,则会进一步查询该进程的页表。由于各种进程对内存的使用越来越多,页表项大量增加,而TLB的缓存空间有限,导致通过查询TLB无法大概率命中要查询的页表项,也就是TLB查询未命中(TLB miss)增多,影响了内存访问性能。
当前业界普遍采用的一个解决方案是使用大页(2M页或1G页)替换连续普通页(4K页),相比于连续普通页需要多个页表项管理,大页只需要一个页表项进行管理,从而有效提高查询TLB时的命中率。但计算机系统运行一段时间后,内存会有碎片化的问题,在分配大页时经常会出现没有连续的内存空间,导致分配大页失败。
发明内容
本申请实施例提供一种内存管理的方法,用于解决全局内存碎片化,同时也就解决了因内存碎片化导致的预留失败的问题。本申请实施例还提供了相应的装置、计算机设备、计算机可读存储介质和计算机程序产品等。
本申请第一方面提供一种内存管理的方法,包括:确定待访问物理内存的第一进程归属于目标进程组,目标进程组绑定有至少一个进程,目标进程组与第一内存空间对应,第一内存空间为物理内存中的一块存储区域,第一内存空间包括至少一种大于4K的物理页;根据第一进程对物理内存的需求,从第一内存空间中为第一进程分配物理页。
上述第一方面所提供的内存管理的方法,可应用于计算机系统,该计算机系统可以为服务器、终端设备、虚拟机(virtual machine,VM)或容器(container)。物理内存通常也会被称为“内存”。第一进程可以是计算机系统中的任意一个进程。进程指的是计算机系统中已运行的程序,是计算机系统进行资源分配和调度的基本单位。目标进程组可以是预先创建的一个进程组,该目标进程组会绑定有一个或多个进程,本申请中,多个包括两个或两个以上,也可以描述为至少两个。该目标进程与第一内存空间对应,则该目标进程组所绑定的至少一个进程只能使用该第一内存空间中的内存资源。该第一内存空间是物理内存中的一块存储区域。第一内存空间包括至少一种大于4K的物理页;物理页的划分通常是有要求的,4K页通常称为普通页,大于4K的页通常称为“大页”。如:2M页、1G页都称为大 页,当然,大页还可以有其他规格,但都会是4K的整数倍。第一进程对物理内存的需求指的是第一进程需要的物理内存量,如:56K、1M、2M或其他可能的数值。计算机系统会根据第一进程对物理内存的需求,分配一个或多个物理页,如:若对物理内存的需求是56K,则可以分配14个4K的物理页,若对物理内存的需求是2M,则可以分配一个2M的大页。
由上述可知,该第一方面通过建立进程组与内存空间的对应关系,将进程对物理内存的使用限制在对应的内存空间中,而不是从整个物理内存中随机分配物理页,从而解决了物理内存全局碎片化的问题。另外,该第一方面中,因为第一内存空间包括至少一种大于4K的物理页,保证了大页分配,因为能正常分配大页,同时也可以减少页表缓存(translation lookaside buffer,TLB)中的页表项,这样,在有进程要访问物理页时,就可以提高在TLB中查询到对应页表项的命中率,从而提高了内存访问的性能,另外,因为预留了大页还可以避免因为动态分配大页而导致的处理器被过多占用的问题。
在第一方面的一种可能的实现方式中,至少一种大于4K的物理页包括2M物理页和1G物理页中的至少一种。
在第一方面的一种可能的实现方式中,上述步骤:根据第一进程对物理内存的需求,从第一内存空间中为第一进程分配物理页,包括:检测第一内存空间中处于空白状态的物理页;若处于空白状态的物理页的类型不满足第一进程对物理内存的需求,则将第一内存空间中处于空白状态的物理页中第一类型的物理页转换为第二类型的物理页,第二类型的物理页的大小与第一类型的物理页的大小不同;为第一进程分配第二类型的物理页。
该种可能的实现方式中,在为第一进程分配物理页时,计算机系统会检测第一内存空间中处于空白状态的物理页,处于空白状态的物理页指的是还没有存储数据的物理页,处于空白状态的物理页可以有4K页,也可以有其他类型的大页,如果根据第一进程对物理内存的需求确定需要分配多个4K页,而处于空白状态的4K页的数量不满足第一进程对物理内存的需求,则可以将其他类型的物理页转换为4K页,如:将2M页或1G页拆分为4K页。如果根据第一进程对物理内存的需求确定需要分配多个2M页,而处于空白状态的2M页的数量不满足第一进程对物理内存的需求,则可以将其他类型的物理页转换为2M页,如:将1G页拆分为2M页,或者将多个4K页合并为一个2M页。
本申请中,第一类型和第二类型没有固定限制,两种类型的物理页大小不同即可。若第一类型的物理页为4K页,那么第二类型的物理页就可以为2M页或1G页,也可以为其他非4K大小的物理页。若第一类型的物理页为2M页,那么第二类型的物理页就可以为4K页或1G页,也可以为其他非2M大小的物理页。若第一类型的物理页为1G页,那么第二类型的物理页就可以为4K页或2M页,也可以为其他非1G大小的物理页。
该种可能的实现方式中,因为计算机系统可以控制第一内存空间中的物理页合并或拆分,从而实现了不同类型的物理页之间的转换,这样,不需要预留过多的大页,避免了因为预留大页过多而造成普通页不足的问题,也提高了对各种类型的物理页的控制能力,降低了对物理页管理的复杂程度。
在第一方面的一种可能的实现方式中,该方法还包括:监测所述第一内存空间中处于空白状态的各类型物理页的数量;当第一类型的物理页的数量低于对应的阈值时,将部分 第二类型的物理页转换为所述第一类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同。
该种可能的实现方式中,在第一内存空间中通过会包括各种类型的物理页,可以通过配置阈值或水线的方式来保证各种类型的物理页的数量,如:4K页的阈值为200个,2M页的阈值为5个,1G页的阈值为2个,当然,这里的阈值数量只是举例,本申请中的阈值可以根据需求设置。计算机系统会通过周期性监测的方式来调整各类型的物理页的数量,从而保持第一内存空间中的各类型的物理页的数量不低于对应的阈值。如监测到4K页的数量低于200个,可以通过拆分2M页或1G页的方式得到更多的4K页,同理,若2M页低于对应的阈值,也可以通过合并4K页或者拆分1G页的方式来得到更多的2M页。通常,在各类型的物理页相互转换时,会保证被转换类型的物理页不低于其对应的阈值。如:在通过拆分2M页得到4K页时,会保证2M页的数量不少于5个。
该种可能的实现方式中,可以控制第一内存空间中的物理页合并或拆分,从而实现了不同类型的物理页之间的转换,这样,不需要预留过多的大页,避免了因为预留大页过多而造成普通页不足的问题,也提高了对各种类型的物理页的控制能力,降低了对物理页管理的复杂程度。
在第一方面的一种可能的实现方式中,该方法还包括:当目标进程组所绑定的进程都运行结束后,第一内存空间中的每个物理页都处于空闲状态,则解绑第一内存空间与目标进程组的对应关系;释放第一内存空间。
该种可能的实现方式中,每个物理页都处于空闲状态表示没有进程使用第一内存空间中的物理页。目标进程组所绑定的进程都运行结束后,表示目标进程组所绑定的进程不会再使用该第一内存空间,那么就可以解绑第一内存空间与目标进程组的对应关系,然后释放第一内存空间,释放后的第一内存空间的内存资源就可以再重新分配给其他进程组或进程使用。由此可见,该第一内存空间的碎片化会随着进程组的生命周期的结束而结束,而不需要像现有技术,要等到计算机系统重启才能解决物理内存碎片化的问题。这样,进一步提高了物理内存的性能。
在第一方面的一种可能的实现方式中,上述步骤:释放所述第一内存空间,包括:将第一内存空间中物理页恢复到分配第一内存空间时的初始状态;释放恢复到初始状态的第一内存空间。
该种可能的实现方式中,在释放第一内存空间之前,会将第一内存空间恢复到分配第一内存空间时的初始状态,该初始状态通常只有大页,如多个1G页,在为进程分配物理页的过程中,1G页可能被拆分成了多个2M页,以及多个4K页,本申请中,恢复到初始状态的过程指的是将被拆分的物理页合并为原来的大页的过程,如:将4K页和2M页都合并为初始状态时的1G页。这样,有利于释放后的内存资源可以快速的被分配到用于其他进程组的内存空间。
在第一方面的一种可能的实现方式中,该方法还包括:创建所述目标进程组,建立所述目标进程组与所述第一内存空间的对应关系;配置所述目标进程组所绑定的进程。
该种可能的实现方式中,在进程运行之前,可以先创建目标进程组,为给目标进程组 与第一内存空间建立对应关系,然后再配置该目标进程组所绑定的进程,这样,该目标进程组所绑定的进程运行时,就可以使用第一内存空间中的内存资源,从而可以有效避免造成物理内存全局碎片化。
本申请第二方面提供一种内存管理的装置,该内存管理的装置具有实现上述第一方面或第一方面任意一种可能实现方式的方法的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的模块,例如:接收单元和处理单元。
本申请第三方面提供一种计算机设备,该计算机设备包括至少一个处理器、存储系统、输入/输出(input/output,I/O)接口以及存储在存储系统中并可在处理器上运行的计算机执行指令,当计算机执行指令被处理器执行时,处理器执行如上述第一方面或第一方面任意一种可能的实现方式的方法。
本申请第四方面提供一种存储一个或多个计算机执行指令的计算机可读存储介质,当计算机执行指令被处理器执行时,处理器执行如上述第一方面或第一方面任意一种可能的实现方式的方法。
本申请第五方面提供一种存储一个或多个计算机执行指令的计算机程序产品,当计算机执行指令被处理器执行时,处理器执行如上述第一方面或第一方面任意一种可能的实现方式的方法。
本申请第六方面提供了一种芯片系统,该芯片系统包括至少一个处理器,至少一个处理器用于支持内存管理的装置实现上述第一方面或第一方面任意一种可能的实现方式中所涉及的功能。在一种可能的设计中,芯片系统还可以包括存储器,存储器,用于保存内存管理的装置必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
其中,第二方面至第六方面或者其中任一种可能实现方式所带来的技术效果可参见第一方面或第一方面不同可能实现方式所带来的技术效果,此处不再赘述。
本申请实施例提供的方案,通过建立进程组与内存空间的对应关系,将进程对物理内存的使用限制在对应的内存空间中,而不是从整个物理内存中随机分配物理页,从而解决了物理内存全局碎片化的问题。另外,因为第一内存空间包括至少一种大于4K的物理页,保证了大页分配,因为能正常分配大页,同时也可以减少页表缓存中的页表项,这样,在有进程要访问物理页时,就可以提高在TLB中查询到对应页表项的命中率,从而提高了内存访问的性能。
图1是本申请实施例提供的计算机系统的一结构示意图;
图2是本申请实施例提供的云场景的一示意图;
图3是本申请实施例提供的内存管理的方法的一实施例示意图;
图4是本申请实施例提供的内存管理的方法的另一实施例示意图;
图5是本申请实施例提供的内存管理的方法的另一实施例示意图;
图6是本申请实施例提供的内存管理的方法的另一实施例示意图;
图7是本申请实施例提供的计算机设备的一结构示意图;
图8是本申请实施例提供的内存管理的装置的一实施例示意图;
图9是本申请实施例提供的计算机设备的另一结构示意图。
下面结合附图,对本申请的实施例进行描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。本领域普通技术人员可知,随着技术发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
本申请实施例提供一种内存管理的方法,用于解决全局内存碎片化,同时也就解决了因内存碎片化导致的预留失败的问题。本申请实施例还提供了相应的装置、计算机设备、计算机可读存储介质和计算机程序产品等。
本申请实施例提供的内存管理的方法应用于计算机系统,该计算机系统可以为服务器、终端设备、虚拟机(virtual machine,VM)或容器(container)。该计算机系统的架构可以参阅图1进行理解。
图1为计算机系统的一架构示意图。
如图1所示,该计算机系统10的架构可以包括应用层101、内核层102和硬件层103。
应用层101包括配置界面和/或应用(application,APP),该应用可以包括各种类型的应用,例如:即时通信应用、地图应用以及购物应用等。配置界面可以用于用户创建进程组以及设置内存空间,建立进程组与内存空间的对应关系,以及绑定进程与进程组。
内核层102包括资源管理模块、进程调度模块和内存管理模块,这三个模块都可以通过软件来实现。资源管理模块可以用于管理进程组,进程调度模块可以用于调度进程,内存管理模块可以用于管理物理内存。本申请中的内核层102可以是开源的Linux内核。
设备层103包括通信接口1031、处理器1032、物理内存1033和总线1034等。通信接口1031、处理器1032和物理内存1033通过总线1034连接。其中,处理器1032可以包括任何类型的通用计算电路或专用逻辑电路,例如:现场可编程门阵列(field-programmable gate array,FPGA)或专用集成电路(application specific integrated circuit,ASIC)。也可以是耦合到一个或多个半导体基板的一个或多个处理器,例如中央处理器(central processing unit,CPU)。物理内存可以被配置为多个内存空间,如图1中示意出的第一内存空间至第n内存空间,每个内存空间是物理内存中的一块存储区域。不同的内存空间对应不同的进程组。当然,这些内存空间可以动态配置或释放,并不需要固定在物理内存中。
本申请中,该计算机系统可以通过内核层的资源管理模块创建进程组,通过内存管理 模块在物理内存中为进程组配置内存空间,并建立进程组与内存空间之间的对应关系,通过进程调度模块调度进程运行时,再通过内存管理模块为进程组中的进程从对应的内存空间分配物理页。
本申请中,上述计算机系统可以是具有物理内存,并需要运行进程的终端设备,该终端设备(也可以称为用户设备(user equipment,UE))是一种具有无线收发功能的设备,可以部署在陆地上,包括室内或室外、手持或车载;也可以部署在水面上(如轮船等);还可以部署在空中(例如飞机、气球和卫星上等)。终端设备可以个人电脑(personal computer,PC)、手机(mobile phone)、平板电脑(pad)、带无线收发功能的电脑、虚拟现实(virtual reality,VR)终端、增强现实(augmented reality,AR)终端、工业控制(industrial control)中的无线终端、无人驾驶(self driving)中的无线终端、远程医疗(remote medical)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端、以物联网(internet of things,IoT)中的无线终端等。
本申请中,上述计算机系统可以是云环境中的服务器,如图2所示,在云环境中可以包括多个服务器,这些服务器可以以虚拟化的形式租赁给用户使用,该用户可以是企业,也可以是个人,用户可以根据使用需求提出租赁需求,该租赁需求中包括对物理内存的需求量,以及对其他资源的需求量等信息。工程人员可以根据该租赁需求,在云环境中为该用户创建容器,该容器会包含该用户所需要的硬件资源。
该容器可以对应一个服务器中的一部分硬件资源,也可以对应多个服务器中的硬件资源,对此,本申请不做限定。
云环境中的服务器可以根据工程人员的配置为该容器创建进程组,从物理内存中分配内存空间,并建立进程组与内存空间之间的对应关系,在进程运行时,为进程组中的进程从对应的内存空间分配物理页。工程人员配置的内容可以包括:进程组的标识、内存空间的大小,内存空间中各种类型的物理页的数量等。
通常,使用同一个容器的进程可以归属为一个进程组,当然,进程组的划分方式可以有多种,不限于与容器关联。如:按照进程所属的业务类型划分,如:将视频业务对应的进程归属到一个进程组中,将即时通信业务对应的进程归属到一个进程组中。或者按照进程所对应的应用划分,如:将APP1所对应的进程划分到一个进程组中,将APP2所对应的进程划分到一个进程组中。本申请中,对进程组的划分方式不做限定。
无论计算机系统是终端设备还是服务器,本申请所提供的内存管理的思想是一致的。
本申请实施例提供的内存管理的方法可以包括如下几个方面:一、创建进程组,以及确定内存空间;二、物理页分配;三、不同类型的物理页的转换;四、内存空间的释放。下面分别进行介绍。
一、创建进程组,以及确定内存空间。
在云场景中,该进程组可以是工程人员触发服务器创建的,如:针对一个租户的容器创建一个进程组。在终端设备中,该进程组可以是消费者用户创建的,也可以终端设备根据预先配置的创建策略创建的,该创建策略可以是按照进程类型创建进程组、按照应用创 建进程组等。
内存空间可以是服务器或终端设备根据进程组的需求,从物理内存中确定的,确定内存空间的过程可以理解为是选择一段连续存储区域的过程。
然后,建立该进程组与该内存空间的对应关系,并配置该进程组所绑定的进程,这样,该进程组所绑定的进程在运行时就可以使用该内存空间中的内存资源。
二、物理页分配。
如图3所示,本申请实施例提供的内存管理的方法的一实施例包括:
201.确定待访问物理内存的第一进程归属于目标进程组。
目标进程组绑定有至少一个进程,目标进程组与第一内存空间对应,第一内存空间为物理内存中的一块存储区域,第一内存空间包括至少一种大于4K的物理页。
可选地,本申请中,至少一种大于4K的物理页包括2M物理页和1G物理页中的至少一种。
本申请中,物理内存通常也会被称为“内存”。第一进程可以是计算机系统中的任意一个进程。进程指的是计算机系统中已运行的程序,是计算机系统进行资源分配和调度的基本单位。
目标进程组可以是预先创建的一个进程组,该目标进程组会绑定有一个或多个进程,本申请中,多个包括两个或两个以上,也可以描述为至少两个。
该目标进程与第一内存空间对应,则该目标进程组所绑定的至少一个进程只能使用该第一内存空间中的内存资源。
该第一内存空间是物理内存中的一块存储区域。第一内存空间包括至少一种大于4K的物理页;物理页的划分通常是有要求的,4K页通常称为普通页,大于4K的页通常称为“大页”。如:2M页、1G页都称为大页,当然,大页还可以有其他规格,但都会是4K的整数倍。
第一进程对物理内存的需求指的是第一进程需要的物理内存量,如:56K、1M、2M或其他可能的数值。
202.根据第一进程对物理内存的需求,从第一内存空间中为第一进程分配物理页。
计算机系统会根据第一进程对物理内存的需求,分配一个或多个物理页,如:若对物理内存的需求是56K,则可以分配14个4K的物理页,若对物理内存的需求是2M,则可以分配一个2M的大页。
本申请实施例提供的方案,通过建立进程组与内存空间的对应关系,将进程对物理内存的使用限制在对应的内存空间中,而不是从整个物理内存中随机分配物理页,从而解决了物理内存全局碎片化的问题。另外,因为第一内存空间包括至少一种大于4K的物理页,保证了大页分配,因为能正常分配大页,同时也可以减少页表缓存中的页表项,这样,在有进程要访问物理页时,就可以提高在TLB中查询到对应页表项的命中率,从而提高了内存访问的性能,另外,因为预留了大页还可以避免因为动态分配大页而导致的处理器被过多占用的问题。
三、不同类型的物理页的转换。
其中,不同类型的物理页的转换可以是分配物理页时转换,也可以在监测到物理页的数量低于阈值时转换。下面分别进行介绍。
1.分配物理页时转换。
如图4所示,本申请实施例提供的内存管理的方法的另一实施例包括:
301.检测第一内存空间中处于空白状态的物理页。
在为第一进程分配物理页时,计算机系统会检测第一内存空间中处于空白状态的物理页,处于空白状态的物理页指的是还没有存储数据的物理页,处于空白状态的物理页可以有4K页,也可以有其他类型的大页。
302.若处于空白状态的物理页的类型不满足第一进程对物理内存的需求,则将第一内存空间中处于空白状态的物理页中第一类型的物理页转换为第二类型的物理页。
第二类型的物理页的大小与第一类型的物理页的大小不同。
本申请中,第一类型和第二类型没有固定限制,两种类型的物理页大小不同即可。若第一类型的物理页为4K页,那么第二类型的物理页就可以为2M页或1G页,也可以为其他非4K大小的物理页。若第一类型的物理页为2M页,那么第二类型的物理页就可以为4K页或1G页,也可以为其他非2M大小的物理页。若第一类型的物理页为1G页,那么第二类型的物理页就可以为4K页或2M页,也可以为其他非1G大小的物理页。
本申请中,处于空白状态的物理页的类型不满足第一进程对物理内存的需求,可以包括空白状态的物理页不存在满足第一进程需求的类型,如:第一进程需要4K页,而第一内存空间中在分配物理页时不存在4K页。另外,还可以是,空白状态的物理页中所要分配类型的物理页的数量不足,导致不满足第一进程对物理内存的需求,如:需要为第一进程分配300个4K页,而第一内存空间中只有230个4K页。
本申请中的“转换”包括合并或拆分。如果根据第一进程对物理内存的需求确定需要分配多个4K页,而处于空白状态的4K页的数量不满足第一进程对物理内存的需求,则可以将其他类型的物理页转换为4K页,如:将2M页或1G页拆分为4K页。如果根据第一进程对物理内存的需求确定需要分配多个2M页,而处于空白状态的2M页的数量不满足第一进程对物理内存的需求,则可以将其他类型的物理页转换为2M页,如:将1G页拆分为2M页,或者将多个4K页合并为一个2M页。
303.为第一进程分配第二类型的物理页。
2.监测到物理页的数量低于阈值时转换。
如图5所示,本申请实施例提供的内存管理的方法的另一实施例包括:
401.监测所述第一内存空间中处于空白状态的各类型物理页的数量。
在第一内存空间中通过会包括各种类型的物理页,可以通过配置阈值或水线的方式来保证各种类型的物理页的数量,如:4K页的阈值为200个,2M页的阈值为5个,1G页的阈值为2个,当然,这里的阈值数量只是举例,本申请中的阈值可以根据需求设置。计算机系统会通过周期性监测的方式来调整各类型的物理页的数量,从而保持第一内存空间中的各类型的物理页的数量不低于对应的阈值。
402.当第一类型的物理页的数量低于对应的阈值时,将部分第二类型的物理页转换为所述第一类型的物理页。
所述第二类型的物理页的大小与所述第一类型的物理页的大小不同。
如监测到4K页的数量低于200个,可以通过拆分2M页或1G页的方式得到更多的4K页,同理,若2M页低于对应的阈值,也可以通过合并4K页或者拆分1G页的方式来得到更多的2M页。通常,在各类型的物理页相互转换时,会保证被转换类型的物理页不低于其对应的阈值。如:在通过拆分2M页得到4K页时,会保证2M页的数量不少于5个。
本申请中提供的上述两种物理页之间的转换方案,因为计算机系统可以控制第一内存空间中的物理页合并或拆分,从而实现了不同类型的物理页之间的转换,这样,不需要预留过多的大页,避免了因为预留大页过多而造成普通页不足的问题,也提高了对各种类型的物理页的控制能力,降低了对物理页管理的复杂程度。
四、内存空间的释放。
如图6所示,本申请实施例提供的内存管理的方法的另一实施例包括:
501.当目标进程组所绑定的进程都运行结束后,第一内存空间中的每个物理页都处于空闲状态,则解绑第一内存空间与目标进程组的对应关系。
每个物理页都处于空闲状态表示没有进程使用第一内存空间中的物理页。目标进程组所绑定的进程都运行结束后,表示目标进程组所绑定的进程不会再使用该第一内存空间,那么就可以解绑第一内存空间与目标进程组的对应关系,然后释放第一内存空间,释放后的第一内存空间的内存资源就可以再重新分配给其他进程组或进程使用。
502.释放第一内存空间。
本申请提供的内存空间的释放方案,该第一内存空间的碎片化会随着进程组的生命周期的结束而结束,而不需要像现有技术,要等到计算机系统重启才能解决物理内存碎片化的问题。这样,进一步提高了物理内存的性能。
可选地,该步骤502可以包括将第一内存空间中物理页恢复到分配第一内存空间时的初始状态;释放恢复到初始状态的第一内存空间。
该种可能的实现方式中,在释放第一内存空间之前,会将第一内存空间恢复到分配第一内存空间时的初始状态,该初始状态通常只有大页,如多个1G页,在为进程分配物理页的过程中,1G页可能被拆分成了多个2M页,以及多个4K页,本申请中,恢复到初始状态的过程指的是将被拆分的物理页合并为原来的大页的过程,如:将4K页和2M页都合并为初始状态时的1G页。这样,有利于释放后的内存资源可以快速的被分配到用于其他进程组的内存空间。
以上所描述的内存管理的方法,可以通过在上述图1所示的资源管理模块、进程调度模块和内存管理模块中设置不同的功能单元来实现,如图7所示,该计算机设备包括内核层和硬件层,该内核层的资源管理模块中包括进程组模块601,进程调度模块中包括页面转换模块602,内存管理模块中包括申请/释放模块603和预留/回收模块604。硬件层包括物理内存,当然,硬件层还包括如图1所示出的其他硬件,该图7中未一一列出。该计算机设备可以是服务器或终端设备,以及上述计算机系统部分所描述的其他可能形态,如:虚拟机或容器等。
其中,进程组模块601可以控制执行对进程组的管理,如上述内存管理方法部分所描述的创建进程组,以及确定内存空间的内容。
页面转换模块602可以控制执行对内存空间中不同类型的物理页之间的转换,如上述步骤301至步骤303,以及步骤401和步骤402对应部分的内容。
申请/释放模块603可以执行物理页的分配和物理页的释放过程,如上述图3部分所描述的内存管理的方法的内容。
预留/回收模块604可以执行大页预留和内存空间的回收,如上述图6对应部分步骤501和步骤502所对应的内容。
以上,本申请从多个方面介绍了内存管理的方法,下面结合附图,介绍本申请的内存管理的装置。
如图8所示,本申请实施例提供一种内存管理的装置70,该内存管理的装置70的一实施例包括:
确定单元701,用于确定待访问物理内存的第一进程归属于目标进程组,所述目标进程组绑定有至少一个进程,所述目标进程组与第一内存空间对应,所述第一内存空间为所述物理内存中的一块存储区域,所述第一内存空间包括至少一种大于4K的物理页。该确定单元701可以执行上述图3对应的方法实施例部分的步骤201。
分配单元702,用于根据所述第一进程对所述物理内存的需求,从所述确定单元701确定的所述目标进程组所对应的第一内存空间中为所述第一进程分配物理页。该分配单元702可以执行上述图3对应的方法实施例部分的步骤202。
本申请实施例提供的方案,通过建立进程组与内存空间的对应关系,将进程对物理内存的使用限制在对应的内存空间中,而不是从整个物理内存中随机分配物理页,从而解决了物理内存全局碎片化的问题。另外,因为第一内存空间包括至少一种大于4K的物理页,保证了大页分配,因为能正常分配大页,同时也可以减少页表缓存中的页表项,这样,在有进程要访问物理页时,就可以提高在TLB中查询到对应页表项的命中率,从而提高了内存访问的性能,另外,因为预留了大页还可以避免因为动态分配大页而导致的处理器被过多占用的问题。
可选地,分配单元702用于:检测所述第一内存空间中处于空白状态的物理页;若所述处于空白状态的物理页的类型不满足所述第一进程对所述物理内存的需求,则将所述第一内存空间中处于空白状态的物理页中第一类型的物理页转换为第二类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同;为所述第一进程分配所述第二类型的物理页。该分配单元702可以执行上述图4对应的方法实施例部分的步骤301至303。
该装置70还包括第一处理单元703,该第一处理单元703用于:监测所述第一内存空间中处于空白状态的各类型物理页的数量;当第一类型的物理页的数量低于对应的阈值时,将部分第二类型的物理页转换为所述第一类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同。该第一处理单元703可以执行上述图5对应的方法实施例部分的步骤401至402。
该装置70还包括回收单元704,该回收单元704用于:当所述目标进程组所绑定的进程都运行结束后,所述第一内存空间中的每个物理页都处于空闲状态,则解绑所述第一内存空间与所述目标进程组的对应关系;释放所述第一内存空间。该回收单元704可以执行上述 图5对应的方法实施例部分的步骤501至502。
该回收单元704用于:将第一内存空间中物理页恢复到分配第一内存空间时的初始状态;释放恢复到初始状态的第一内存空间。
该装置70还包括第二处理单元705,该第二处理单元705用于:创建所述目标进程组,建立所述目标进程组与所述第一内存空间的对应关系;配置所述目标进程组所绑定的进程。
本申请中,该第二处理单元705可以对应上述图6中的进程组模块601,回收单元704可以对应上述图6中的预留/回收模块604,第一处理单元703可以对应上述图6中的页面转换模块602,分配单元702即可以对应上述图6中的页面转换模块602,也可以对应上述图6中的申请/释放模块603,确定单元701也可以对应上述图6中的申请/释放模块603。
以上所描述的内存管理的装置可以参阅前面内存管理的方法的相应内容进行理解,此处不在重复赘述。
图9所示,为本申请的实施例提供的计算机设备80的一种可能的逻辑结构示意图。计算机设备80包括:处理器801、通信接口802、物理内存803以及总线804。处理器801、通信接口802以及物理内存803通过总线804相互连接。在本申请的实施例中,处理器801用于对计算机设备80的动作进行控制管理,例如,处理器801用于执行图3至图5的方法实施例中的步骤。通信接口802用于支持计算机设备80进行通信。物理内存803,用于存储计算机设备80的程序代码和数据,并为进程组提供内存空间。
其中,处理器801可以是中央处理器单元,通用处理器,数字信号处理器,专用集成电路,现场可编程门阵列或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器801或第二处理器8031也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理器和微处理器的组合等等。总线804可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
在本申请的另一实施例中,还提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,当设备的处理器执行该计算机执行指令时,设备执行上述图3至图6中处理器所执行的步骤。
在本申请的另一实施例中,还提供一种计算机程序产品,该计算机程序产品包括计算机执行指令,该计算机执行指令存储在计算机可读存储介质中;当设备的处理器执行该计算机执行指令时,设备执行上述图3至图6中处理器所执行的步骤。
在本申请的另一实施例中,还提供一种芯片系统,该芯片系统包括处理器,该处理器用于支持内存管理的装置实现上述图3至图6中处理器所执行的步骤。在一种可能的设计中,芯片系统还可以包括存储器,存储器,用于保存数据写入的装置必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及 算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请实施例的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请实施例所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请实施例各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请实施例各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上,仅为本申请实施例的具体实施方式,但本申请实施例的保护范围并不局限于此。
Claims (16)
- 一种内存管理的方法,其特征在于,包括:确定待访问物理内存的第一进程归属于目标进程组,所述目标进程组绑定有至少一个进程,所述目标进程组与第一内存空间对应,所述第一内存空间为所述物理内存中的一块存储区域,所述第一内存空间包括至少一种大于4K的物理页;根据所述第一进程对所述物理内存的需求,从所述第一内存空间中为所述第一进程分配物理页。
- 根据权利要求1所述的方法,其特征在于,所述至少一种大于4K的物理页包括2M物理页和1G物理页中的至少一种。
- 根据权利要求1或2所述的方法,其特征在于,所述根据所述第一进程对所述物理内存的需求,从所述第一内存空间中为所述第一进程分配物理页,包括:检测所述第一内存空间中处于空白状态的物理页;若所述处于空白状态的物理页的类型不满足所述第一进程对所述物理内存的需求,则将所述第一内存空间中处于空白状态的物理页中第一类型的物理页转换为第二类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同;为所述第一进程分配所述第二类型的物理页。
- 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:监测所述第一内存空间中处于空白状态的各类型物理页的数量;当第一类型的物理页的数量低于对应的阈值时,将部分第二类型的物理页转换为所述第一类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同。
- 根据权利要求1-4任一项所述的方法,其特征在于,所述方法还包括:当所述目标进程组所绑定的进程都运行结束后,所述第一内存空间中的每个物理页都处于空闲状态,则解绑所述第一内存空间与所述目标进程组的对应关系;释放所述第一内存空间。
- 根据权利要求5所述的方法,其特征在于,所述释放所述第一内存空间,包括:将所述第一内存空间中物理页恢复到分配所述第一内存空间时的初始状态;释放恢复到所述初始状态的所述第一内存空间。
- 根据权利要求1-6任一项所述的方法,其特征在于,所述方法还包括:创建所述目标进程组,建立所述目标进程组与所述第一内存空间的对应关系;配置所述目标进程组所绑定的进程。
- 一种内存管理的装置,其特征在于,包括:确定单元,用于确定待访问物理内存的第一进程归属于目标进程组,所述目标进程组绑定有至少一个进程,所述目标进程组与第一内存空间对应,所述第一内存空间为所述物理内存中的一块存储区域,所述第一内存空间包括至少一种大于4K的物理页;分配单元,用于根据所述第一进程对所述物理内存的需求,从所述确定单元确定的所述目标进程组所对应的第一内存空间中为所述第一进程分配物理页。
- 根据权利要求8所述的装置,其特征在于,分配单元用于:检测所述第一内存空间中处于空白状态的物理页;若所述处于空白状态的物理页的类型不满足所述第一进程对所述物理内存的需求,则将所述第一内存空间中处于空白状态的物理页中第一类型的物理页转换为第二类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同;为所述第一进程分配所述第二类型的物理页。
- 根据权利要求8所述的装置,其特征在于,所述装置还包括第一处理单元,所述第一处理单元用于:监测所述第一内存空间中处于空白状态的各类型物理页的数量;当第一类型的物理页的数量低于对应的阈值时,将部分第二类型的物理页转换为所述第一类型的物理页,所述第二类型的物理页的大小与所述第一类型的物理页的大小不同。
- 根据权利要求8-10任一项所述的装置,其特征在于,所述装置还包括回收单元,所述回收单元用于:当所述目标进程组所绑定的进程都运行结束后,所述第一内存空间中的每个物理页都处于空闲状态,则解绑所述第一内存空间与所述目标进程组的对应关系;释放所述第一内存空间。
- 根据权利要求11所述的装置,其特征在于,所述回收单元用于:将所述第一内存空间中物理页恢复到分配所述第一内存空间时的初始状态;释放恢复到所述初始状态的所述第一内存空间。
- 根据权利要求8-12任一项所述的装置,其特征在于,所述装置还包括第二处理单元,所述第二处理单元用于:创建所述目标进程组,建立所述目标进程组与所述第一内存空间的对应关系;配置所述目标进程组所绑定的进程。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-7任一项所述的方法。
- 一种计算设备,其特征在于,包括处理器和存储有计算机程序的计算机可读存储介质;所述处理器与所述计算机可读存储介质耦合,所述计算机程序被所述处理器执行时实现如权利要求1-7任一项所述的方法。
- 一种芯片系统,其特征在于,包括处理器,所述处理器被调用用于执行如权利要求1-7任一项所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110313871.9A CN115129459A (zh) | 2021-03-24 | 2021-03-24 | 一种内存管理的方法及设备 |
CN202110313871.9 | 2021-03-24 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022199560A1 true WO2022199560A1 (zh) | 2022-09-29 |
Family
ID=83374627
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/082140 WO2022199560A1 (zh) | 2021-03-24 | 2022-03-22 | 一种内存管理的方法及设备 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115129459A (zh) |
WO (1) | WO2022199560A1 (zh) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5617554A (en) * | 1992-02-10 | 1997-04-01 | Intel Corporation | Physical address size selection and page size selection in an address translator |
CN102375947A (zh) * | 2010-08-16 | 2012-03-14 | 伊姆西公司 | 用于隔离计算环境的方法和系统 |
CN103257929A (zh) * | 2013-04-18 | 2013-08-21 | 中国科学院计算技术研究所 | 一种虚拟机内存映射方法及系统 |
CN105468542A (zh) * | 2014-09-03 | 2016-04-06 | 杭州华为数字技术有限公司 | 地址分配方法及装置 |
CN105518631A (zh) * | 2014-08-08 | 2016-04-20 | 华为技术有限公司 | 内存管理方法、装置和系统、以及片上网络 |
CN111078407A (zh) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | 内存管理的方法、装置、存储介质及电子设备 |
CN111316244A (zh) * | 2018-12-28 | 2020-06-19 | 深圳市大疆创新科技有限公司 | 多进程间的通信方法和系统 |
-
2021
- 2021-03-24 CN CN202110313871.9A patent/CN115129459A/zh active Pending
-
2022
- 2022-03-22 WO PCT/CN2022/082140 patent/WO2022199560A1/zh active Application Filing
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5617554A (en) * | 1992-02-10 | 1997-04-01 | Intel Corporation | Physical address size selection and page size selection in an address translator |
CN102375947A (zh) * | 2010-08-16 | 2012-03-14 | 伊姆西公司 | 用于隔离计算环境的方法和系统 |
CN103257929A (zh) * | 2013-04-18 | 2013-08-21 | 中国科学院计算技术研究所 | 一种虚拟机内存映射方法及系统 |
CN105518631A (zh) * | 2014-08-08 | 2016-04-20 | 华为技术有限公司 | 内存管理方法、装置和系统、以及片上网络 |
CN105468542A (zh) * | 2014-09-03 | 2016-04-06 | 杭州华为数字技术有限公司 | 地址分配方法及装置 |
CN111316244A (zh) * | 2018-12-28 | 2020-06-19 | 深圳市大疆创新科技有限公司 | 多进程间的通信方法和系统 |
CN111078407A (zh) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | 内存管理的方法、装置、存储介质及电子设备 |
Also Published As
Publication number | Publication date |
---|---|
CN115129459A (zh) | 2022-09-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3706394A1 (en) | Writes to multiple memory destinations | |
US10740016B2 (en) | Management of block storage devices based on access frequency wherein migration of block is based on maximum and minimum heat values of data structure that maps heat values to block identifiers, said block identifiers are also mapped to said heat values in first data structure | |
EP3073374B1 (en) | Thread creation method, service request processing method and related device | |
JP5510556B2 (ja) | 仮想マシンのストレージスペースおよび物理ホストを管理するための方法およびシステム | |
US8478926B1 (en) | Co-processing acceleration method, apparatus, and system | |
EP3211530B1 (en) | Virtual machine memory management method, physical main machine, pcie device and configuration method therefor, and migration management device | |
CN104461735B (zh) | 一种虚拟化场景下分配cpu资源的方法和装置 | |
CN111090521B (zh) | 内存分配方法、装置、存储介质及电子设备 | |
US11231852B2 (en) | Efficient sharing of non-volatile memory | |
US20230168953A1 (en) | Inter-process communication method and apparatus | |
CN112650558B (zh) | 数据处理方法、装置、可读介质和电子设备 | |
CN113204407B (zh) | 一种内存超配管理方法及装置 | |
US8352702B2 (en) | Data processing system memory allocation | |
CN113760560A (zh) | 一种进程间通信方法以及进程间通信装置 | |
WO2023030178A1 (zh) | 一种基于用户态协议栈的通信方法及相应装置 | |
US8751724B2 (en) | Dynamic memory reconfiguration to delay performance overhead | |
KR102326280B1 (ko) | 데이터 처리 방법, 장치, 기기 및 매체 | |
US9772776B2 (en) | Per-memory group swap device | |
WO2022199560A1 (zh) | 一种内存管理的方法及设备 | |
CN106537321B (zh) | 存取文件的方法、装置和存储系统 | |
CN113918087B (zh) | 存储装置以及用于管理存储装置中的命名空间的方法 | |
Lee et al. | Compressed and shared swap to extend available memory in virtualized consumer electronics | |
CN112947863A (zh) | 一种飞腾服务器平台下存储空间合并成的方法 | |
KR20150048028A (ko) | 데이터 전송 관리 방법 | |
US20120011330A1 (en) | Memory management apparatus, memory management method, program therefor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22774217 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22774217 Country of ref document: EP Kind code of ref document: A1 |