Intelligent freezing method and device for memory repeated page fault

By identifying and freezing background applications with repeated page faults on resource-constrained mobile devices, and dynamically adjusting the freezing intensity, the problem of background applications affecting the foreground frame rate is solved, thus improving the user experience.

CN120085988BActive Publication Date: 2025-11-07江淮前沿技术协同创新中心 +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510194286.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-11-07
Estimated Expiration
2045-02-21

AI Technical Summary

Technical Problem

In resource-constrained low- to mid-range mobile devices, repeated page faults in background applications cause a drop in the frame rate of foreground applications, affecting user experience, and the existing memory management and process scheduling collaboration is insufficient.

Method used

The system identifies background applications that experience repeated page faults through a daemon process, freezes the processes to which they belong, and dynamically adjusts the freeze intensity based on memory pressure. It employs a heartbeat mechanism to divide the process into freeze and unfreeze phases, utilizes the Linux kernel interface to detect repeated page fault events, maintains an application-process mapping table, and sends freeze signals to achieve application-level freezing.

Benefits of technology

It significantly improved the user experience, increased the frame rate by 1.57 times, reduced the number of repeated page faults in background applications, and optimized the collaboration between memory management and process scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120085988B_ABST
    Figure CN120085988B_ABST
Patent Text Reader

Abstract

The application provides an intelligent freezing method and device for repeated memory page faults, which comprises three components, a daemon process, a process freezing based on repeated page faults driving and a memory-aware dynamic unfreezing. The daemon process is responsible for communication with the system module. The process freezing based on repeated page faults driving freezes the process to which the background application causing repeated page faults belongs. The memory-aware dynamic unfreezing maintains a heartbeat in the system. Each heartbeat cycle is divided into two stages: freezing period and unfreezing period. At the beginning of each cycle, the selected application is frozen and then unfreezed. The memory pressure state is monitored. When the memory pressure increases, the freezing period is extended. Conversely, it is shortened. It does not require invasive modification of mobile applications and hardware infrastructure. The results of experimental evaluation using real devices show that the application can significantly improve user experience. Specifically, compared with the prior art, the application increases the frame rate per second by 1.57 times on average.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of memory management and process scheduling, in particular to an intelligent freezing method and device for memory repeated page faults. BACKGROUND

[0002] There are relatively low-priced and resource-limited mobile devices in the market. It has been a great challenge for smart phone providers to provide good user experience for these resource-limited devices.

[0003] In a mobile system, when an application is running in the foreground, there are usually active applications in the background. Most users do not clean up these background applications, which consumes a lot of memory resources. When the memory is exhausted, the mobile system recycles the memory pages according to the design principle of Linux, such as LRU (Least Recently Used) algorithm. However, this memory activity of the background process has a negative impact on the foreground process.

[0004] Experiments have shown that when there are multiple background applications, the frame rate of the foreground application often drops to less than 30 frames per second. Analysis shows that first, CPU contention is not the main reason; second, although the background application does not use too much CPU, it often runs and needs to access memory pages; third, due to priority inversion, memory recycling affects the foreground application, and memory jitter caused by repeated page faults amplifies this effect; fourth, the problem in memory management is actually caused by incorrect process scheduling. Based on these observations, it is clear that good cooperation between memory management and process scheduling is necessary for the user experience of resource-limited mobile systems. SUMMARY

[0005] In order to overcome the problems existing in the above-mentioned technology, the purpose of the present application is to provide an intelligent freezing method and device for memory repeated page faults. The basic idea is to identify the background application with repeated page faults, freeze the process to which it belongs, and adjust the freezing strength according to the memory pressure. It consists of three key parts: daemon, process freezing based on repeated page faults, and memory-aware dynamic unfreezing.

[0006] The specific technical scheme to achieve the purpose of the present application is:

[0007] An intelligent freezing method for memory repeated page faults, comprising the following steps:

[0008] Step 1: maintain a heartbeat mechanism; each heartbeat period is divided into two stages: freezing stage and unfreezing stage; at the beginning of each period, the selected application is frozen for E f seconds, and then unfreezed for E tseconds; sending freeze and unfreeze signals to target processes at the beginning of each freeze phase and unfreeze phase; adjusting freeze intensity by adjusting phase ratio; monitoring memory pressure state, when memory pressure rises, extending freeze phase, otherwise shortening;

