Memory processing method and device, electronic equipment and storage medium

By processing anonymous pages in groups, the problem of long time-consuming processing of anonymous pages in the prior art is solved, and more efficient memory processing is achieved.

CN119357076APending Publication Date: 2025-01-24VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411425018.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

When processing anonymous pages, the prior art requires reverse mapping (Rmap) processing for each anonymous page in turn, resulting in a long processing time and affecting memory processing efficiency.

Method used

By obtaining the information of the N anonymous page in the linked list, the anonymous page is paid in packet, and the reverse mapping RMAP processing is performed based on each group of anonymous pages.

Benefits of technology

The total number and time consumption of anonymous page processing has been reduced, and the memory processing efficiency of electronic equipment is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357076A_ABST
    Figure CN119357076A_ABST
Patent Text Reader

Abstract

The invention discloses a memory processing method and device, electronic equipment and a storage medium, and belongs to the technical field of electronics. The method comprises the steps that first information of N anonymous pages in a first linked list is acquired; the first information comprises PTE in VMA mapped by N anonymous pages, and N is a positive integer smaller than or equal to 32; based on the first information, grouping the N anonymous pages to obtain at least one group of anonymous pages; and based on each group of anonymous pages, executing Rmap processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of electronic technology, and specifically relates to a memory processing method, device, electronic device and storage medium. Background Art

[0002] As users' functional requirements for electronic devices continue to increase, insufficient memory often occurs in the systems of electronic devices. In this case, the electronic device can reverse map (Rmap) the anonymous pages on the least recently used page replacement (Least Recently Used, LRU) linked list one by one in order, thereby performing an unmap process on the anonymous pages that partially meet the recycling conditions, reducing the memory space occupied by the anonymous pages, thereby achieving the effect of recycling memory, so that the electronic device can obtain enough memory for the application to run.

[0003] However, in the above method, since the electronic device needs to perform Rmap processing on each anonymous page in turn and needs to perform locking processing and PTE Referenced detection on each anonymous page respectively, the electronic device needs to repeat the above process during the memory processing. This will cause the processing of the anonymous page to be time-consuming and affect the memory processing efficiency of the electronic device. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a memory processing method, device, electronic device and storage medium, which can reduce the processing time of anonymous pages and improve the memory processing efficiency of electronic devices.

[0005] In a first aspect, an embodiment of the present application provides a memory processing method, which includes: obtaining first information of N anonymous pages in a first linked list; the first information includes page table entries PTE in a virtual memory area VMA mapped by the N anonymous pages, where N is a positive integer less than or equal to 32; based on the first information, the N anonymous pages are grouped to obtain at least one group of anonymous pages; based on each group of anonymous pages, reverse mapping Rmap processing is performed.

[0006] In the second aspect, an embodiment of the present application provides a memory processing device, which includes: an acquisition module, a grouping module and an execution module; the acquisition module is used to acquire first information of N anonymous pages in a first linked list; the first information includes page table entries PTE in a virtual memory area VMA mapped by the N anonymous pages, where N is a positive integer less than or equal to 32; the grouping module is used to group the N anonymous pages based on the first information acquired by the acquisition module to obtain at least one group of anonymous pages; the execution module is used to perform reverse mapping Rmap processing based on each group of anonymous pages obtained by the grouping module.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0010] In a sixth aspect, an embodiment of the present application provides a computer program / program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0011] In an embodiment of the present application, first information of N anonymous pages in a first linked list is obtained, and the first information includes PTEs in the VMA to which the N anonymous pages are mapped; then, based on the obtained first information, the N anonymous pages can be grouped to obtain at least one group of anonymous pages; thus, reverse mapping Rmap processing can be performed based on each group of anonymous pages. In this scheme, since the anonymous pages in the linked list can be mapped to the PTEs in the VMA, for multiple anonymous pages in the linked list that are only mapped to continuous PTEs in the same VMA and are mounted in a continuous order on the linked list, it represents that the virtual addresses of these anonymous pages are continuous, so these anonymous pages can be used as a group of anonymous pages, so that the anonymous pages in the linked list are subjected to specific processing in groups, without the need to perform Rmap processing on each anonymous page in the linked list in sequence, so the total number of times the electronic device needs to perform Rmap processing can be reduced, so that the total time-consuming overhead of performing Rmap processing on anonymous pages can be reduced, thereby improving the memory processing efficiency of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 is a flow chart of an LRU second chance method provided by an embodiment of the present application;

[0013] Figure 2 This is one of the flow charts of a memory processing method provided in an embodiment of the present application;

[0014] Figure 3 This is one of the example schematic diagrams of an isolate linked list provided in an embodiment of the present application;

[0015] Figure 4 This is the second flowchart of a memory processing method provided in an embodiment of the present application;

[0016] Figure 5 This is the third flowchart of a memory processing method provided in an embodiment of the present application;

[0017] Figure 6 This is the second example schematic diagram of an isolate linked list provided in an embodiment of the present application;

[0018] Figure 7 This is a fourth flowchart of a memory processing method provided in an embodiment of the present application;

[0019] Figure 8 This is one of the flow charts of a PTE access count value provided in an embodiment of the present application;

[0020] Fig. 9 This is the second flowchart of a PTE access count value provided by an embodiment of the present application;

[0021] Fig.10 This is the third example schematic diagram of an isolate linked list provided in an embodiment of the present application;

[0022] Fig.11 This is the fifth flowchart of a memory processing method provided in an embodiment of the present application;

[0023] Fig.12 is a structural schematic diagram of a memory processing device provided in an embodiment of the present application;

[0024] Fig.13 This is one of the hardware structure diagrams of an electronic device provided in an embodiment of the present application;

[0025] Fig.14 This is the second schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0027] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0028] The terms "at least one (item)", "at least one of" and the like in the specification of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".

[0029] The following is an explanation of the professional terms involved in the embodiments of the present application:

[0030] The memory pages reclaimed by the operating system kernel (Linux) can be divided into anonymous pages and file pages according to their types. The memory page size is 4KB. Anonymous pages refer to memory pages without backing disk file storage, and file pages refer to memory pages with backing disk file storage.

[0031] The Linux memory recycling system organizes and manages anonymous pages through the Least Recently Used (LRU) list, and divides it into the anonymous page active LRU list and the anonymous page inactive LRU list according to the active degree of anonymous page access. Among them, the most recently accessed anonymous page is located at the head of the active LRU list, and the anonymous page that has not been accessed for the longest time is located at the tail of the inactive LRU list.

[0032] The core idea of ​​the LRU (Least Recently Used) algorithm is to replace the pages that have not been used for the longest time.

