Search

CN-121996400-A - Memory management method, system, device, program product and storage medium

CN121996400ACN 121996400 ACN121996400 ACN 121996400ACN-121996400-A

Abstract

The specification provides a memory management method, a system, equipment, a program product and a storage medium, wherein the method is applied to a management function for managing a private memory pool, the private memory pool is used by a private process, the management function is used for replacing a transparent large page function in an operating system in the running process of the operating system, the method comprises the steps of receiving a call request for representing that a current process in running needs to use the transparent large page, responding to the call request, and providing the transparent large page function for the current process through the private memory pool if the current process is determined to be the private process.

Inventors

  • ZHENG HAO

Assignees

  • 阿里云计算有限公司

Dates

Publication Date
20260508
Application Date
20241107

Claims (15)

  1. 1. The memory management method is applied to a management function for managing a private memory pool, wherein the private memory pool is used by a private process, the management function is used for replacing a transparent large page function in an operating system in the running process of the operating system, and the method comprises the following steps: Receiving a call request for representing that a transparent large page is required to be used by a current process in running; And responding to the call request, and if the current process is determined to be the private process, providing a transparent large page function for the current process through the private memory pool.
  2. 2. The method of claim 1, wherein if the current process is determined to be the private process, providing, by the private memory pool, a transparent page function for the current process, comprising: Creating process metadata, wherein the process metadata is used for storing a private process structure body of the private process, and the private process structure body records a process name of the private process; after acquiring a kernel process structure body of the current process in the operating system, acquiring a process name of the current process from the kernel process structure body; If the private process structure body for recording the process name of the current process exists in the process metadata, determining that the current process is the private process, and providing a transparent large page function for the current process through the private memory pool; The method further comprises the steps of: If the private process structure body for recording the process name of the current process does not exist in the process metadata, determining whether to call a transparent large page function of the operating system or not so as to determine whether to provide the transparent large page function for the current process through the transparent large page function.
  3. 3. The method of claim 1, wherein the providing, by the private memory pool, the transparent page function for the current process comprises: If the fact that the target memory big page which can be allocated to the current process exists in the private memory pool is determined, the target memory big page is returned to a calling party which initiates the calling request; The method further comprises the steps of: if it is determined that the large memory page which can be allocated to the current process does not exist in the private memory pool, determining whether to call a transparent large page function of the operating system or not, and determining whether to provide the transparent large page function for the current process through the transparent large page function.
  4. 4. The method according to claim 3, wherein if it is determined that there is a target memory big page in the private memory pool that can be allocated to the current process, returning the target memory big page to the caller that initiated the call request includes: Creating an array, wherein each element in the array is used for storing the storage address of a page structure body of each memory big page; Creating a bitmap, wherein the bitmap characterizes the allocation state of each memory big page in the private memory pool; If the unallocated target memory big page exists in the bitmap, setting the allocation state of the target memory big page as allocated in the bitmap, and after the storage address of the page structure of the target memory big page is inquired from the array, returning the inquired storage address to a calling party initiating the call request.
  5. 5. The method of claim 4, wherein the private process structure is further configured to record a number of large pages of memory that have been used by a process, wherein the private memory pool corresponds to a memory pool structure configured to record a number of large pages of memory that have been used by the private memory pool, wherein the page structure has spare bits therein, and wherein the method further comprises: Adding 1 to the number of large pages of the memory used by the process recorded in the process structure item of the current process; Adding 1 to the number of the large memory pages recorded in the memory pool structure body; And recording the identification of the private process structure body of the current process in the idle bit of the page structure body of the large page of the target memory.
  6. 6. The method of claim 5, the method further comprising: Responding to a release request of a large page of a memory to be released, and acquiring a storage address of a page structure of the large page of the memory to be released from the release request; inquiring whether a target element for recording a storage address of a page structure body of the large page of the memory to be released exists in the array; if yes, clearing the large page of the memory to be released corresponding to the target element, and clearing after analyzing the target mark recorded in the idle bit of the page structure of the large page of the memory to be released; Based on the target identifier, a corresponding target private process structure body is searched from the process metadata, and the number of large pages of the memory used by the process recorded in the target private process structure body is reduced by 1; subtracting 1 from the number of large memory pages recorded in the memory pool structure; and setting the allocation state corresponding to the large page of the memory to be released, which is recorded in the bitmap, as unallocated.
  7. 7. The method of claim 1, the method further comprising: Providing a size setting interface for setting the memory size of the private memory pool; And responding to the current expected size of the private memory pool received through the size setting interface, and adjusting the number of memory pages contained in the private memory pool based on the current actual size of the private memory pool and the current expected size.
  8. 8. The method of claim 1, wherein the management function comprises an allocation function of a private memory pool and a release function of the private memory pool, and wherein the transparent large page function comprises a memory allocation function, a memory release function, and a memory space for scanning a process to determine whether the process needs to use a transparent large page of the scanning function; The memory allocation function is replaced by the allocation function of the private memory pool, the memory release function is replaced by the release function of the private memory pool, and the information of the private process is added in a scan list of the scan function.
  9. 9. The method of claim 1, wherein the private memory pool is allocated from the memory by the operating system based on a set size within a preset duration after the physical machine is started.
  10. 10. The method of claim 9, the method further comprising: The method comprises the steps of determining that a free memory big page to be recycled in a private memory pool needs to be recycled, triggering a virtualization layer to execute recycling operation, switching an operating system from a root mode to a virtualization mode by the virtualization layer to enable the operating system to be switched to a client operating system, inquiring the free memory big page to be recycled from the private memory pool, processing page table entries corresponding to the memory big page to be recycled to enable the memory big page to be recycled by the virtualization layer, and if the virtualization layer receives page shortage abnormality triggered by the client operating system using the recycled memory big page of the private memory pool, distributing a new physical page and establishing a page table mapping with the recycled memory big page to enable the client operating system to use the new physical page based on the page table mapping.
  11. 11. A memory management method is applied to an operating system, wherein the operating system comprises a transparent large page function, and the method comprises the following steps: determining a management function for managing the private memory pool; During operation, the transparent large page function is replaced by the management function, so that when the current process running in the operating system needs to use the transparent large page, the method of any one of claims 1 to 10 is executed by the management function.
  12. 12. An operating system in a physical machine for performing the method of claim 11.
  13. 13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method of any one of claims 1 to 11 when the computer program is executed by the processor.
  14. 14. A computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any one of claims 1 to 11.
  15. 15. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of claims 1 to 11.