[0009] Step 2: detecting repeated page fault events in kernel space; specifically, when a page fault exception occurs, accessing the interface of Linux kernel to obtain the first _PAGE_PRESENT flag of the page table entry of the page, which indicates whether the page corresponding to the page table entry has been evicted from memory, if the flag is 1, it means that a repeated page fault event occurs;

[0010] Step 3: identifying the process to which the page belongs, and then judging whether the process can be frozen; specifically, obtaining the page table and virtual address of the page table entry through the page fault exception handling program to determine which process caused the page fault exception; checking the process type, if it is not a background process, or a kernel process or an Android service, it will not be frozen;

[0011] Step 4: for the frozen process, identifying which background application the process belongs to by consulting the application and process mapping table maintained in the kernel space, and then sending a freeze signal to the processes belonging to the application to achieve application-level freezing; if the repeated page fault occurs at time T within the freeze phase of the heartbeat cycle, i.e. 0 < T ≤ E f , the processes belonging to the application will be immediately frozen and unfrozen at E f , then allowed to run within the next E t seconds until the next cycle; if T occurs in the unfreeze phase, the processes belonging to the application will also be immediately frozen until the next cycle's unfreeze phase;

[0012] Step 5: after receiving the freeze signal, the process calls the function try_to_freeze() and enters the sleep state; after receiving the unfreeze signal, the process wakes up again.

[0013] Further, the adjustment of freeze intensity in step 1 is performed by adjusting the phase ratio, specifically including:

[0014] changing the ratio of E f to E t to dynamically adjust the freeze intensity; the ratio is adjusted according to the memory water level;

[0015] record the ratio R of E f to E t :

[0016]

[0017] where Hwm represents high water level, S am represents available memory size, δ is a weight coefficient; H will be determined in the system initialization phase wm , so when the available memory S am is very small, R will increase, thereby increasing the freezing strength to adapt to greater memory pressure; E t is set to a unit of time, i.e. 1 second; the length of the entire heartbeat cycle is adjusted by changing the value of E f .

[0018] Further, the application and process mapping table maintained in the kernel space in step 4 is composed of UID, PID and state information; the application will obtain a fixed UID after installation, and the PID is the ID number of the process; when the application is installed, deleted or started, the mapping table will be updated accordingly; the mapping table is stored in the kernel space so as to quickly retrieve the mapping table; the corresponding application UID can be obtained by using the process PID causing repeated page fault, so as to obtain all PIDs of the processes belonging to the application; only when the mapping table is updated, cross-space communication will be performed.

[0019] Further, the cross-space communication is performed only when the mapping table is updated, and specifically includes:

[0020] Application information is collected from the Android framework, and the information is transmitted to the kernel through the proc file system; in the file system, a function is predefined through file_operations (); when a protocol string is written to the / proc / {pid} / ice-mp node, the function is called; the function receives the application information, i.e. UID, PID and state, and updates the mapping table.

[0021] An intelligent freezing device for memory repeated page fault is used to implement the intelligent freezing method for memory repeated page fault, and specifically includes:

[0022] A daemon process module: communicates with the system; obtains the process ID, i.e. PID, of the repeated page fault background application, and transmits the PID to the process freezing module based on repeated page fault driving; monitors the current memory pressure, and transmits the memory pressure to the memory-aware dynamic unfreezing module;

[0023] A process freezing module based on repeated page fault driving: consults the application and process mapping table maintained in the kernel space to identify which background application the process ID belongs to, and then sends a freezing signal to the processes belonging to the application;

[0024] The memory-aware dynamic thaw module maintains a heartbeat mechanism, with each heartbeat cycle divided into two phases: a freeze phase and a thaw phase. At the start of each freeze and thaw phase, freeze and thaw signals are sent to the target process. The module monitors memory pressure and extends the freeze phase when memory pressure increases and shortens it when memory pressure decreases, thereby adjusting the freeze intensity.

[0025] Compared with existing technologies, the method proposed in this invention effectively reduces the number of repeated page faults in background applications, significantly improving the user experience. Experiments show that the frame rate per second is increased by 1.57 times. Attached Figure Description

[0026] Figure 1 A flowchart of the process freeze module based on repeated page faults;