[0033] The LRU second chance method is an improved page replacement algorithm based on the LRU algorithm. It means that the Linux kernel maintains a double linked list (i.e., the anonymous page active LRU linked list and the anonymous page inactive LRU linked list), mounts all the allocated anonymous pages in the system in the order in which the anonymous pages were recently accessed, and reclaims the anonymous pages from the end of the inactive LRU linked list in the mounting order on the double linked list. By giving the most recently used pages a "second chance", it aims to avoid replacing frequently used pages too early, thereby reducing performance issues that may be caused by a simple LRU algorithm.

[0034] anon_vma is a mechanism in the Linux kernel for managing anonymous memory mapping (Anonymous Memory Mapping) related data structures. Anonymous memory mapping is mainly used for the process heap, stack, and some dynamically allocated memory areas.

[0035] The memory processing method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0036] At present, in the Linux kernel system, for the application scenario of memory page units mapped by Page Table Entry (PTE), the anonymous pages mounted on the LRU linked list are all independent single memory pages. In the process of recycling anonymous pages through the LRU second chance method, the anonymous pages on the LRU linked list are Rmap processed one by one in order to complete the process of PTE referenced detection and unmap processing, so as to recycle and release anonymous pages that meet the release conditions, and realize memory processing of the Linux kernel system.

[0037] Specifically, Figure 1 As shown, the electronic device can scan the anonymous pages on the active LRU list and the inactive LRU list in sequence. In the process of reclaiming the anonymous pages on the active LRU list, the electronic device first scans the anonymous pages one by one from the end of the active LRU list, performs reverse mapping (Rmap) processing in sequence, obtains the virtual memory area (VMA) mapped by the anonymous page, and performs PTE Referenced detection to obtain the access count value, and determines the subsequent operations to be performed on the anonymous page based on the obtained access count value.

[0038] Similarly, the process of traversing the PTE Referenced access count value in the recycling of anonymous pages on the inactive LRU is similar to the process of the active LRU linked list mentioned above.

[0039] Specifically, in the process of performing Rmap processing on the LRU linked list, any of the following situations may be included:

[0040] (1) If the file page is in the active LRU list and PTE Referenced=1, the file page will be remounted to the head of the active LRU list after PTE Referenced detection.

[0041] (2) If the anonymous page is in the active LRU list, the anonymous page will be moved to the head of the inactive LRU list after the PTE Referenced check. At the same time, if the PTE Referenced corresponding to the anonymous page is 1, the corresponding PTE Referenced is set to 0.

[0042] (3) If the anonymous page is in the inactive LRU list, PTE Referenced = 1, and the number of accesses meets certain conditions, the anonymous page will be activated and migrated to the head of the active LRU list after the PTE Referenced detection, and PTE Referenced will be set to 0.

[0043] (4) If the anonymous page is in the inactive LRU list, PTE Referenced = 1, and may be accessed again in the near future, the anonymous page will be migrated to the head of the inactive LRU list after the PTE Referenced check, so that it can continue to remain in the inactive LRU list, and PTE Referenced will be set to 0.

[0044] (5) If the anonymous page is in the inactive LRU list and PTE Referenced=0, the anonymous page can be further released to the buddy system through Unmap processing after PTE Referenced detection.

[0045] For the above situation (3), although the anonymous page is in the inactive LRU list, there are also anonymous pages that have been recently accessed. Such anonymous pages cannot be directly recycled, but need to be added to the head of the active LRU list and re-polled.

[0046] For the above situation (4), although the anonymous page is in the inactive LRU list, there are also anonymous pages that may be accessed in the near future. Such anonymous pages cannot be directly recycled, but need to be re-added to the head of the inactive LRU list and re-polled.

[0047] However, in the above method, it is necessary to perform Rmap processing on each anonymous page in turn, which makes the processing of anonymous pages time-consuming. At the same time, a lock processing is required during the execution of an Rmap processing. However, frequent locking will cause competition pressure on the anon_vma lock, which will further affect the recovery efficiency of anonymous pages. This will result in poor efficiency in memory processing by electronic devices.

[0048] The memory processing method provided in the embodiment of the present application can be applied to scenarios where the system is under high memory pressure, where the kernel memory asynchronous recovery thread runs at a high load and power consumption increases due to the limited efficiency of the kernel memory recovery, and where the application process takes a long time to apply for memory, resulting in freezes and other problems.

[0049] In the memory processing method, device, electronic device and storage medium provided in the embodiment of the present application, the first information of N anonymous pages in the first linked list is obtained, and the first information includes the PTE in the VMA mapped by the N anonymous pages; then, based on the obtained first information, the N anonymous pages can be grouped to obtain at least one group of anonymous pages; thus, the reverse mapping Rmap processing can be performed based on each group of anonymous pages. In this scheme, since the anonymous pages in the linked list can be mapped to the PTE in the VMA, for the multiple anonymous pages in the linked list that are only mapped to the same VMA in a continuous PTE and are mounted in a continuous order on the linked list, it represents that the virtual addresses of these anonymous pages are continuous, so these anonymous pages can be used as a group of anonymous pages, so that the anonymous pages in the linked list are executed in groups. The specific processing process is performed on the anonymous pages in the linked list without sequentially performing Rmap processing on each anonymous page in the linked list, so the total number of times the electronic device needs to perform Rmap processing can be reduced, so that the total time-consuming overhead of performing Rmap processing on anonymous pages can be reduced, thereby improving the memory processing efficiency of the electronic device.

[0050] The execution subject of the memory processing method provided in the embodiment of the present application is a memory processing device, which can be an electronic device, or a functional module or entity in an electronic device, and the embodiment of the present application does not limit this. The following will take an electronic device as an example to exemplify the memory processing method provided in the embodiment of the present application.

[0051] The present application embodiment provides a memory processing method. Figure 2 FIG. 1 is a flow chart of a memory processing method provided by an embodiment of the present application. Figure 2 As shown, the memory processing method provided in the embodiment of the present application may include the following steps 201 to 203.

[0052] Step 201: The electronic device obtains first information of N anonymous pages in a first linked list.

[0053] In some embodiments of the present application, the first linked list may be an isolate linked list.

[0054] In some embodiments of the present application, the electronic device isolates a maximum of SWAP_CLUSTER_MAX=32 anonymous pages from the LRU linked list through the isolate linked list to perform subsequent Rmap processing.

[0055] In the embodiment of the present application, N is a positive integer less than or equal to 32.

[0056] In the embodiment of the present application, the first information includes the PTEs in the VMAs mapped by N anonymous pages.

[0057] It should be noted that an anonymous page can map one VMA, or can map multiple VMAs.

[0058] Step 202: The electronic device groups N anonymous pages based on the first information to obtain at least one group of anonymous pages.

[0059] In some embodiments of the present application, each group of anonymous pages in the at least one group of anonymous pages may include at least one anonymous page.