Description

Memory management method, system, device, program product and storage medium Technical Field The present disclosure relates to the field of operating systems, and in particular, to a memory management method, system, device, program product, and storage medium. Background Conventional operating systems such as Linux are provided with transparent large page (TRANSPARENT HUGE PAGES, THP) functionality, which allows multiple normal pages to be consolidated into one larger page, thereby reducing associated translation look-aside buffer (Translation Lookaside Buffer, TLB) misses. This means that the address map can be found faster when accessing the memory, thereby improving performance. The THP comprises khuged functions for triggering and using the THP or not, the processes which can be scanned by the khuged functions are often processes with page fault abnormality, however, the probability of triggering the page fault abnormality by the processes which run for a long time and are stable in an operating system is low, so that the processes are difficult to use the THP functions. Disclosure of Invention To overcome the problems in the related art, the present specification provides a memory management method, system, apparatus, program product, and storage medium. According to a first aspect of embodiments of the present disclosure, there is provided a memory management method, where the method is applied to a management function for managing a private memory pool, where the private memory pool is used by a private process, the management function is used to replace a transparent large page function in an operating system during a running process of the operating system, and the method includes: Receiving a call request for representing that a transparent large page is required to be used by a current process in running; And responding to the call request, and if the current process is determined to be the private process, providing a transparent large page function for the current process through the private memory pool. According to a second aspect of embodiments of the present specification, the method is applied to an operating system, the operating system including a transparent big page function, the method comprising: determining a management function for managing the private memory pool; and in the running process, replacing the transparent large page function with the management function, so that when the current process running in the operating system needs to use the transparent large page, the management function executes the steps of the method in the first aspect. According to a third aspect of embodiments of the present specification, there is provided an operating system for performing the method of the second aspect. According to a fourth aspect of embodiments of the present specification, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the method embodiments of the first or second aspect are implemented when the computer program is executed by the processor. According to a fifth aspect of embodiments of the present specification, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of an embodiment of the method of the first or second aspect described above. According to a sixth aspect of embodiments of the present specification, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the steps of an embodiment of the method of the first or second aspect described above. The technical scheme provided by the embodiment of the specification can comprise the following beneficial effects: In the embodiment of the specification, a private memory pool special for a specific private process is designed, and a new management function which can enable the private process to use a transparent large page function based on the private memory pool is designed; because the operating system itself has the transparent large page function to provide the transparent large page function, in the running process of the operating system, the transparent large page function in the operating system is replaced by the management function of the embodiment, so that when the management function is called, whether the current process needing to use the transparent large page is a private process can be determined, and if so, the transparent large page function is provided for the current process through the private memory pool. Therefore, the embodiment can ensure that the specific private process can use the transparent large page function. It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. Drawings Fig. 1A is