[0027] Figure 2 This is a flowchart illustrating the operation of the device of the present invention. Detailed Implementation

[0028] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0029] Example

[0030] like Figure 2 The diagram shows the workflow of an intelligent freezing device for addressing repeated page faults. Three components are designed: a daemon process, a process freezing mechanism driven by repeated page faults, and a memory-aware dynamic unfreezing mechanism. The daemon process interacts with the system module, delivering the process ID (PID) causing the repeated page fault to the process freezing module and the monitored memory pressure information to the memory-aware dynamic unfreezing module.

[0031] See Figure 1 This is a flowchart of the process freezing module based on duplicate page faults according to the present invention. First, the system detects duplicate page faults in the kernel space through duplicate page fault event handling, identifies the process to which the page belongs, and determines whether the process can be frozen. Specifically, the Linux kernel interface is accessed to obtain the _PAGE_PRESENT flag bit at the beginning of the page table entry for that page. If this bit is 1, it indicates that a duplicate page fault has occurred. The page table and virtual address of the page table entry are obtained through the page fault exception handler, thus obtaining the corresponding process. The type is checked; if it is not a background process, a kernel process, or an Android service, it will not be frozen. Next, the freezeable PID is obtained through the daemon process and queried in the application-process mapping table to obtain the corresponding application ID (UID) and all PIDs belonging to that application. Finally, a freeze signal is sent to all processes belonging to that application, causing the target thread to sleep.

[0032] The memory-aware dynamic thawing module maintains a heartbeat mechanism. Each heartbeat cycle is divided into two phases: freeze phase and thaw phase. At the beginning of each cycle, the selected application is frozen for E f seconds and then thawed for E t seconds. The beginning of each freeze phase and thaw phase sends freeze and thaw signals to the target process. By obtaining the memory pressure information provided by the daemon process, the freeze intensity is adjusted. When the memory pressure rises, the freeze phase is extended, and vice versa.

[0033] This implementation requires two types of overhead: storage and performance overhead. The storage overhead includes the mapping table that needs to be maintained. For a device with 20 installed applications, each containing 3 processes, the maximum memory consumption is 13.8 KB, including 20x64B UID, 20x3x64B PID, 20x3x1B memory freeze state, and 20x3x64B memory priority score. If the application's life cycle ends, the corresponding object in the mapping table will be deleted. In this way, the proportion of the mapping table is controlled. In addition, for safety, an upper limit is set for the mapping table. The upper limit is set to 32 KB, which is sufficient to accommodate this information. In summary, the total memory consumption is at the 10 KB level. Compared with the total memory on a smartphone, this is negligible. The performance overhead is divided into three parts. First, it takes time to respond to repeated page fault events. Specifically, the daemon process module needs to obtain the PID, the process freeze module based on repeated page faults looks up the UID corresponding to the PID, and performs freezing. These operations are performed in an asynchronous manner so that page access will not be suspended. Second, the UID-PID mapping needs to be maintained. After the system starts, the daemon process module checks the configuration file in Android to obtain the UID of the installed application. The mapping table will be initialized at system startup and updated when an application is installed or started. When the life cycle of an application starts or ends, the process list in the mapping table needs to be updated. At the same time, when the freeze state changes, the application needs to index the corresponding UID and update the corresponding state in the table. Since the table is small in size, the application maintains the table in memory. Therefore, a table index can be completed at the μs level. Compared with the startup delay, the time consumption is negligible. The third part is the performance overhead caused by freezing. Thawing an application only takes tens of milliseconds, which is acceptable compared with the startup time. In addition, a series of optimizations have been made in the design of the application to minimize the penalty. For example, only active background applications are allowed to be frozen. Applications that do not have reclaimed pages or have reclaimed pages but do not have repeated page faults will not be frozen. Compared with the benefits, this overhead is acceptable.

Claims