[0060] It can be understood that the sum of the anonymous pages included in the at least one group of anonymous pages is N.

[0061] In some embodiments of the present application, when the number of anonymous pages included in a group of anonymous pages is 1, the group of anonymous pages can be called discrete anonymous pages; when the number of anonymous pages included in a group of anonymous pages is greater than or equal to 2, the group of anonymous pages can be called accumulated anonymous pages.

[0062] For example, Figure 3 As shown, in the case where the isolate linked list includes 32 anonymous pages, the electronic device can group the 32 anonymous pages into 7 groups of anonymous pages based on the first information, namely, discrete anonymous page 1, discrete anonymous page 2, accumulated anonymous page 1, discrete anonymous page 3, discrete anonymous page 4, accumulated anonymous page 2 and discrete anonymous page 5. Each group of discrete anonymous pages includes one anonymous page, namely, discrete anonymous page 1 includes the first anonymous page on the isolate linked list, discrete anonymous page 2 includes the second anonymous page on the isolate linked list, discrete anonymous page 3 includes the 26th anonymous page on the isolate linked list, discrete anonymous page 4 includes the 27th anonymous page on the isolate linked list, and discrete anonymous page 5 includes the 32nd anonymous page on the isolate linked list; each group of accumulated anonymous pages can include multiple anonymous pages, namely, accumulated anonymous page 1 includes the 3rd to 25th anonymous pages on the isolate linked list, and accumulated anonymous page 2 includes the 28th to 32nd anonymous pages on the isolate linked list.

[0063] In some embodiments of the present application, Figure 2 ,like Figure 4 As shown, the above step 202 can be specifically implemented through the following step 202a.

[0064] Step 202a: The electronic device determines the anonymous pages that meet a preset condition among the N anonymous pages as a group of anonymous pages, thereby obtaining at least one group of anonymous pages.

[0065] In some embodiments of the present application, the electronic device may determine multiple anonymous pages that meet preset conditions as a group of accumulated anonymous pages, and determine a single anonymous page among anonymous pages that do not meet preset conditions as a group of discrete anonymous pages, thereby obtaining at least one group of anonymous pages.

[0066] In the embodiment of the present application, the above preset condition is that the anonymous page maps multiple consecutive PTEs in the same VMA, and the mounting order on the LRU linked list is continuous.

[0067] For example, in combination Figure 3 , the 3rd to 25th anonymous pages on the isolate list map multiple consecutive PTEs in the same VMA, and the mounting order on the LRU list is continuous, so the 3rd to 25th anonymous pages on the isolate list are determined as a group, that is, accumulated anonymous page 1; the 28th to 32nd anonymous pages on the isolate list map multiple consecutive PTEs in the same VMA, and the mounting order on the LRU list is continuous, so the 28th to 32nd anonymous pages on the isolate list are determined as a group, that is, accumulated anonymous page 2. At the same time, the first, second, 26th, 27th, and 32nd anonymous pages on the isolate list do not meet the preset conditions with their adjacent anonymous pages, so the first anonymous page on the isolate list is determined as a group, namely, discrete anonymous page 1; the second anonymous page on the isolate list is determined as a group, namely, discrete anonymous page 2; the 26th anonymous page on the isolate list is determined as a group, namely, discrete anonymous page 3; the 27th anonymous page on the isolate list is determined as a group, namely, discrete anonymous page 7; the 32nd anonymous page on the isolate list is determined as a group, namely, discrete anonymous page 5.

[0068] In some embodiments of the present application, the above “mapping the same VMA” can be understood as: multiple anonymous pages only map the same VMA in the same process.

[0069] In some embodiments of the present application, virtual addresses of multiple anonymous pages mapped by consecutive PTEs are consecutive.

[0070] It should be noted that among the anonymous pages mounted on the LRU linked list, there are multiple anonymous pages that map consecutive PTEs in the same VMA and are mounted in a consecutive order on the LRU linked list, and this situation accounts for about 50% of all anonymous pages on the LRU linked list of the entire Linux kernel system. Therefore, the electronic device can group N anonymous pages based on the above preset conditions.

[0071] In some embodiments of the present application, between two adjacent groups of anonymous pages, any of the following situations may be true:

[0072] Two adjacent groups of anonymous pages are mapped to different VMAs;

[0073] Two adjacent groups of anonymous pages are mapped to the same VMA, but the PTE mapped to the last anonymous page in the first group of anonymous pages in the two groups is not continuous with the PTE mapped to the first anonymous page in the second group of anonymous pages.

[0074] In an embodiment of the present application, since the anonymous pages in the linked list can be mapped to the PTE in the VMA, for the multiple anonymous pages in the linked list that are only mapped to the continuous PTE in the same VMA and are mounted in a continuous order on the linked list, the virtual addresses representing these anonymous pages are continuous, so these anonymous pages can be regarded as a group of anonymous pages. At the same time, the electronic device can determine each single anonymous page that does not meet the preset conditions as a group of anonymous pages, thereby obtaining at least one group of anonymous pages. Therefore, the subsequent processing can be performed in groups without having to perform processing on each anonymous page in turn, thereby appropriately reducing the number of processings that need to be performed, and improving the efficiency of the electronic device in processing the memory. In addition, according to the setting of preset conditions, the complexity of traversing multiple VMAs during the Rmap processing caused by the situation where anonymous pages map multiple VMAs can also be avoided.

[0075] In some embodiments of the present application, when the electronic device obtains at least one group of anonymous pages, the electronic device can also obtain the number of anonymous pages contained in each group of the at least one group of anonymous pages, so that in the subsequent processing, the electronic device can accurately know which anonymous pages are specifically included in each group of anonymous pages based on the number of each group of anonymous pages.

[0076] Step 203: The electronic device performs Rmap processing based on each group of anonymous pages.

[0077] In some embodiments of the present application, the electronic device may perform Rmap processing accordingly based on the type of each group of anonymous pages.

[0078] It should be noted that the above anonymous page type can be any of the following: discrete anonymous page, accumulated anonymous page.

[0079] For example, in combination Figure 3, the electronic device can perform Rmap processing once for each of the 7 groups of anonymous pages in the isolate list, that is, the electronic device needs to perform Rmap processing 7 times in total.

[0080] In some embodiments of the present application, the Rmap process includes locking, PTE access count detection, and unmap. Figure 2 ,like Figure 5 As shown, the above step 203 can be implemented by the following steps 203a to 203c

[0081] Step 203a: The electronic device performs a locking process on each group of anonymous pages.

[0082] In some embodiments of the present application, the above-mentioned locking process may be anon_vma locking process.

[0083] In some embodiments of the present application, when a group of anonymous pages are accumulated anonymous pages, the electronic device may perform a lock process on the group of anonymous pages according to the characteristic of the accumulated anonymous pages that "only consecutive PTEs in the same VMA are mapped".

