Memory management method and device and storage medium
By dynamically adjusting memory groups in the NUMA architecture and reallocating memory groups according to the cross-group memory access request popularity of physical memory pages, the problem of frequent memory access across nodes in the NUMA architecture is solved and memory access efficiency is improved.
Patent Information
- Application Number
- PCT/CN2024/113899
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-22
- Filing Date
- 2024-08-22
- Publication Date
- 2025-03-27
AI Technical Summary
In the NUMA architecture, memory access across nodes occurs frequently, affecting memory access efficiency.
By presetting multiple memory groups on the physical machine, count the cross-group memory access request heat of the target physical memory page. If the heat exceeds the specified criteria, the memory group belonging to is re-determined for the target physical memory page and allocated to the re-determined memory group.
By dynamically scheduling physical memory pages to more suitable memory groups, the proportion of cross-group memory access on the physical machine is reduced and memory access efficiency is improved.
Smart Images

Figure CN2024113899_27032025_PF_FP_ABST
Abstract
Description
Memory management method, device and storage medium
[0001] This disclosure claims priority to application number 202311235255.1, filed with the China Patent Office on September 22, 2023, entitled “A memory management method, device and storage medium,” the entire contents of which are incorporated by reference into this disclosure. Technical Field
[0002] The present disclosure relates to the field of computer technology, and in particular to a memory management method, device, and storage medium. Background Art
[0003] NUMA (Non-Uniform Memory Access) is an architectural model for how multiple processor cores access physical memory. In a NUMA architecture, physical memory is divided into multiple NUMA nodes, each of which contains a set of processor cores and local memory. In a NUMA architecture, each node has its own local memory, and the connection between local memory and processor cores is faster, which means that processor cores can access the memory of the local node more quickly. Memory access to other nodes, however, requires a slower interconnect structure.
[0004] To improve physical memory utilization, the NUMA architecture supports memory swapping (SWAP). This means that local memory within a NUMA node can be temporarily swapped out for use on other NUMA nodes. This often results in cross-node memory accesses, impacting memory access efficiency.
[0005] Summary of the Invention
[0006] Various aspects of the present disclosure provide a memory management method, device, and storage medium for improving memory access efficiency under a memory grouping architecture.
[0007] The present disclosure provides a memory management method. A physical machine is pre-set with multiple memory groups, each of which contains physical memory pages. The method includes:
[0008] In response to a management instruction for a target physical memory page, counting the heat of cross-group memory access requests on the target physical memory page in a current statistical period;
[0009] If the cross-group memory access request heat exceeds the specified standard, the memory group to which the target physical memory page belongs is re-determined;
[0010] Allocate the target physical memory page to the newly determined memory group.
[0011] Re-determine the memory group to which the target physical memory page belongs, including:
[0012] Determine the source memory group corresponding to each cross-group memory access request monitored on the target physical memory page within the current statistical period;
[0013] For each determined source memory group, count the number of cross-group memory access requests corresponding to the target physical memory page in the current statistical period;
[0014] The source memory group whose number of cross-group memory access requests meets the specified condition is used as the memory group to be re-determined for the target physical memory page.
[0015] The specified conditions include: the maximum number of cross-group memory access requests.
[0016] Preferably, the method further comprises:
[0017] Set multiple sampling periods within the current statistical period;
[0018] When the target sampling period starts, the access flag in the page table entry where the target physical memory page is located is cleared, so that an access fault is triggered when an access request for the target physical memory page occurs within the target sampling period.
[0019] If an access fault is received for the target physical memory page within the target sampling period, identifying a source memory group corresponding to the access request that triggers the access fault from the access fault;
[0020] If the identified source memory group is inconsistent with the memory group to which the target physical memory page currently belongs, it is determined that a cross-group memory access request has been detected;
[0021] The target sampling period is any one of the multiple sampling periods.
[0022] The cross-group memory access request heat of the target physical memory page is counted in the current statistical period, including:
[0023] Based on the access faults received in the current statistical period, the total number of access requests corresponding to the target physical memory page in the current statistical period and the total number of cross-group memory access requests are counted;
[0024] The ratio of the total number of cross-group memory access requests to the total number of access requests is calculated as the cross-group memory access request heat.
[0025] Preferably, the method further comprises:
[0026] After completing the identification operation within the target sampling period, adding an access identifier to the target page table entry used by the access request that triggered the access fault;
[0027] Trigger access request to continue execution;
[0028] Wherein, based on the added access identifier, the access request that continues to be executed and the subsequent access request initiated by using the target page table entry within the target sampling period no longer trigger an access fault.
[0029] Preferably, the method further comprises:
[0030] If the cross-group memory access request popularity exceeds the specified standard, after the current statistical period ends, a designated physical memory page is selected from the memory group to which the target physical memory page currently belongs to replace the target physical memory page.
[0031] The designated physical memory page is used to respond to access requests subsequently initiated in the memory group to which the target physical memory page currently belongs, which originally need to be responded to by the target physical memory page.
[0032] The method further comprises: using the designated physical memory page to respond to a subsequent access request initiated in the memory group to which the target physical memory page currently belongs, which originally needs to be responded to by the target physical memory page, including:
[0033] Find the page table entries used by each memory access request within the group monitored on the target physical memory page during the current statistical period;
[0034] Clearing the access identifier associated with the target physical memory page in each page table entry found, so that an access request for the target physical memory page initiated based on each page table entry found can trigger an access fault;
[0035] In the process of handling the access failure, the physical address of the target physical memory page in the corresponding page table entry is replaced with the physical address corresponding to the specified physical memory page;
[0036] After the replacement operation is completed, an access identifier is added to the corresponding page table entry for the specified physical memory page;
[0037] The access request that triggered the completed access fault processing continues to be executed to respond to the access request in the same manner as the memory access within the group.
[0038] Specifically, when the target physical memory page is mapped to the virtual machine memory space, the method is applicable to the virtual machine manager on the physical machine; when the target physical memory page is not mapped to the virtual machine memory space, the method is applicable to the memory management unit on the physical machine.
[0039] Specifically, the memory group uses NUMA nodes or CPU sockets as the memory grouping unit.
[0040] An embodiment of the present disclosure also provides a physical machine, including a memory and a processor, the memory provides physical memory pages, a plurality of memory groups are preset on the physical machine, the memory groups contain physical memory pages, the memory access rate within the group is higher than the memory access rate across groups, the memory is used to store one or more computer instructions; the processor is coupled to the memory, and is used to execute one or more computer instructions, so as to execute the aforementioned memory management method.
[0041] The embodiment of the present disclosure further provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the aforementioned memory management method.
[0042] In an embodiment of the present disclosure, for each physical memory page that is pre-divided into a memory group on a physical machine, the heat of cross-group memory access requests of the physical memory page within a period of time can be counted during memory use. If the heat of the cross-group memory access request exceeds a specified standard, the memory group to which the physical memory page belongs is re-determined, and the physical memory page is allocated to the re-determined memory group. In this way, the cross-group memory access request situation on the physical memory page can be sensed during the use of the physical memory page, and the physical memory page can be dynamically scheduled to a more appropriate memory group based on the cross-group memory access request situation on the physical memory page. By dynamically scheduling each physical memory page, dynamic adjustment of the physical memory pages in each memory group on the physical machine can be achieved, thereby reducing the proportion of cross-group memory access on the physical machine, and thus improving memory access efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0044] FIG1 is a flow chart of a memory management method provided by an exemplary embodiment of the present disclosure;
[0045] FIG2 is a logical diagram of a memory management method provided by an exemplary embodiment of the present disclosure;
[0046] FIG3 is a flow chart of another memory management method provided by an exemplary embodiment of the present disclosure;
[0047] FIG4 is a flow chart of a memory management method provided by an exemplary embodiment of the present disclosure;
[0048] FIG5a is a schematic diagram of a logic scheme in an exemplary application scenario provided by an exemplary embodiment of the present disclosure;
[0049] FIG5 b is a schematic diagram of a time period setting scheme in an exemplary application scenario provided by an exemplary embodiment of the present disclosure;
[0050] FIG6 is a schematic structural diagram of a physical machine provided by another exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0051] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.
[0052] Before introducing the technical solutions provided by the various embodiments of the present disclosure, several technical concepts involved in the present disclosure are briefly described as follows.
[0053] NUMA (Non-Uniform Memory Access): In a NUMA architecture, physical memory is divided into multiple nodes, each of which contains a set of processor cores and local memory. In a NUMA architecture, each node has its own local memory, and the connection between the memory and the processor cores in the same node is faster. This means that the processor core can access the memory in its own node faster, while memory access to other nodes must be carried out through a slower interconnect structure (such as a network connection).
[0054] Memory swapping (SWAP) is a technology that copies infrequently used physical memory pages to external storage areas such as disks and releases physical memory pages to increase system available memory.
[0055] The technical solutions provided by various embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0056] Figure 1 is a flow chart of a memory management method provided by an exemplary embodiment of the present disclosure, which is applicable to a physical machine. Figure 2 is a logic diagram of a memory management method provided by an exemplary embodiment of the present disclosure. Referring to Figure 2, a physical machine in this embodiment is pre-set with multiple memory groups.
[0057] The memory management method provided in this embodiment can be applied to various memory grouping architectures. In different memory grouping architectures, the memory grouping units used may be different. For example, the memory group in this embodiment can use the aforementioned NUMA node as the memory grouping unit, that is, the physical memory pages on the physical machine can be pre-divided into NUMA nodes. Of course, the memory group in this embodiment can also use other memory grouping units, such as CPU sockets (Socket), core chiplets CCD (Core Chiplet Die) or processor module units CCX (CPU Complex), etc. This embodiment does not limit the memory grouping units used. For example, when the CPU socket is used as the memory grouping unit, the physical memory pages can be divided into the CPU socket. In this way, a memory group will contain all the processor cores in the corresponding CPU socket and the physical memory pages allocated to the memory group.
[0058] Referring to Figure 2, the memory group in this embodiment may contain physical memory pages. Generally, the memory access rate within a group is higher than the memory access rate across groups. The specific implementation logic of memory access within a group and memory access across groups will not be described in detail here. You can refer to the background knowledge of various memory grouping architectures (such as the aforementioned NUMA architecture) for details. This embodiment assumes that the memory grouping architecture has this property.
[0059] Currently, in various memory grouping architectures, the memory grouping scheme is basically determined during the architecture initialization process. During the subsequent memory usage, the initialized memory grouping scheme will remain unchanged. That is, the physical memory pages contained in each memory group remain unchanged to maintain the speed advantage of memory access within the group.
[0060] During their research, the inventors discovered that, to improve memory utilization, memory grouping architectures often incorporate the aforementioned memory swapping technology. This results in physical memory pages within a memory group being frequently swapped out. These swapped-out physical memory pages can then be accessed by processor cores in other memory groups. However, processor cores in other memory groups must access these swapped-out physical memory pages through cross-group memory access. Consequently, cross-group memory accesses frequently occur in memory grouping architectures, impacting memory access efficiency.
[0061] To this end, this embodiment proposes an innovative memory management method to improve memory access efficiency under a memory grouping architecture.
[0062] Referring to FIG1 , the method may include:
[0063] Step 100: In response to a management instruction for a target physical memory page, count the heat of cross-group memory access requests on the target physical memory page in a current statistical period;
[0064] Step 101: If the heat of the cross-group memory access request exceeds a specified standard, re-determine the memory group to which the target physical memory page belongs;
[0065] Step 102: Allocate the target physical memory page to the re-determined memory group.
[0066] The memory management method provided in this embodiment can support both virtualized and non-virtualized scenarios. In a virtualized scenario, physical memory pages will be allocated for use by virtual machines on a physical machine, that is, physical memory pages will be mapped to the virtual machine's memory space. In this case, the memory management method provided in this embodiment can be applied to the virtual machine manager (VMM) on the physical machine. In a non-virtualized scenario, physical memory pages will be allocated for use by applications on the physical machine, that is, physical memory pages will be mapped to the virtual address space of the physical machine. In this case, the memory management method provided in this embodiment can be applied to the memory management unit (MM) on the physical machine. It should be understood that some physical memory pages on a physical machine may be used for virtualized scenarios and some for non-virtualized scenarios. In this case, the two portions of physical memory pages can be memory managed by different execution entities. That is, the portion of physical memory pages used in the virtualized scenario is managed by the virtual machine manager according to the memory management method provided in this embodiment, while the portion of physical memory pages used in the non-virtualized scenario is managed by the memory management unit according to the memory management method provided in this embodiment. In this way, the two scenarios can coexist on one physical machine, and the memory management solution provided in this embodiment does not conflict with each other in the two scenarios.
[0067] Referring to Figure 1, in step 100, in response to a management instruction for a target physical memory page, the popularity of cross-group memory access requests on the target physical memory page can be counted within the current statistical period. The management instruction in this embodiment can be automatically triggered on a scheduled basis. For example, a management period can be set, and the management instruction is automatically triggered when the management period is reached. The management period can be one hour or one day, and can be set according to actual needs. For another example, several management start times can be set, and the management instruction can be automatically triggered when the management start time is reached. The management start times can be 1:00, 3:00, and 5:00 every day, and can also be set according to actual needs. No further examples of automatic triggering timing are provided here. Of course, the management instruction in this embodiment can also be triggered on demand. For example, a staff member can manually trigger the management instruction as needed. No further examples of on-demand triggering are provided here. In addition, in this embodiment, the triggering timing of management instructions on different physical memory pages may not be exactly the same.
[0068] For ease of description, the memory management solution is described in this embodiment from the perspective of a target physical memory page. It should be understood that the target physical memory page can be any physical memory page on the physical machine.
[0069] The statistical period mentioned in step 100 can be a specified period of time, the length of which can be set as needed, and in response to the different triggering methods of the management instructions mentioned above, the lengths of different statistical periods can be the same or different. In this way, the heat of cross-group memory access requests within a period of time can be counted for the target physical memory page in step 100. Among them, the heat of cross-group memory access requests is used to reflect the comparison between the cross-group memory access requests and the intra-group memory access requests received on the target physical memory page during the statistical period. The heat of cross-group memory access requests in this embodiment can be characterized in the form of cross-group memory access request ratio or cross-group memory access request frequency. Among them, the cross-group memory access request ratio can refer to the proportion of cross-group memory access requests received on the target physical memory page during the statistical period in all the access requests it receives; the cross-group memory access request frequency can refer to the ratio between the number of cross-group memory access requests received on the target physical memory page during the statistical period and the length of the statistical period.
[0070] In this embodiment, a cross-group memory access request refers to an access request to a target physical memory page initiated by a processor core that is not in the same memory group as the target physical memory page. As mentioned above, the response rate for cross-group memory access requests is generally much lower than the response rate for intra-group memory access requests.
[0071] Continuing to refer to Figure 1, in step 101, if the heat of the cross-group memory access request exceeds the specified standard, the memory group to which the target physical memory page belongs is re-determined. Among them, the specified standard can be set according to actual needs. For example, if the cross-group memory access request ratio is used to characterize the heat of the cross-group memory access request, the specified standard can be preset to a ratio threshold. In this way, if the cross-group memory access request ratio counted for the target physical memory page in step 100 exceeds the ratio threshold, it can be determined that the heat of the cross-group memory access request exceeds the specified standard. For another example, if the cross-group memory access request frequency is used to characterize the heat of the cross-group memory access request, the specified standard can be preset to exceed a specified frequency threshold and be greater than the memory access request frequency within the group. In this way, if the cross-group memory access request frequency counted for the target physical memory page in step 100 exceeds the specified frequency threshold and is greater than the memory access request frequency within the group, it can be determined that the heat of the cross-group memory access request exceeds the specified standard. Here, if the cross-group memory access request heat exceeds the specified standard, it indicates that the target physical memory has a low demand for access by the processor cores in the group, but a higher demand for access by the processor cores in other memory groups. Based on this, in step 101, a more suitable memory group can be found for the target physical memory page.
[0072] In this embodiment, a variety of implementation methods can be used to redetermine the memory group to which the target physical memory page belongs. The specific implementation methods will be exemplified later and will not be described in detail here. Through step 101, when the heat of cross-group memory access requests exceeds a specified standard, a more appropriate memory group can be redetermined for the target physical memory page. It should be understood that the redetermined memory group will usually no longer be the memory group to which the target physical memory page currently belongs.
[0073] As can be seen, in this embodiment, in steps 100 and 101, the cross-group memory access request heat index is introduced. Based on this index, the concept of dynamically adjusting the memory group to which the target physical memory page belongs is further proposed. This breaks the current technical understanding that the memory grouping scheme must remain unchanged in the memory grouping architecture. From the perspective of the overall memory grouping architecture, in this embodiment, the physical memory pages contained in each memory group can be dynamically scheduled.
[0074] On this basis, if the heat of the cross-group memory access request exceeds the specified standard, at least two aspects of processing can be performed in step 102: on the one hand, the intra-group memory access relationship between the target physical memory page and the processor core in the memory group to which it currently belongs can be disconnected. On the other hand, an intra-group memory access relationship between the target physical memory page and the processor core in the memory group to which it is reallocated can be established. In this way, the target physical memory page will be called the local memory in the memory group to which it is reallocated, and a higher response rate can be provided for the access requests occurring in the memory group to which it is reallocated. From the perspective of the memory group to which the target physical memory page is reallocated, the processes in it that originally needed to access the target physical memory page through cross-group memory access can now complete the access to the target physical memory page through intra-group memory access, and the access efficiency is greatly improved.
[0075] In this embodiment, after completing the current scheduling management for the target physical memory page based on the current statistical cycle, the target physical memory page can be scheduled again in the next statistical cycle. By implementing multiple statistical cycles, dynamic scheduling of the target physical memory page can be achieved. Other physical memory pages on the physical machine can also be dynamically scheduled according to the same technical logic. This allows physical memory pages with relatively low utilization within each memory group to be scheduled to a more appropriate memory group, thereby effectively reducing cross-group memory access.
[0076] In addition, this embodiment can also support automatic scaling of memory groups. The affinity between memory groups and physical memory pages is introduced as a scheduling reference for automatic scaling. To this end, in a further improved solution:
[0077] After the target physical memory page is allocated to the re-determined memory group, the affinity between it and the target physical memory page can be updated under the re-determined memory group according to the preset accumulation rule. Among them, an exemplary accumulation rule can be that each time it is allocated to the memory group, the affinity is increased by 1. In this way, the affinity between the relevant physical memory page can be monitored separately under each memory group. It should be understood that the affinity here can be used to reflect the access preference of the memory group to the physical memory page.
[0078] On this basis, when a memory group needs to be expanded, the affinity between the memory group and the physical memory pages outside the group can be checked, and the physical memory pages with higher affinity among the physical memory pages outside the group are preferentially selected for memory expansion.
[0079] In this way, when the memory group is expanded, the physical memory pages preferred by the memory group can be rescheduled back to the memory group, thereby effectively ensuring the memory access performance in the expanded memory group.
[0080] In summary, in this embodiment, for each physical memory page that is pre-divided into a memory group on the physical machine, the heat of cross-group memory access requests of the physical memory page within a period of time can be counted during the use of the memory. If the heat of the cross-group memory access request exceeds the specified standard, the memory group to which the physical memory page belongs is re-determined, and the physical memory page is allocated to the re-determined memory group. In this way, the cross-group memory access request situation on the physical memory page can be perceived during the use of the physical memory page, and the physical memory page can be dynamically scheduled to a more appropriate memory group based on the cross-group memory access request situation on the physical memory page. By dynamically scheduling each physical memory page, dynamic adjustment of the physical memory pages in each memory group on the physical machine can be achieved, thereby reducing the proportion of cross-group memory access on the physical machine, and thus improving memory access efficiency.
[0081] FIG3 is a flow chart of another memory management method provided by an exemplary embodiment of the present disclosure. Referring to FIG3 , the method may include:
[0082] Step 300: In response to a management instruction for a target physical memory page, count the heat of cross-group memory access requests on the target physical memory page in a current statistical period;
[0083] Step 301: If the heat of cross-group memory access requests exceeds a specified standard, determine the source memory group corresponding to each cross-group memory access request monitored on the target physical memory page within the current statistical period;
[0084] Step 302: For each determined source memory group, count the number of cross-group memory access requests corresponding to the target physical memory page within the current statistical period;
[0085] Step 303: The source memory group whose number of cross-group memory access requests meets a specified condition is used as the memory group to be re-determined for the target physical memory page;
[0086] Step 304: Allocate the target physical memory page to the re-determined memory group.
[0087] Wherein, step 300 and step 304 can refer to the relevant description of the above embodiment, which will not be repeated here. In this embodiment, based on steps 301 to 303, an implementation method for re-determining the memory group to which the target physical memory page belongs is provided.
[0088] Referring to Figure 3, in this implementation, in step 301, cross-group memory access requests on the target physical memory page can be monitored during the current statistical period, and the source memory group corresponding to each monitored cross-group memory access request can be obtained. The source memory group refers to the memory group where the processor core used by the requesting party, such as the process or thread that initiates the cross-group memory access request, is located.
[0089] It should be understood that, in actual applications, cross-group memory access requests on the target physical memory may come from multiple different source memory groups, while a single source memory group may issue multiple cross-group memory access requests to the target physical memory page within the current statistical period. To this end, in this implementation, in step 302, the number of cross-group memory access requests issued by each source memory group determined in step 301 to the target physical memory page within the current statistical period can be counted separately. Among them, the number of cross-group memory access requests can reflect the access requirements of the corresponding source memory group to the target physical memory page.
[0090] On this basis, in step 303, the source memory group whose number of cross-group memory access requests meets the specified condition can be used as the memory group re-determined for the target physical memory page. In one scheme: from each source memory group determined in step 301, the source memory group that initiates the most cross-group memory access requests to the target physical memory page within the current statistical period can be found as the memory group re-determined for the target physical memory page. It can be understood that in this priority scheme, the specified condition can be understood as the maximum number of cross-group memory access requests issued to the target physical memory page within the current statistical period. That is, in this scheme, each source memory group that issues a cross-group memory access request to the target physical memory page within the current statistical period is compared, and specifically what is compared is the number of cross-group memory access requests initiated by these source memory groups to the target physical memory page within the current statistical period. Thus, in this scheme, the source memory group that has issued the most cross-group memory access requests to the target physical memory page during the current statistical period can be selected from the various source memory groups that have issued cross-group memory access requests to the target physical memory page, and used as the new memory group corresponding to the target physical memory page. As mentioned above, the number of cross-group memory access requests can reflect the access requirements of the corresponding source memory group to the target physical memory page. Therefore, in this scheme, the memory group with the highest cross-group memory access requirements to the target physical memory page can be used as the memory group re-determined for the target physical memory page.
[0091] Accordingly, in this implementation, the target physical memory page can be reallocated to a more appropriate memory group. After the reallocation is completed, the memory access request issued to the target physical memory page in the reallocated memory group will be responded to in the manner of intra-group memory access, and the response rate is greatly improved. Moreover, since the reallocated memory group originally initiated a large number of cross-group memory access requests to the target physical memory, this part of the cross-group memory access request number can be avoided in the reallocated memory group. From the perspective of the memory grouping architecture, the cross-group memory access request issued to the target physical memory page in the reallocated memory group can be avoided through dynamic scheduling of the target physical memory page, and the effect of reducing cross-group memory access requests can be achieved in almost all memory groups. Therefore, the proportion of cross-group memory access requests in the entire memory grouping architecture will be greatly reduced, and the overall memory access efficiency will be improved.
[0092] During the research process, the inventors found that both intra-group and cross-group memory access requests are imperceptible to the virtual manager or memory management unit on the physical machine, which brings difficulties to the implementation of step 301 in the above implementation method.
[0093] To this end, this implementation further proposes a solution for monitoring cross-group memory access requests on the target physical memory page. In an exemplary solution, the access identifier in the page table entry where the target physical memory page is located can be used to monitor cross-group memory access requests on the target physical memory page.
[0094] In this exemplary solution: multiple sampling periods can be set within the current statistical cycle; when the start time of the target sampling period is reached, the access identifier in the page table entry where the target physical memory page is located is cleared, so that an access fault is triggered when an access request for the target physical memory page occurs within the target sampling period; if an access fault is received for the target physical memory page within the target sampling period, the source memory group corresponding to the access request that triggered the access fault is identified from the access fault; if the identified source memory group is inconsistent with the memory group to which the target physical memory page currently belongs, it is determined that a cross-group memory access request is monitored; wherein the target sampling period is any one of the multiple sampling periods.
[0095] In actual applications, the current statistical period can be divided into multiple continuous sampling periods. Of course, multiple discontinuous sampling periods can also be set within the current statistical period. This embodiment does not limit the specifications, intervals, etc. of the sampling periods, and can be flexibly adjusted according to actual sampling accuracy requirements.
[0096] In this exemplary solution, the access flag (AF) mentioned is an existing concept in the field of memory management technology. The access flag is used to indicate whether the physical memory page in the page table entry has been accessed for the first time. If the physical memory page in the page table entry has not been accessed for the first time, there will be no access flag on it, and an access fault may be triggered when the first access occurs; if the physical memory page in the page table entry has been accessed for the first time, an access flag will be added to it. At present, the access flag is usually automatically maintained by the hardware on the physical machine (such as the memory manager MMU, Memory Management Unit), and the virtual machine manager or memory management unit on the physical machine is unaware of this. It only acts as a passive recipient of the access fault and handles the access fault.
[0097] This exemplary solution proposes that, in a virtualized scenario, the virtual machine manager participates in maintaining the access identifier; in a non-virtualized scenario, the memory management unit participates in maintaining the access identifier.
[0098] For ease of understanding, in this exemplary solution, the target sampling period is used as an example to describe a solution for monitoring cross-group memory access requests within a single sampling period. It should be understood that the same solution can be used to monitor cross-group memory access requests within other sampling periods.
[0099] In this exemplary solution, it is proposed that when the starting moment of the target sampling period is reached, the access identifier in the page table entry where the target physical memory page is located can be actively cleared. It should be noted here that at the same moment, there is usually only one page table entry where the target physical memory page is located. This is because through the aforementioned memory interaction technology, after the target physical memory page is swapped out, the physical address of the target physical memory page originally recorded in the corresponding page table entry will be deleted, and this type of page table entry will not be identified by this embodiment as a page table entry that requires access identifier clearing. Of course, if with the development of technology, at the same moment, there may be multiple page table entries where the target physical memory page is located, then in this embodiment, it can support clearing the access identifiers of all page table entries where the target physical memory page is located. In the field of memory management technology, the page table entries used by different applications are isolated from each other. Therefore, when multiple applications use the target physical memory page, different applications will use their own exclusive page table entries to access the target physical memory page.
[0100] Among them, in the virtualization scenario, the page table entry here refers to the page table entry that records the mapping relationship between the virtual machine physical memory address (GPA, Guest Physical Address) and the physical machine physical memory address (HPA, Host Physical Address). This is not limited to the memory virtualization technology used in the virtualization scenario. For example, the extended page table (EPT) mechanism can be used to implement memory virtualization. Of course, shadow page tables, nested paging, and other mechanisms can also be used to implement it. No limitation is made here, and no further examples are given. This embodiment can support various memory virtualization technologies. This is because, regardless of the memory virtualization technology, it is necessary to construct the aforementioned mapping relationship between GPA and HPA in order to achieve access to physical memory pages. In the virtualization scenario, two stages of address mapping are usually required: the virtual machine's operating system GUEST OS completes the mapping from GVA (Guest Virtual Address, virtual machine virtual memory address) to GPA; then the hardware such as MMU and / or IOMMU in the physical machine completes the mapping from GPA to HPA, and finally accesses the required physical memory page. In this exemplary solution, the virtual machine manager can proactively clear the access identifier recorded for the target physical memory page in the mapping relationship between the GPA and the HPA as needed during the subsequent address mapping phase. It should be understood that in a virtualized scenario, the virtual machine manager has the authority to maintain the mapping relationship between the GPA and the HPA, and therefore can seamlessly perform the access identifier clearing operation required in this embodiment.
[0101] In a non-virtualized scenario, the page table entry here refers to the page table entry that records the mapping relationship between the virtual address (VA) and the physical address (PA). In this exemplary solution, the memory management unit can proactively clear the access identifier recorded for the target physical memory page in the mapping relationship between VA and PA as needed. Similarly, in a non-virtualized scenario, the memory management unit has the authority to maintain the mapping relationship between VA and PA. Therefore, it can also perform the access identifier clearing operation required in this embodiment without any obstacles.
[0102] After completing the aforementioned access flag clearing operation for the target sampling period, if an access request for the target physical memory page occurs on the page table entry being operated on, it will be considered the first access to the target physical memory page, thereby triggering an access fault. In a virtualized scenario, an access fault will cause the virtual machine to exit. The virtual machine manager can intercept the access fault and perform access fault handling. Here, in addition to performing access fault handling in the conventional manner, the virtual machine manager also identifies the source memory bank corresponding to the access request that triggered the access fault. It should be understood that the virtual machine manager has a global view of each virtual machine and memory bank in the physical machine, and therefore can perform this identification operation without any obstacles. Similarly, in a non-virtualized scenario, the memory management unit can also intercept the access fault and identify the source memory bank corresponding to the access request that triggered the access fault. Furthermore, the virtual machine manager or memory management unit can also determine whether the identified source memory bank is consistent with the memory bank to which the target physical memory page currently belongs. If so, the corresponding access request is determined to be an intra-bank memory access request. If not, the corresponding access request is determined to be a cross-bank memory access request.
[0103] It should be understood that for the page table entry where the target physical memory page is located, the first access request for the target physical memory page occurring within the target sampling period will trigger an access fault. Therefore, within the target sampling period, if an access request for the target physical memory page occurs on the page table entry where the target physical memory page is located, then the access fault will be intercepted in this embodiment. In this way, the access faults intercepted in different sampling periods may be triggered by access requests initiated by different applications, and different applications may use different processor cores, and different processor cores may come from different memory groups. Therefore, by querying layer by layer, the source memory group corresponding to the access request that triggered the access fault can be identified, and intra-group memory access requests and cross-group memory access requests can be distinguished.
[0104] As can be seen, in this exemplary solution, cross-group memory access requests on the target physical memory page can be monitored by proactively clearing the access flag in the page table entry where the target physical memory page is located on demand. This enables the virtualization manager or memory management unit on the physical machine to correctly perceive cross-group memory access requests and intra-group memory access requests occurring on each physical memory page.
[0105] On this basis, access fault interception can be implemented in each sampling period within the current statistical cycle, and it can be distinguished whether the access request that triggers each access fault is an intra-group memory access request or a cross-group memory access request. Therefore, the total number of intra-group access requests and the total number of cross-group memory access requests on the target physical memory page can be counted in the current statistical cycle; furthermore, the aforementioned cross-group memory access request heat can be calculated based on the total number of cross-group memory access requests and the total number of intra-group access requests. Echoing the two exemplary heat characterization methods mentioned above, here, the sum of the total number of cross-group memory access requests and the total number of intra-group access requests can be calculated; and the ratio between the total number of cross-group memory access requests and the sum can be calculated as the aforementioned cross-group memory access request ratio. Here, the ratio between the total number of cross-group memory access requests and the current statistical cycle length can also be calculated as the aforementioned cross-group memory access request frequency. In addition, it should be understood that in actual applications, access requests to the target physical memory page may not occur in some sampling periods, so access faults will not be intercepted.
[0106] It should be understood that the above-mentioned operations of counting the heat of cross-group memory access requests on the target physical memory page, identifying the source memory group corresponding to each cross-group memory access request, and distinguishing whether the access request is an intra-group memory access request or a cross-group memory access request can all be completed within the current statistical cycle. In this way, after the current statistics are completed, sufficient basis can be obtained to determine whether it is necessary to redetermine the memory group to which the target physical memory page belongs and to which memory group it is more appropriate to reallocate the target physical page.
[0107] Furthermore, in order to avoid excessive access failures that may negatively impact memory access efficiency, this exemplary solution also proposes: after completing the identification operation within the target sampling period, an access identifier may be added to the target page table entry used by the access request that triggered the access failure; and the access request is triggered to continue execution; wherein, based on the added access identifier, the access request that continues to be executed and subsequent access requests initiated using the target page table entry within the target sampling period no longer trigger an access failure.
[0108] Taking the virtualization scenario as an example, the virtual machine manager can add an access identifier to the target page table entry used by the access request that triggers the access fault after completing the aforementioned operations of counting the heat of cross-group memory access requests on the target physical memory page, identifying the source memory group corresponding to each cross-group memory access request, and distinguishing whether the access request is an intra-group memory access request or a cross-group memory access request; and after completing the access identifier addition operation, the processing right of the access request can be returned to the virtual machine (for example, the return can be achieved by the virtual machine entering the VMentry mechanism) to trigger the virtual machine to continue to execute the access request. At this time, the virtual machine continues to execute the access request. In the aforementioned second address mapping stage, since the access identifier has been added to the corresponding page table entry for the target physical memory page, the access fault will no longer be triggered, and subsequent access requests for the target physical memory page on the page table entry will no longer trigger access faults, thereby avoiding triggering too many access faults.
[0109] Based on this, within a single sampling period, the page table entry where the target physical page is located will trigger an access fault when the first access request to the target physical memory page occurs, and subsequent access requests will not trigger an access fault. Although such a setting may make it impossible to monitor all access requests that actually occur on the target physical memory page within a single sampling period, since the concept of this embodiment only needs to evaluate the cross-group memory access situation on the target physical memory page, there is no need to strictly pursue the accuracy of the evaluation. Moreover, in actual applications, the required evaluation accuracy can be achieved by adjusting the sampling frequency. It can be seen that this mechanism of timely and proactively restoring the access identifier for the target physical memory page by the virtual machine manager or memory management unit can effectively reduce the number of access faults on the basis of ensuring the normal implementation of the memory management scheme of this embodiment, and avoid negative impacts on memory access efficiency.
[0110] FIG4 is a flow chart of a memory management method provided by an exemplary embodiment of the present disclosure. Referring to FIG4 , the method may include:
[0111] Step 400: In response to a management instruction for a target physical memory page, count the heat of cross-group memory access requests on the target physical memory page in a current statistical period;
[0112] Step 401: If the heat of the cross-group memory access request exceeds a specified standard, the memory group to which the target physical memory page belongs is re-determined;
[0113] Step 402: Allocate the target physical memory page to the newly determined memory group;
[0114] Step 403: After the current statistical period ends, a designated physical memory page is selected from the memory group to which the target physical memory page currently belongs to replace the target physical memory page.
[0115] Step 404: Use the designated physical memory page to respond to access requests subsequently initiated from the memory group to which the target physical memory page currently belongs, which originally need to be responded to by the target physical memory page.
[0116] Among them, steps 400-402 can refer to the relevant description in the above embodiment and will not be repeated here. In this embodiment, based on steps 403-404, a memory optimization solution is provided in the memory group to which the target physical memory page is originally allocated when it is reallocated to other memory groups.
[0117] As mentioned above, during the current statistical period, not only cross-group memory access requests will occur on the target physical memory page, but also some intra-group memory access requests will occur. After the target physical memory page is allocated to another memory group in step 402, the target physical memory page is no longer local memory for the memory group to which it originally belongs, but becomes remote memory. Accordingly, access requests initiated in the memory group to which the target physical memory page originally belongs, which originally needed to be responded to by the target physical memory page, also become cross-group memory access requests, and the response rate of these access requests will be greatly reduced.
[0118] In order to avoid this problem, it is proposed in step 403 that after the end of the current statistical period, if the heat of cross-group memory access requests exceeds the specified standard, that is, the target physical memory page needs to be reallocated to other memory groups, then a specified physical memory page can be selected from the memory group to which the target physical memory page currently belongs to replace the target physical memory page, and in step 404, the specified physical memory page is used to respond to the access request that is subsequently initiated in the memory group to which the target physical memory page originally belongs and that originally needed to be responded to by the target physical memory page. Among them, the specified physical memory page selected here can be any idle physical memory page in the memory group to which the target physical memory page originally belonged.
[0119] Here, the target physical memory page can be swapped out and the designated physical memory page used to replace the target physical memory page can be swapped in through the aforementioned memory swap (SWAP) technology. After the memory swap, the target physical memory page is released, so that it can be reallocated to a new memory group. It should be understood that for the processor core in the memory group to which the target physical memory page originally belongs, it does not know which physical memory page is being accessed when performing memory access. The memory access request initiated by the processor core usually carries a virtual memory address, and then the memory access request needs to be mapped based on the aforementioned page table before it reaches the corresponding physical memory page. In this way, by implementing this memory optimization solution, the access request subsequently initiated in the memory group to which the target physical memory page originally belonged, which originally needed to be responded to by the target physical memory page, can still be responded to in the manner of intra-group memory access, and will not become a cross-group memory access manner due to the reallocation of the target physical memory page, resulting in the generation of new cross-group memory access requests.
[0120] In order to implement the replacement of the target physical memory page with the specified physical memory page, in an exemplary implementation scheme:
[0121] After the current statistical period ends, the page table entries used by each of the memory access requests within the group monitored on the target physical memory page during the current statistical period can be searched;
[0122] Clearing the access identifier associated with the target physical memory page in each page table entry found, so that an access request for the target physical memory page initiated based on each page table entry found can trigger an access fault;
[0123] In the process of handling the access failure, the physical memory address of the target physical memory page in the corresponding page table entry is replaced with the physical address corresponding to the specified physical memory page;
[0124] After the replacement operation is completed, an access identifier is added to the corresponding page table entry for the specified physical memory page;
[0125] The access request that triggered the completed access fault processing continues to be executed to respond to the access request in the same manner as the memory access within the group.
[0126] In this exemplary implementation, the access identifiers associated with the target physical memory pages in the page table entries used by each group's memory access request can be actively cleared, so that when subsequent access requests for the target physical memory pages occur on these page table entries, access faults can be triggered. Thus, the virtual machine manager or memory management unit can intercept these access faults, which gives the virtual machine manager or memory management unit an opportunity to replace the target physical memory page. That is, the virtual machine manager or memory management unit can handle the intercepted access faults and replace the physical addresses in the page table entries during the access fault handling to complete the fault handling. The process of handling access faults can refer to the page fault recovery logic, that is, the virtual memory address in the corresponding page table is identified as being in a page fault state, an idle physical memory page is searched for as the aforementioned designated physical memory page, and a swap-in operation is performed on the designated physical memory page. In this way, the original mapping relationship in the page table entry can be updated, and the updated mapping relationship has replaced the target physical memory page with the designated physical memory page. After the physical address replacement operation is completed, an access flag can be added to the corresponding page table entry for the specified physical memory page and the access request that has completed the fault handling can be triggered to continue. After the access request continues to be executed, the specified physical memory page will respond in the same way as the memory access within the group.
[0127] It is worth noting that, in actual applications, the reallocation process of the target physical page mentioned in steps 401-402 and the physical memory page replacement process mentioned in steps 403-404 can be executed in parallel without affecting each other, so as to avoid cross-group memory access requests in the memory group to which the target physical memory page originally belongs due to the reallocation of the target physical memory page.
[0128] In addition, the memory optimization scheme proposed in FIG4 for the target physical internal page in the original memory group can be combined with the implementation scheme proposed in FIG3 for re-determining the memory group to which the target physical memory page belongs.
[0129] In summary, in the memory optimization solution provided in this embodiment, when the target physical memory page is reallocated to other memory groups, not only can the cross-group memory access request for the target physical memory page in the memory group to which it is reallocated be converted into an intra-group memory access request, but also the intra-group memory access request in the memory group to which it originally belongs, which originally needed to be responded by the target physical memory page, can still be responded in accordance with the intra-group memory access method. In this way, from the perspective of the memory grouping architecture, through the memory management method provided in this embodiment, a part of the cross-group memory access requests occurring therein are converted into intra-group memory access requests, while the original intra-group memory access requests therein continue to be responded in accordance with the intra-group memory access method. Therefore, the cross-group memory access requests in the memory grouping architecture will be greatly reduced. In this way, the application will be more likely to complete the memory access through the intra-group memory access method, thereby effectively improving the memory access efficiency.
[0130] Figure 5a is a logical diagram of a solution in an exemplary application scenario provided by an exemplary embodiment of the present disclosure. Referring to Figure 5a, the memory management method provided in this embodiment is applied to a virtual machine manager in a physical machine, which is described as VMM below. There are multiple NUMA nodes preset on the physical machine, for example, NUMA node0 and NUMA node1 in Figure 5a. There are multiple virtual machines running on the physical machine. An application in the virtual machine can initiate a memory access request. Referring to Figure 5a, generally, a virtual machine can include multiple VCPUs, and the VCPU will rely on the processor core (CPU) on the physical machine for implementation. The application can include multiple processes, and the virtual machine can schedule a single process of the application to a VCPU in the virtual machine. Ultimately, the memory access request initiated by the process of the application on the virtual machine will reach the processor core on the physical machine.
[0131] Referring to Figure 5a, the target physical memory page b on the physical machine is currently allocated to NUMA node 1. Taking application a in virtual machine A as an example, if process c in application a is scheduled to VCPU 1, which is implemented on physical CPU X, the access request initiated by process c for the target physical memory page b will reach CPU X, which is located in NUMA node 0. Therefore, the access request will reach the target physical memory page b via cross-group memory access. If process d in application a is scheduled to VCPU 2, which is implemented on physical CPU Y, the access request initiated by process d for the target physical memory page b will reach CPU Y, which is located in NUMA node 0 and belongs to the same NUMA node 0 as the target physical memory page b. Therefore, the access request can reach the target physical memory page b via intra-group memory access.
[0132] Referring to Figure 5a, the VMM can monitor the access requests received on the target physical memory page b. To this end, Figure 5b is a schematic diagram of a time period setting scheme in an exemplary application scenario provided by an exemplary embodiment of the present disclosure. Referring to Figure 5b, the statistical period is set to 1 hour, and the statistical period is divided into N consecutive sampling periods. The VMM can clear the access identifier AF associated with the target physical memory page b in the page table entry where the target physical memory page b is located (for example, the page table entry where the target physical memory page b is located in the EPT page table) at the start time of each sampling period. In this way, if an access request for the target physical memory page b occurs on the page table entry being operated within a certain sampling period, an access fault will be triggered, and the virtual machine will exit the Vmexit event. The VMM can intercept these access faults.
[0133] In addition to performing routine processing on these access failures, the VMM can also parse out the source NUMAnode corresponding to the access request that triggered the access failure from these access failures. For example, when the access request initiated by process d in Figure 5a for the target physical memory page b causes an access failure, the VMM can identify that the access request originates from NUMAnode1 and determines that it is an intra-group memory access request; and when the access request initiated by process c in Figure 5a for the target physical memory page b causes an access failure, the VMM can identify that the access request originates from NUMAnode0 and determines that it is a cross-group memory access request.
[0134] For example, referring to Figure 5b, in the first sampling period, an access failure to the target physical memory page b is detected, and its corresponding source memory group is NUMAnode1; in the second sampling period, an access failure to the target physical memory page b is detected, and its corresponding source memory group is NUMAnode0; in the third sampling period, no access failure to the target physical memory page b is detected; in the fourth sampling period, an access failure to the target physical memory page b is detected, and its corresponding source memory group is NUMAnode0; in the fifth sampling period, an access failure to the target physical memory page b is detected, and its corresponding source memory group is NUMAnode2. Assuming N = 5, it can be calculated that in this statistical period, the proportion of cross-group memory access requests corresponding to the target physical memory page b is 3 / 4, among which the number of cross-group memory access requests issued to the target physical memory page from NUMAnode1 is the largest.
[0135] Because 3 / 4 exceeds the specified standard of 1 / 2, referring to Figure 5a, the VMM reallocates the target physical memory to NUMAnode0. This way, subsequent access requests for target physical memory page b from requesters such as process c in NUMAnode0 will be responded to as intra-group memory accesses, significantly improving the memory access rate. Referring to Figure 5b, the VMM also replaces target physical memory page b with physical memory page e in NUMAnode1, allowing physical memory page e to continue responding to intra-group memory access requests that would have otherwise been handled by target physical memory page b, using intra-group memory accesses.
[0136] 5a and 5b , the memory management method provided in this embodiment can realize dynamic scheduling of physical memory pages under a memory grouping architecture, and dynamically schedule physical memory pages to appropriate memory groups, thereby converting as many access requests in the memory grouping architecture that originally needed to be responded to according to a cross-group memory access method into intra-group memory access requests as possible, thereby improving memory access efficiency.
[0137] It should be noted that some of the processes described in the above embodiments and the accompanying drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. The sequence numbers of the operations, such as 301 and 302, are merely used to distinguish between different operations and do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel.
[0138] FIG6 is a schematic diagram of the structure of a physical machine provided by another exemplary embodiment of the present disclosure. As shown in FIG6 , the physical machine may include: a memory 60 and a processor 61. The memory 60 may provide physical memory pages. The physical machine is pre-configured with multiple memory groups, each of which contains physical memory pages. The memory access rate within a group is higher than the memory access rate across groups. The memory is used to store one or more computer instructions. The processor is coupled to the memory and is used to execute the one or more computer instructions, thereby:
[0139] In response to a management instruction for a target physical memory page, counting the heat of cross-group memory access requests on the target physical memory page in a current statistical period;
[0140] If the cross-group memory access request heat exceeds the specified standard, the memory group to which the target physical memory page belongs is re-determined;
[0141] Allocate the target physical memory page to the newly determined memory group.
[0142] In one embodiment, when re-determining the memory group to which the target physical memory page belongs, the processor 61 may be specifically configured to:
[0143] Determine the source memory group corresponding to each cross-group memory access request monitored on the target physical memory page within the current statistical period;
[0144] For each determined source memory group, count the number of cross-group memory access requests corresponding to the target physical memory page in the current statistical period;
[0145] The source memory group whose number of cross-group memory access requests meets the specified condition is used as the memory group to be re-determined for the target physical memory page.
[0146] In one embodiment, when the processor 61 uses the source memory group whose number of cross-group memory access requests meets a specified condition as the memory group to be re-determined for the target physical memory page, it can be specifically configured to:
[0147] From the determined source memory groups, find the source memory group that initiates the largest number of cross-group memory access requests to the target physical memory page in the current statistical period, and use it as the newly determined memory group for the target physical memory page.
[0148] In one embodiment, the processor 61 may further be configured to:
[0149] Set multiple sampling periods within the current statistical period;
[0150] When the target sampling period starts, the access flag in the page table entry where the target physical memory page is located is cleared, so that an access fault is triggered when an access request for the target physical memory page occurs within the target sampling period.
[0151] If an access fault is received for the target physical memory page within the target sampling period, identifying a source memory group corresponding to the access request that triggers the access fault from the access fault;
[0152] If the identified source memory group is inconsistent with the memory group to which the target physical memory page currently belongs, it is determined that a cross-group memory access request has been detected;
[0153] The target sampling period is any one of the multiple sampling periods.
[0154] In one embodiment, when the processor 61 counts the heat of cross-group memory access requests on the target physical memory page in the current statistical period, it may be configured to:
[0155] Based on the access faults received in the current statistical period, the total number of intra-group access requests and the total number of cross-group memory access requests corresponding to the target physical memory page in the current statistical period are counted;
[0156] The heat of cross-group memory access requests is calculated based on the total number of cross-group memory access requests and the total number of intra-group access requests.
[0157] In one embodiment, the processor 61 may further be configured to:
[0158] After completing the identification operation within the target sampling period, adding an access identifier to the target page table entry used by the access request that triggered the access fault;
[0159] Trigger access request to continue execution;
[0160] Wherein, based on the added access identifier, the access request that continues to be executed and the subsequent access request initiated by using the target page table entry within the target sampling period no longer trigger an access fault.
[0161] In one embodiment, the processor 61 may further be configured to:
[0162] If the cross-group memory access request popularity exceeds the specified standard, after the current statistical period ends, a designated physical memory page is selected from the memory group to which the target physical memory page currently belongs to replace the target physical memory page.
[0163] The designated physical memory page is used to respond to access requests subsequently initiated in the memory group to which the target physical memory page currently belongs, which originally need to be responded to by the target physical memory page.
[0164] In one embodiment, when the processor 61 uses the designated physical memory page to respond to an access request subsequently initiated from the memory group to which the target physical memory page currently belongs, and which originally needs to be responded to by the target physical memory page, the processor 61 may be specifically configured to:
[0165] Find the page table entries used by each memory access request within the group monitored on the target physical memory page during the current statistical period;
[0166] Clearing the access identifier associated with the target physical memory page in each page table entry found, so that an access request for the target physical memory page initiated based on each page table entry found can trigger an access fault;
[0167] In the process of handling the access failure, the physical address of the target physical memory page in the corresponding page table entry is replaced with the physical address corresponding to the specified physical memory page;
[0168] After the replacement operation is completed, an access identifier is added to the corresponding page table entry for the specified physical memory page;
[0169] The access request that triggered the completed access fault processing continues to be executed to respond to the access request in the same manner as the memory access within the group.
[0170] In one embodiment, when the target physical memory page is mapped to the virtual machine memory space, the memory management logic executed by the processor 61 can be implemented by the virtual machine manager on the physical machine; when the target physical memory page is not mapped to the virtual machine memory space, the memory management logic executed by the processor 61 can be implemented by the memory management unit on the physical machine.
[0171] In one embodiment, the memory group uses a NUMA node or a CPU socket as a memory grouping unit.
[0172] In one embodiment, the processor 61 may further be configured to:
[0173] After the target physical memory page is allocated to the re-determined memory group, the affinity between the target physical memory page and the re-determined memory group is updated according to the preset accumulation rule; when the re-determined memory group needs to be expanded, the physical memory pages outside the re-determined memory group and whose affinity with the re-determined memory group meets the specified requirements will be re-scheduled back to the re-determined memory group.
[0174] Furthermore, as shown in Figure 6 , the physical machine also includes other components such as a communication component 62 and a power supply component 63. Figure 6 only schematically shows some components, which does not mean that the physical machine only includes the components shown in Figure 6 .
[0175] It is worth noting that the technical details in the above-mentioned embodiments of the physical machine can be referred to the relevant description in the aforementioned method embodiments. In order to save space, they will not be repeated here, but this should not cause any loss of the protection scope of this disclosure.
[0176] Accordingly, an embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program, which can implement the steps in the above method embodiment when executed.
[0177] The memory in FIG6 is used to store computer programs and can be configured to store various other data to support operations on the computing platform. Examples of such data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, images, videos, etc. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0178] The communication component in Figure 6 above is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0179] The power supply assembly in Figure 6 provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.
[0180] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0181] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0182] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0184] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0185] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0186] The above are merely embodiments of the present disclosure and are not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included within the scope of protection of the present disclosure.
Claims
1. A memory management method, wherein: A plurality of memory groups are preset on the physical machine, and the memory groups contain physical memory pages. The method includes: In response to a management instruction for a target physical memory page, counting the heat of cross-group memory access requests on the target physical memory page in a current statistical cycle; If the heat of the cross-group memory access request exceeds a specified standard, re-determining the memory group to which the target physical memory page belongs; The target physical memory page is allocated to the re-determined memory group.
2. The method according to claim 1, wherein: Re-determining the memory group to which the target physical memory page belongs, including: Determine the source memory group corresponding to each cross-group memory access request monitored on the target physical memory page during the current statistical period; For each determined source memory group, respectively counting the number of cross-group memory access requests corresponding to the target physical memory page in the current statistical period; The source memory group whose number of cross-group memory access requests meets the specified condition is used as the memory group to be re-determined for the target physical memory page.
3. The method according to claim 2, wherein: The method further comprises: using a source memory group whose number of cross-group memory access requests meets a specified condition as a memory group to be re-determined for the target physical memory page, including: From the determined source memory groups, find the source memory group that initiates the most cross-group memory access requests to the target physical memory page in the current statistical period, as the memory group that is re-determined for the target physical memory page.
4. The method according to claim 2, wherein: Also includes: Setting a plurality of sampling periods within the current statistical period; When the start time of the target sampling period is reached, the access identifier in the page table entry where the target physical memory page is located is cleared, so that an access fault is triggered when an access request for the target physical memory page occurs within the target sampling period; If an access failure to the target physical memory page is received within the target sampling period, identifying from the access failure a source memory group corresponding to the access request that triggers the access failure; If the identified source memory group is inconsistent with the memory group to which the target physical memory page currently belongs, it is determined that a cross-group memory access request is monitored; The target sampling period is any one of the multiple sampling periods.
5. The method according to claim 4, wherein: Counting the heat of cross-group memory access requests on the target physical memory page in the current statistical period includes: Based on the access failures received in the current statistical period, counting the total number of intra-group access requests and the total number of cross-group memory access requests corresponding to the target physical memory page in the current statistical period; The heat of the cross-group memory access request is calculated according to the total number of cross-group memory access requests and the total number of intra-group access requests.
6. The method according to claim 4, wherein: Also includes: After completing the identification operation within the target sampling period, adding an access identifier to a target page table entry used by the access request that triggers the access fault; triggering the access request to continue execution; Wherein, based on the added access identifier, the access request that continues to be executed and the subsequent access request initiated by using the target page table entry within the target sampling period no longer trigger an access fault.
7. The method according to claim 1, wherein: Also includes: If the heat of the cross-group memory access request exceeds the specified standard, after the current statistical period ends, a specified physical memory page for replacing the target physical memory page is selected from the memory group to which the target physical memory page currently belongs; The designated physical memory page is used to respond to an access request subsequently initiated in the memory group to which the target physical memory page currently belongs, which originally needs to be responded to by the target physical memory page.
8. The method according to claim 7, wherein: Using the designated physical memory page to respond to an access request subsequently initiated in the memory group to which the target physical memory page currently belongs, which originally needs to be responded to by the target physical memory page, includes: Finding the page table entries used by each of the intra-group memory access requests monitored on the target physical memory page during the current statistical period; Clearing the access identifier associated with the target physical memory page in each page table entry found, so that an access request for the target physical memory page initiated based on each page table entry found can trigger an access fault; In the process of processing the access fault, the physical address of the target physical memory page in the corresponding page table entry is replaced with the physical address corresponding to the specified physical memory page; After completing the replacement operation, adding an access identifier for the specified physical memory page in the corresponding page table entry; The access request that triggered the completed access fault processing continues to be executed to respond to the access request in accordance with the intra-group memory access manner.
9. The method according to claim 1, wherein: When the target physical memory page is mapped to the virtual machine memory space, the method is applicable to the virtual machine manager on the physical machine; when the target physical memory page is not mapped to the virtual machine memory space, the method is applicable to the memory management unit on the physical machine.
10. The method according to claim 1, wherein: The memory group uses a NUMA node or a CPU slot as a memory grouping unit.
11. The method according to claim 1, wherein: Also includes: After the target physical memory page is allocated to the re-determined memory group, the affinity between the target physical memory page and the re-determined memory group is updated according to a preset accumulation rule; In the said When the newly determined memory group needs to be expanded, the physical memory pages that are outside the re-determined memory group and whose affinity with the re-determined memory group meets the specified requirements are rescheduled back to the re-determined memory group.
12. A physical machine, wherein: It includes a memory and a processor, the memory provides physical memory pages, the physical machine is preset with multiple memory groups, the memory groups contain physical memory pages, the memory access rate within the group is higher than the memory access rate across groups, the memory is used to store one or more computer instructions; the processor is coupled to the memory, and is used to execute the one or more computer instructions, so as to execute the memory management method described in any one of claims 1-11.
13. A computer-readable storage medium storing computer instructions, wherein: When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the memory management method according to any one of claims 1 to 11.
14. A computer program, wherein: It includes computer instructions, which, when executed by a processor, implement the memory management method described in any one of claims 1-11.
Citation Information
Patent Citations
Memory access monitoring method and device
CN102362464A
Cache management method and device
CN104156322A
Data storage method and equipment based on HBase
CN104750757A
Data migration method, device and processor
CN104956341A
NUMA system and method of migrating pages in the system
CN112947851A
Cited By
Memory allocation method and device and storage medium
CN120469820A