1. An intelligent freezing method for memory-oriented repeated page fault, characterized in that, The method comprises the following steps: Step 1: maintain a heartbeat mechanism; each heartbeat cycle is divided into two stages: freeze stage and thaw stage; at the beginning of each cycle, the selected application is frozen for E f seconds, and then thawed for E t seconds; the beginning of each freeze stage and thaw stage sends freeze and thaw signals to the target process; adjusting the freezing intensity is done by adjusting the stage ratio; monitor the memory pressure state, when the memory pressure rises, extend the freeze stage, otherwise shorten it; Step 2: detecting repeated page fault events in the kernel space; specifically, when a page fault exception occurs, the first _PAGE_PRESENT flag of the page table entry of the page is obtained by accessing the interface of the Linux kernel, and the flag indicates whether the page corresponding to the page table entry has been evicted from the memory; if the flag is 1, it means that a repeated page fault event occurs; Step 3: identifying the process to which the page belongs, and then judging whether the process can be frozen; specifically, the page table and virtual address of the page table entry are obtained through the page fault exception handling program to determine which process causes the page fault exception; the process type is checked, and if it is not a background process, or a kernel process or an Android service, the process will not be frozen; Step 4: For the frozen process, identify which background application the process belongs to by looking up the application and process mapping table maintained in the kernel space, and then send a freeze signal to the processes belonging to the application to achieve application-granularity freezing; if the repeated page fault occurs at time T within the freeze phase of the heartbeat cycle, i.e. 0 < T ≤ E f , the processes belonging to the application will be immediately frozen and unfrozen at E f , and then allowed to run for the next E t seconds until the next cycle; if T occurs in the unfreeze phase, the processes belonging to the application will also be immediately frozen until the next cycle's unfreeze phase. Step 5: after receiving the freeze signal, the process calls the function try_to_freeze() and enters the sleep state; after receiving the unfreeze signal, the process wakes up again.

2. The smart freeze method of claim 1, wherein, The adjustment of the freezing intensity in step 1 is performed by adjusting the phase ratio, specifically including: Change E f With E t to dynamically adjust the freeze strength; the ratio is adjusted according to the water level in the memory; The ratio R of the value of E f to the value of E t ​ , where H wm represents the high water mark, S am represents the available memory size, and δ is a weight coefficient; H wm is determined in the system initialization phase, so that when the available memory S am is small, R will increase, thereby increasing the freezing strength and adapting to greater memory pressure; E t is set to a unit of time, i.e., 1 second; and the length of the entire heartbeat cycle is adjusted by changing the value of E f .

3. The smart freeze method of claim 1, wherein, The application and process mapping table maintained in the kernel space is composed of UID, PID and state information; after the application is installed, a fixed UID is obtained, and the PID is the ID number of the process; when the application is installed, deleted or started, the mapping table is updated accordingly; The mapping table is stored in the kernel space to enable quick retrieval of the mapping table; the PID of the process causing the repeated page fault is used to consult the mapping table to obtain the corresponding UID of the application, and thus the entire PID of the process belonging to the application is obtained; Cross-space communication is only performed when the mapping table is updated.

4. The smart freeze method of claim 3, wherein, The cross-space communication only when the mapping table is updated specifically includes: Application information is collected from the Android framework, and the information is transmitted to the kernel through the proc file system; in the file system, a function is predefined through file_operations(); when a protocol string is written to the / proc / {pid} / ice-mp node, the function is called; the function receives the application information, i.e., UID, PID and state, and updates the mapping table.

5. An intelligent freezing device for memory-oriented repeated page fault, used for implementing any one of the intelligent freezing methods for memory-oriented repeated page fault according to claims 1-4, characterized in that, Specifically including: The daemon process module: communicates with the system; obtains the process ID, i.e., PID, of the background application to which the repeated page fault belongs, and transmits the PID to the process freezing module based on the repeated page fault driver; monitors the current memory pressure and transmits the memory pressure to the memory-aware dynamic unfreezing module; The process freezing module based on the repeated page fault driver: consults the application and process mapping table maintained in the kernel space to identify which background application the process ID belongs to, and then sends a freeze signal to the processes belonging to the application; The memory-aware dynamic unfreezing module: maintains a heartbeat mechanism, and each heartbeat period is divided into two phases: a freezing phase and an unfreezing phase; a freeze signal and an unfreeze signal are sent to the target process at the beginning of each freezing phase and unfreezing phase; the memory pressure state is monitored, and when the memory pressure rises, the freezing phase is extended, and vice versa, to adjust the freezing intensity.

Citation Information

Patent Citations

  • Process freezing method and mobile terminal

    CN106648849A

  • Page missing exception processing method and device, electronic equipment and storage medium

    CN115543532A