[0084] For example, in combination Figure 3 , the electronic device can perform a locking process on each of the 7 groups of anonymous pages in the isolate list, that is, the electronic device needs to perform a locking process 7 times in total.

[0085] In this way, the electronic device performs locking processing in groups. Even if a group contains multiple anonymous pages, a corresponding locking processing can be performed once, thereby reducing the number of times the locking processing needs to be directly performed in units of a single anonymous page, thereby reducing the time consumption caused by the locking processing.

[0086] Step 203b: The electronic device performs a PTE access count value detection on at least part of the anonymous pages in each group of anonymous pages after the locking process, and obtains a PTE access count value corresponding to each anonymous page in each group of anonymous pages.

[0087] In some embodiments of the present application, the above PTE access count value detection can be expressed as a PTE Referenced detection. Therefore, the above PTE access count value can be expressed as a PTE Referenced value.

[0088] In some embodiments of the present application, when the number of anonymous pages contained in a group of anonymous pages is less than or equal to 2, the electronic device can directly perform PTE access count value detection on the single anonymous page to obtain the PTE access count value corresponding to the single anonymous page.

[0089] In some embodiments of the present application, when the number of anonymous pages contained in a group of anonymous pages is greater than or equal to 3, the electronic device can perform PTE access count value detection on some or all of the accumulated multiple anonymous pages to obtain PTE access count values ​​corresponding to the multiple anonymous pages.

[0090] In some embodiments of the present application, the above-mentioned partial anonymous pages may include but are not limited to any of the following: anonymous pages in odd positions in a group of anonymous pages, anonymous pages in even positions in a group of anonymous pages, and anonymous pages in preset positions in a group of anonymous pages.

[0091] It should be noted that the above-mentioned preset positions may be any adjacent P positions in a group of anonymous pages, wherein P is less than the number of anonymous pages included in the group of anonymous pages.

[0092] For example, in combination Figure 3 ,like Figure 6 As shown, the electronic device can perform PTE access count value detection on each group of anonymous pages in turn according to the order corresponding to the positions of the 7 groups of anonymous pages in the isolate linked list to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages.

[0093] In some embodiments of the present application, the above-mentioned PTE access count value may indicate whether the PTE mapped by the anonymous page has been accessed recently.

[0094] In some embodiments of the present application, the PTE access count value may be 0 or 1. 0 indicates that the PTE mapped by the anonymous page has not been accessed recently; 1 indicates that the PTE mapped by the anonymous page has been accessed recently.

[0095] In some embodiments of the present application, Figure 5 ,like Figure 7 As shown, the above step 203b can be specifically implemented through the following steps 203b1 to 203b3. It should be noted that the execution relationship between step 203b2 and step 203b3 is an "or" relationship.

[0096] Step 203b1: The electronic device performs PTE access count value detection on some anonymous pages in the locked group of anonymous pages for a group of anonymous pages in at least one group of anonymous pages, and obtains a PTE access count value corresponding to each anonymous page in the group of anonymous pages.

[0097] In some embodiments of the present application, in the case where some anonymous pages are anonymous pages in odd positions in a group of anonymous pages, if the number of anonymous pages contained in a group of anonymous pages is greater than or equal to 3, the electronic device can, based on the principle of similarity in locality of memory space access, first perform PTE access count value detection on the anonymous pages in odd positions in the group of anonymous pages to obtain the PTE access count value corresponding to each anonymous page in the partial anonymous pages.

[0098] It should be noted that the above-mentioned memory space access locality similarity principle means that in theory, it can be optimistically speculated that only consecutive PTEs in the same VMA are mapped and multiple anonymous pages with consecutive mounting order on the LRU linked list have the same PTEReferenced value. That is, PTE Referenced is 0 or 1.

[0099] For example, Figure 8 As shown, a partial anonymous page is an anonymous page in an odd position in a group of anonymous pages. Assume that a group of accumulated anonymous pages 3 contains 8 anonymous pages, and a group of accumulated anonymous pages 4 contains 4 anonymous pages. In the process of detecting the PTE access count value of the anonymous pages in the accumulated anonymous page 3, the electronic device can firstly detect the PTE access count value only for the anonymous pages in the odd positions of the 8 anonymous pages contained in the accumulated anonymous page 3, that is, the first, third, fifth and seventh anonymous pages. Similarly, in the process of detecting the PTE access count value of the anonymous pages in the accumulated anonymous page 4, the electronic device can firstly detect the PTE access count value only for the anonymous pages in the odd positions of the 48 anonymous pages contained in the accumulated anonymous page 4, that is, the first and third anonymous pages.

[0100] Step 203b2: When the PTE access count values ​​corresponding to each anonymous page in a group of anonymous pages are the same, the electronic device stops performing PTE access count value detection on the remaining anonymous pages in a group of anonymous pages, and determines the PTE access count values ​​corresponding to the partial anonymous pages as the PTE access count values ​​corresponding to the remaining anonymous pages.

[0101] In the embodiment of the present application, the remaining anonymous pages are anonymous pages in a group of anonymous pages except for some anonymous pages.

[0102] In some embodiments of the present application, when the partial anonymous pages are anonymous pages at odd positions in a group of anonymous pages, the remaining anonymous pages are anonymous pages at even positions in the group of anonymous pages.

[0103] In some embodiments of the present application, when the PTE access count values ​​corresponding to each anonymous page in an odd-numbered position in a group of anonymous pages are the same, it can be considered that the above-mentioned optimistic jump detection process of the PTE access count value is successful, and thus it is assumed that the PTE access count values ​​of all anonymous pages included in the group of anonymous pages are the same, and the PTE access count value detection of the group of anonymous pages is ended.

[0104] For example, in combination Figure 8 , assuming that the PTE access count values ​​obtained after the PTE access count value detection for the 1st, 3rd, 5th and 7th anonymous pages in the accumulated anonymous page 3 are all 0, then it can be assumed that the PTE access count values ​​corresponding to the 2nd, 4th, 6th and 8th anonymous pages in the accumulated anonymous page 3 are all 0, and the PTE access count value detection for the accumulated anonymous page 3 is stopped.

[0105] Step 203b3: When there are different PTE access count values ​​in the PTE access count values ​​corresponding to each anonymous page in some anonymous pages, the electronic device continues to perform PTE access count value detection on the remaining anonymous pages in a group of anonymous pages to obtain the PTE access count values ​​corresponding to the remaining anonymous pages.

[0106] In some embodiments of the present application, the above “there are different PTE access count values” can be understood as the detected PTE access count value contains both 0 and 1.

[0107] In some embodiments of the present application, when there are different PTE access count values ​​in the PTE access count values ​​corresponding to each anonymous page in some anonymous pages, it can be considered that the above-mentioned optimistic jump detection of the PTE access count value detection process has failed, and it cannot be assumed that the PTE access count values ​​of all anonymous pages included in the group of anonymous pages are the same. Therefore, the electronic device can use the jump detection method for the second time to perform PTE access count value detection on the anonymous pages that were not detected in the first jump detection process. Thereby, it is ensured that all anonymous pages in the group of anonymous pages have performed PTE access count value detection.

[0108] For example, in combination Figure 8 ,like Fig. 9 As shown, assuming that the PTE access count values ​​obtained after performing PTE access count value detection on the 1st, 3rd, 5th and 7th anonymous pages in the accumulated anonymous page 3 contain both 0 and 1, the electronic device needs to jump to detect the PTE access count values ​​of the anonymous pages ignored for the first time, that is, the electronic device needs to perform PTE access count value detection on the 2nd, 4th, 6th and 8th anonymous pages in the accumulated anonymous page 3, so as to finally obtain the PTE access count value corresponding to each anonymous page in the accumulated anonymous page 3.

[0109] It should be noted that the above steps 203b1 to 203b3 are still executed in groups, and different groups may need to execute different steps. In addition, for each group of anonymous pages in the above at least one group of anonymous pages, the above steps 203b1 to 203b3 may be executed to obtain the PTE access count value corresponding to each group of anonymous pages.

[0110] In an embodiment of the present application, when the PTE access count values ​​corresponding to some anonymous pages in a group of anonymous pages are the same, the electronic device can stop performing PTE access count value detection on the remaining anonymous pages in the group of anonymous pages. Therefore, in the process of performing PTE access count value detection on at least one group of anonymous pages, there is no need to perform PTE access count value detection on each anonymous page in each group of anonymous pages, which can reduce the number of PTE access count value detections required for at least one group of anonymous pages, thereby reducing the time-consuming overhead caused by the number of PTE access count value detections. In this way, the anonymous page recovery efficiency can be improved, and the efficiency of the electronic device in processing memory can be improved.

[0111] Step 203c: The electronic device performs Unmap processing on the anonymous page whose PTE access count value is the first value in each group of anonymous pages based on the PTE access count value.

[0112] It should be noted that the above Unmap process can be used to clear the PTE mapped by the anonymous page, which refers to the process of releasing the mapping relationship between the virtual memory address and the physical memory address.

[0113] In some embodiments of the present application, the first value may be 0.

[0114] It should be noted that if the PTE access count value corresponding to an anonymous page is 0, the anonymous page has not been accessed recently and meets the recycling conditions.

[0115] In the embodiment of the present application, since the locking process, PTE access count value detection and Unmap process are performed in groups in the process of performing Rmap processing on N anonymous pages, when a group of anonymous pages contains multiple anonymous pages, the multiple anonymous pages can be locked once, which can reduce the competition pressure caused by frequent locking during the Rmap process. In this way, the total time-consuming overhead of performing Rmap processing on N anonymous pages can be reduced, thereby improving the efficiency of electronic devices in processing memory.

[0116] It should be noted that the above-mentioned PTE access count value detection and Unmap processing are both implemented on the basis of Rmap processing traversing the VMA mapped by anonymous pages.

[0117] In the memory processing method provided in the embodiment of the present application, the first information of N anonymous pages in the first linked list is obtained, and the first information includes the PTE in the VMA mapped by the N anonymous pages; then, based on the obtained first information, the N anonymous pages can be grouped to obtain at least one group of anonymous pages; thus, the reverse mapping Rmap processing can be performed based on each group of anonymous pages. In this scheme, since the anonymous pages in the linked list can be mapped to the PTE in the VMA, for multiple anonymous pages in the linked list that are only mapped to continuous PTEs in the same VMA and are mounted in a continuous order on the linked list, it represents that the virtual addresses of these anonymous pages are continuous, so these anonymous pages can be used as a group of anonymous pages, so that the anonymous pages in the linked list are executed in groups. The specific processing process is performed on the anonymous pages in the linked list without sequentially performing Rmap processing on each anonymous page in the linked list, so the total number of times the electronic device needs to perform Rmap processing can be reduced, so that the total time-consuming overhead of performing Rmap processing on anonymous pages can be reduced, thereby improving the memory processing efficiency of the electronic device.

[0118] In some embodiments of the present application, after the above step 202, the memory processing method provided by the embodiment of the present application may further include the following step 301. Meanwhile, in combination with the above step 301, the above step 203 may be specifically implemented by the following steps 302 and 303.

[0119] Step 301: The electronic device marks M groups of anonymous pages in at least one group of anonymous pages as a first value, and marks K groups of anonymous pages in at least one group of anonymous pages as a second value.

[0120] In the embodiment of the present application, each group of anonymous pages in the above-mentioned M groups of anonymous pages includes one anonymous page, and each group of anonymous pages in the above-mentioned K groups of anonymous pages includes multiple anonymous pages.

[0121] Wherein, M and K are both positive integers.

[0122] In some embodiments of the present application, the electronic device may include a bitmap array.

[0123] It should be noted that the size of the bitmap array is SWAP_CLUSTER_MAX=32, and each bit element value can be used to record the anonymous page type of the corresponding position number on the isolate linked list.

[0124] In some embodiments of the present application, the anonymous page type may include at least one of the following: an accumulated anonymous page and a discrete anonymous page.

[0125] In some embodiments of the present application, if the bit element value is a first value, it can indicate that the anonymous page with the corresponding position number on the isolate linked list is a discrete anonymous page; if the bit element value is a second value, it can indicate that the anonymous page with the corresponding position number on the isolate linked list is an anonymous page in a group of accumulated anonymous pages.

[0126] In some embodiments of the present application, the first value may be 0, and the second value may be 1.

[0127] For example, in combination Figure 3 ,like Fig.10 As shown, in the case where the anonymous page on the isolate list is a discrete anonymous page, the bit element value of the corresponding position label of the anonymous page is 0, for example, the bit element value on the bitmap corresponding to the first anonymous page on the isolate list is 0; in the case where the anonymous page on the isolate list is an accumulated anonymous page, the bit element value of the corresponding position label of the anonymous page is 1, for example, the bit element value on the bitmap corresponding to the accumulated anonymous page 1 (i.e., the 3rd to 25th anonymous pages) on the isolate list is 1.

[0128] In an embodiment of the present application, since the electronic device can add different identifiers for different types of anonymous pages, in the subsequent processing process, the electronic device can perform different processing for different types of anonymous pages in a more targeted manner based on the numerical tags, thereby improving the efficiency of the electronic device in processing the memory.

[0129] Step 302: The electronic device obtains an anonymous page address of each group of anonymous pages in the M groups of anonymous pages, and performs Rmap processing on the group of anonymous pages based on the anonymous page addresses of the group of anonymous pages.

[0130] Step 303: The electronic device obtains a first parameter of a group of anonymous pages for each group of the K groups of anonymous pages, and performs Rmap processing on the group of anonymous pages based on the first parameter of the group of anonymous pages.

[0131] In the embodiment of the present application, the first parameter includes the number of anonymous pages and the anonymous page address of the first anonymous page.

[0132] In some embodiments of the present application, the value range corresponding to the number of anonymous pages NR included in the above-mentioned first parameter is [2, SWAP_CLUSTER_MAX].

[0133] In some embodiments of the present application, for any group of anonymous pages in the M groups of anonymous pages, since the number of anonymous pages included in a group of anonymous pages is 1, the electronic device can directly perform Rmap processing on a single anonymous page.

[0134] In some embodiments of the present application, for any group of anonymous pages in K groups of anonymous pages, since a group of anonymous pages contains multiple anonymous pages, the electronic device can directly obtain the first parameter of a group of anonymous pages corresponding to the anonymous page when detecting an anonymous page marked as 1, so as to perform Rmap processing, without having to obtain the anonymous page address of each anonymous page through detection and then perform Rmap processing.

[0135] In an embodiment of the present application, in the process of performing Rmap processing on an anonymous page, the electronic device can obtain the anonymous page address of the anonymous page. Since a group of anonymous pages includes multiple anonymous pages, the electronic device can perform Rmap processing for the group of anonymous pages based on the number of anonymous pages included in the group of anonymous pages and the anonymous page address of the first anonymous page, so that the total time-consuming overhead of performing Rmap processing on at least one group of anonymous pages can be reduced, thereby improving the efficiency of the electronic device in processing memory.

[0136] It should be noted that, for each group of anonymous pages in the at least one group of anonymous pages, the above steps 301 to 303 may be executed to perform Rmap processing on each group of anonymous pages.

[0137] The present application embodiment provides a memory processing method. Fig.11 FIG. 1 is a flowchart of a memory processing method provided by an embodiment of the present application. The memory processing method provided by an embodiment of the present application will be described exemplarily by taking an electronic device as an example. Fig.11 As shown, the memory processing method provided in the embodiment of the present application may include the following steps 1 to 13.

[0138] Step 1: The electronic device isolates up to 32 anonymous pages from the LRU linked list to the isolate linked list.

[0139] Step 2: The electronic device obtains the PTE in the VMA mapped by each anonymous page in the isolate list.

[0140] Step 3: The electronic device detects whether the anonymous page meets preset conditions.

[0141] In some embodiments of the present application, the above-mentioned preset condition is that the anonymous page maps multiple consecutive PTEs in the same VMA, and the mounting order on the LRU linked list is continuous.

[0142] Step 4: The electronic device regards multiple anonymous pages that meet preset conditions as a group of anonymous pages, and marks the corresponding bit elements in the bitmap as 1.

[0143] Step 5: The electronic device regards the single anonymous page that does not meet the preset condition as a group of anonymous pages, and marks the corresponding bit element in the bitmap as 0.

[0144] Step 6: The electronic device performs a locking process for each group of anonymous pages.

[0145] Step 7: The electronic device performs an optimistic jump PTE access count value detection on the anonymous pages at odd positions in a group of anonymous pages (such as anonymous page group A) whose bit elements are marked as 1 and whose number of anonymous pages is greater than or equal to 3.

[0146] Step 8: The electronic device detects whether the PTE count value corresponding to each anonymous page in the anonymous pages at odd positions is the same.

[0147] Step 9. When the PTE access count value corresponding to each anonymous page in the odd-numbered positions of the anonymous page group A is the same, stop performing PTE access count value detection on the anonymous pages in the even-numbered positions of the anonymous page group A, and determine the PTE access count value corresponding to the anonymous page in the odd-numbered position as the PTE access count value corresponding to the anonymous page in the even-numbered position.

[0148] Step 10. When there are different PTE access count values ​​in the PTE access count values ​​corresponding to each anonymous page in the odd-numbered positions in the anonymous page group A, continue to perform PTE access count value detection on the anonymous pages in the even-numbered positions in the anonymous page group A to obtain the PTE access count values ​​corresponding to the anonymous pages in the even-numbered positions.

[0149] Step 11: The electronic device detects the PTE access count value of each anonymous page in a group of anonymous pages (such as anonymous page group B) whose bit element is marked as 1 and the number of anonymous pages included is 2.

[0150] Step 12: The electronic device detects the PTE access count value of the anonymous page whose bit element is marked as 0.

[0151] Step 13: The electronic device performs Unmap processing on the anonymous pages with a PTE access count value of 0 in each group of anonymous pages based on the PTE access count value.

[0152] It should be noted that the above-mentioned method embodiments, or various possible implementation methods in each method embodiment, can be executed separately, or, under the premise that there is no contradiction, can also be executed in combination with each other. The specific implementation can be determined according to actual usage requirements, and the embodiments of the present application do not limit this.

[0153] It should be noted that the memory processing method provided in the embodiment of the present application can be executed by a memory processing device. In the embodiment of the present application, the memory processing device provided in the embodiment of the present application is described by taking the memory processing method executed by the memory processing device as an example.

[0154] Fig.12 A possible structural diagram of a memory processing device involved in an embodiment of the present application is shown. Fig.12 As shown, the memory processing device 70 may include: an acquisition module 71 , a grouping module 72 and an execution module 73 .

[0155] The acquisition module 71 is used to acquire first information of N anonymous pages in the first linked list; the first information includes page table entries PTE in the virtual memory area VMA mapped by the N anonymous pages, where N is a positive integer less than or equal to 32;

[0156] A grouping module 72, configured to group the N anonymous pages to obtain at least one group of anonymous pages based on the first information obtained by the obtaining module 71;

[0157] The execution module 73 is used to perform reverse mapping Rmap processing based on each group of anonymous pages obtained by the grouping module 72.

[0158] In a possible implementation, the grouping module 72 is specifically used to determine the anonymous pages that meet the preset conditions among the N anonymous pages as a group of anonymous pages to obtain at least one group of anonymous pages, wherein the preset conditions are that the anonymous pages map multiple consecutive PTEs in the same VMA, and the mounting order on the least recently used page replacement LRU linked list is continuous.

[0159] In a possible implementation, the Rmap processing includes locking processing, PTE access count value detection and unmap processing; the execution module 73 is specifically used to: perform a locking process on each group of anonymous pages; perform a PTE access count value detection on at least part of the anonymous pages in each group of anonymous pages after the locking process to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages; based on the PTE access count value, perform an Unmap process on the anonymous pages in each group of anonymous pages whose PTE access count value is the first value.

[0160] In a possible implementation, the execution module 73 is specifically used to: for a group of anonymous pages in at least one group of anonymous pages, perform PTE access count value detection on some anonymous pages in a group of anonymous pages after locking processing to obtain the PTE access count value corresponding to each anonymous page in the group of anonymous pages; when the PTE access count value corresponding to each anonymous page in the group of anonymous pages is the same, stop performing PTE access count value detection on the remaining anonymous pages in the group of anonymous pages, and determine the PTE access count value corresponding to the part of the anonymous pages as the PTE access count value corresponding to the remaining anonymous pages, and the remaining anonymous pages are the anonymous pages in the group of anonymous pages other than the part of the anonymous pages; or, when there are different PTE access count values ​​in the PTE access count value corresponding to each anonymous page in the part of the anonymous pages, continue to perform PTE access count value detection on the remaining anonymous pages in the group of anonymous pages to obtain the PTE access count value corresponding to the remaining anonymous pages.

[0161] In a possible implementation, the memory processing device 70 provided in the embodiment of the present application also includes: a marking module; a marking module, which is used to, after grouping N anonymous pages based on the first information to obtain at least one group of anonymous pages, mark M groups of anonymous pages in at least one group of anonymous pages as a first value, and mark K groups of anonymous pages in at least one group of anonymous pages as a second value, each group of anonymous pages in the M groups of anonymous pages includes one anonymous page, and each group of anonymous pages in the K groups of anonymous pages includes multiple anonymous pages, and M and K are both positive integers; the above-mentioned execution module 73 is specifically used to: for each group of anonymous pages in the M groups of anonymous pages, obtain the anonymous page addresses of a group of anonymous pages, and perform Rmap processing on the group of anonymous pages based on the anonymous page addresses of the group of anonymous pages; for each group of anonymous pages in the K groups of anonymous pages, obtain the first parameter of a group of anonymous pages, and perform Rmap processing on the group of anonymous pages based on the first parameter of a group of anonymous pages, the first parameter including the number of anonymous pages and the anonymous page address of the first anonymous page.

[0162] In the memory processing device provided in the embodiment of the present application, since the anonymous pages in the linked list can be mapped to the PTE in the VMA, for multiple anonymous pages in the linked list that are only mapped to consecutive PTEs in the same VMA and have a consecutive mounting order on the linked list, it represents that the virtual addresses of these anonymous pages are continuous. Therefore, these anonymous pages can be regarded as a group of anonymous pages, so that the specific processing process is performed on the anonymous pages in the linked list as a group, without the need to perform Rmap processing on each anonymous page in the linked list in turn, so the total number of times the memory processing device needs to perform Rmap processing can be reduced. In this way, the total time-consuming overhead of performing Rmap processing on anonymous pages can be reduced, thereby improving the memory processing efficiency of the memory processing device.

[0163] The memory processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.

[0164] The memory processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0165] The memory processing device provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.

[0166] Alternatively, if Fig.13 As shown, an embodiment of the present application further provides an electronic device 90, including a processor 91 and a memory 92, wherein the memory 92 stores programs or instructions that can be executed on the processor 91, and when the program or instructions are executed by the processor 91, the various steps of the above-mentioned memory processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.

[0167] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0168] Fig.14 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0169] The electronic device 100 includes but is not limited to components such as a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, and a processor 110.

[0170] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.14 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0171] Among them, the processor 110 is used to obtain the first information of N anonymous pages in the first linked list; the first information includes the page table entries PTE in the virtual memory area VMA mapped by the N anonymous pages, N is a positive integer less than or equal to 32; and based on the first information, the N anonymous pages are grouped to obtain at least one group of anonymous pages; and based on each group of anonymous pages, reverse mapping Rmap processing is performed.

[0172] Optionally, the processor 110 is specifically used to determine the anonymous pages that meet the preset conditions among the N anonymous pages as a group of anonymous pages, and obtain at least one group of anonymous pages, wherein the preset conditions are that the anonymous pages map multiple consecutive PTEs in the same VMA, and the mounting order on the least recently used page replacement LRU linked list is continuous.

[0173] Optionally, the above-mentioned Rmap processing includes locking processing, PTE access count value detection and unmap processing; the processor 110 is specifically used to perform a locking process on each group of anonymous pages; and perform a PTE access count value detection on at least part of the anonymous pages in each group of anonymous pages after the locking process to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages; and based on the PTE access count value, perform an Unmap process on the anonymous page whose PTE access count value is the first value in each group of anonymous pages.

[0174] Optionally, the processor 110 is specifically used to perform PTE access count value detection on some anonymous pages in a group of anonymous pages after locking processing for a group of anonymous pages in at least one group of anonymous pages, and obtain PTE access count values ​​corresponding to each anonymous page in the part of anonymous pages; and when the PTE access count values ​​corresponding to each anonymous page in the part of anonymous pages are the same, stop performing PTE access count value detection on the remaining anonymous pages in the group of anonymous pages, and determine the PTE access count values ​​corresponding to the part of anonymous pages as the PTE access count values ​​corresponding to the remaining anonymous pages, and the remaining anonymous pages are anonymous pages other than the part of anonymous pages in the group of anonymous pages; or, when there are different PTE access count values ​​in the PTE access count values ​​corresponding to each anonymous page in the part of anonymous pages, continue to perform PTE access count value detection on the remaining anonymous pages in the group of anonymous pages to obtain PTE access count values ​​corresponding to the remaining anonymous pages.

[0175] Optionally, the processor 110 is further used to, after grouping N anonymous pages based on the first information to obtain at least one group of anonymous pages, mark M groups of anonymous pages in the at least one group of anonymous pages as a first value, and mark K groups of anonymous pages in the at least one group of anonymous pages as a second value, each group of anonymous pages in the M groups of anonymous pages includes one anonymous page, and each group of anonymous pages in the K groups of anonymous pages includes multiple anonymous pages, and M and K are both positive integers; the processor 110 is specifically used to obtain anonymous page addresses of a group of anonymous pages for each group of anonymous pages in the M groups of anonymous pages, and perform Rmap processing on the group of anonymous pages based on the anonymous page addresses of the group of anonymous pages; and obtain a first parameter of a group of anonymous pages for each group of anonymous pages in the K groups of anonymous pages, and perform Rmap processing on the group of anonymous pages based on the first parameter of the group of anonymous pages, the first parameter including the number of anonymous pages and the anonymous page address of the first anonymous page.

[0176] In the electronic device provided in the embodiment of the present application, since the anonymous pages in the linked list can be mapped to the PTE in the VMA, for multiple anonymous pages in the linked list that are only mapped to consecutive PTEs in the same VMA and have a consecutive mounting order on the linked list, it represents that the virtual addresses of these anonymous pages are continuous. Therefore, these anonymous pages can be regarded as a group of anonymous pages, so that the specific processing process is performed on the anonymous pages in the linked list as a group, and there is no need to perform Rmap processing on each anonymous page in the linked list in turn. Therefore, the total number of times the electronic device needs to perform Rmap processing can be reduced. In this way, the total time-consuming overhead of performing Rmap processing on anonymous pages can be reduced, thereby improving the memory processing efficiency of the electronic device.

[0177] The electronic device provided in the embodiment of the present application can implement each process implemented in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0178] The beneficial effects of various implementations in this embodiment can be specifically referred to the beneficial effects of the corresponding implementations in the above method embodiment. To avoid repetition, they will not be described again here.

[0179] It should be understood that in the embodiment of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes a touch panel 1071 and at least one of other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0180] The memory 109 can be used to store software programs and various data. The memory 109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 109 may include a volatile memory or a non-volatile memory, or the memory 109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0181] The processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 110.

[0182] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0183] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0184] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0185] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0186] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0187] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0188] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0189] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A memory processing method, characterized in that: The method comprises: Acquire first information of N anonymous pages in the first linked list; the first information includes page table entries PTE in the virtual memory area VMA mapped by the N anonymous pages, where N is a positive integer less than or equal to 32; Based on the first information, grouping the N anonymous pages to obtain at least one group of anonymous pages; Based on each set of anonymous pages, a reverse mapping Rmap process is performed.

2. The method according to claim 1, characterized in that The step of grouping the N anonymous pages based on the first information to obtain at least one group of anonymous pages includes: Anonymous pages that meet a preset condition among the N anonymous pages are determined as a group of anonymous pages to obtain the at least one group of anonymous pages, wherein the preset condition is that the anonymous pages map multiple consecutive PTEs in the same VMA and are mounted in a consecutive order on a least recently used page replacement LRU linked list.

3. The method according to claim 1 or 2, characterized in that: The Rmap process includes locking process, PTE access count value detection and unmap process; The reverse mapping Rmap process is performed based on each group of anonymous pages, including: Execute the locking process once for each group of anonymous pages; Perform the PTE access count value detection on at least part of the anonymous pages in each group of anonymous pages after the locking process to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages; Based on the PTE access count value, the Unmap process is performed on the anonymous page whose PTE access count value is a first value in each group of anonymous pages.

4. The method according to claim 3, characterized in that The step of performing the PTE access count detection on at least part of the anonymous pages in each group of anonymous pages after the locking process to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages includes: For a group of anonymous pages in the at least one group of anonymous pages, perform the PTE access count value detection on some anonymous pages in the group of anonymous pages after the locking process to obtain a PTE access count value corresponding to each anonymous page in the part of anonymous pages; In the case where the PTE access count values ​​corresponding to each anonymous page in the partial anonymous pages are the same, stopping the PTE access count value detection for the remaining anonymous pages in the group of anonymous pages, and determining the PTE access count values ​​corresponding to the partial anonymous pages as the PTE access count values ​​corresponding to the remaining anonymous pages, the remaining anonymous pages being the anonymous pages in the group of anonymous pages except the partial anonymous pages; or, In the case that different PTE access count values ​​exist in the PTE access count values ​​corresponding to each anonymous page in the partial anonymous pages, the PTE access count value detection is continued to be performed on the remaining anonymous pages in the group of anonymous pages to obtain the PTE access count values ​​corresponding to the remaining anonymous pages.

5. The method according to claim 1, characterized in that After grouping the N anonymous pages to obtain at least one group of anonymous pages based on the first information, the method further includes: Marking M groups of anonymous pages in the at least one group of anonymous pages as a first value, and marking K groups of anonymous pages in the at least one group of anonymous pages as a second value, wherein each group of anonymous pages in the M groups of anonymous pages includes one anonymous page, and each group of anonymous pages in the K groups of anonymous pages includes a plurality of anonymous pages, and both M and K are positive integers; The reverse mapping Rmap process is performed based on each group of anonymous pages, including: For each group of anonymous pages in the M groups of anonymous pages, obtaining an anonymous page address of a group of anonymous pages, and performing the Rmap process on the group of anonymous pages based on the anonymous page addresses of the group of anonymous pages; For each group of anonymous pages in the K groups of anonymous pages, a first parameter of a group of anonymous pages is obtained, and based on the first parameter of the group of anonymous pages, the Rmap process is performed on the group of anonymous pages, wherein the first parameter includes the number of anonymous pages and the anonymous page address of the first anonymous page.

6. A memory processing device, characterized in that: The memory processing device comprises: an acquisition module, a grouping module and an execution module; The acquisition module is used to acquire first information of N anonymous pages in the first linked list; the first information includes page table entries PTE in the virtual memory area VMA mapped by the N anonymous pages, where N is a positive integer less than or equal to 32; The grouping module is used to group the N anonymous pages to obtain at least one group of anonymous pages based on the first information obtained by the obtaining module; The execution module is used to perform reverse mapping Rmap processing based on each group of anonymous pages obtained by the grouping module.

7. The device according to claim 6, characterized in that The Rmap process includes locking process, PTE access count value detection and unmap process; The execution module is specifically used for: Execute the locking process once for each group of anonymous pages; Perform the PTE access count value detection on at least part of the anonymous pages in each group of anonymous pages after the locking process to obtain the PTE access count value corresponding to each anonymous page in each group of anonymous pages; Based on the PTE access count value, the Unmap process is performed on the anonymous page whose PTE access count value is a first value in each group of anonymous pages.

8. The device according to claim 7, characterized in that The execution module is specifically used for: For a group of anonymous pages in the at least one group of anonymous pages, perform the PTE access count value detection on some anonymous pages in the group of anonymous pages after the locking process to obtain a PTE access count value corresponding to each anonymous page in the part of anonymous pages; When the PTE access count value corresponding to each anonymous page in the part of anonymous pages is the same, stop performing the PTE access count value detection on the remaining anonymous pages in the group of anonymous pages, and determine the PTE access count value corresponding to the part of anonymous pages as the PTE access count value corresponding to the remaining anonymous pages, the remaining anonymous pages being the anonymous pages in the group of anonymous pages except the part of anonymous pages; or, In the case that different PTE access count values ​​exist in the PTE access count values ​​corresponding to each anonymous page in the partial anonymous pages, the PTE access count value detection is continued to be performed on the remaining anonymous pages in the group of anonymous pages to obtain the PTE access count values ​​corresponding to the remaining anonymous pages.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the memory processing method as described in any one of claims 1 to 5 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the memory processing method according to any one of claims 1 to 5 are implemented.