CN114461405A - Storage method and related device for locking page in memory - Google Patents

Storage method and related device for locking page in memory Download PDF

Info

Publication number
CN114461405A
CN114461405A CN202210339963.9A CN202210339963A CN114461405A CN 114461405 A CN114461405 A CN 114461405A CN 202210339963 A CN202210339963 A CN 202210339963A CN 114461405 A CN114461405 A CN 114461405A
Authority
CN
China
Prior art keywords
page
lock
memory
target
electronic device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210339963.9A
Other languages
Chinese (zh)
Other versions
CN114461405B (en
Inventor
李鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Glory Smart Technology Development Co ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202210339963.9A priority Critical patent/CN114461405B/en
Publication of CN114461405A publication Critical patent/CN114461405A/en
Application granted granted Critical
Publication of CN114461405B publication Critical patent/CN114461405B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a method and a related device for storing a lock page in a memory, wherein the method is applied to electronic equipment, the memory of the electronic equipment comprises a lock page storage area and an exchange page storage area, and the lock page is stored in the lock page storage area, and the method comprises the following steps: the electronic equipment determines a target page in a lock page, wherein the lock page is a page locked in a memory of the electronic equipment, and the target page is a lock page which is not accessed in a target time period; the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released; the electronic device compresses the target page in the memory. The electronic equipment compresses the target page in the memory, so that the storage space occupied by the target page in the memory is reduced, the storage space with lower efficiency in a part of the memory is released, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.

Description

Storage method and related device for locking page in memory
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and a related apparatus for storing a locked page in a memory.
Background
In the process of reading the file data, the electronic device can preferentially search whether the target data is cached from the memory of the electronic device. When the target data exists in the memory, the electronic equipment can directly read the target data from the memory; when the target data does not exist in the memory, the electronic device can access other storage devices except the memory, read the target data in the storage devices into the memory, and then read the target data from the memory.
Generally, the memory space of the electronic device is limited, so that when the memory space is insufficient, the electronic device will usually recycle part of the storage space in the memory, so as to store new data by using the memory space occupied by the recycled part of the data. The data originally stored in the recycled storage space is deleted from the memory. However, these deleted data may be subsequently accessed by the electronic device again.
At present, in order to solve the above problem, electronic devices usually lock some preset core pages of a file in a memory, and these pages are called locked pages. The lock page is stably stored in the memory and is not deleted from the memory. However, in practical applications, common functions of different users on electronic devices are greatly different, and core functions provided by the electronic devices are not necessarily common functions of the users. Some pages in the lock pages are accessed frequently, and the pages waste the storage space of the memory, so that the use efficiency of the memory is reduced, and the performance of the electronic equipment is reduced.
Disclosure of Invention
The application provides a storage method and a related device for a locked page in a memory, which are used for improving the use efficiency of the memory, so that the performance of electronic equipment is improved.
In a first aspect, the present application provides a method for storing a lock page in a memory, where the method is applied to an electronic device, a memory of the electronic device includes a lock page storage region and an exchange page storage region, and a lock page is stored in the lock page storage region, and the method includes: the electronic equipment determines a target page in a lock page, wherein the lock page is a page locked in a memory of the electronic equipment, and the target page is a lock page which is not accessed in a target time period; the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released; the electronic device compresses the target page in the memory.
The method provided by the embodiment of the application can identify the use habits of different users according to the access information of the locked pages in the memory, so that the target pages which are not accessed frequently in the pages are locked according to the use habits of the different users. The target page may be a page that has not been accessed within the target time period. The electronic equipment can judge that the probability of the target page being accessed is low, so that the electronic equipment compresses the target page in the memory, the storage space occupied by the target page in the memory is reduced, a part of memory with low efficiency is released, the part of memory can be used for storing pages which are accessed frequently, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
As a possible implementation, the electronic device determines a target page in the lock page, including: at the starting time of the target time period, the electronic equipment marks a lock page; when a first page in the locked pages is accessed, the electronic equipment clears the mark of the first page; and at the end time of the target time period, the electronic equipment determines the locked page with the mark as the target page. The electronic equipment can directly identify the target page from the marks of the pages by marking the locked page at the starting time of the target time period and then deleting the marks of the accessed pages in the target time period.
As a possible implementation manner, the method for storing a lock page in a memory provided in the embodiment of the present application may further include: when the electronic device accesses the target page, the electronic device decompresses the target page and stores the target page in the lock page storage region. When a target page in the electronic device is accessed, the electronic device may decompress the accessed page and store the page, such as to lock the page memory region, so that the page is accessed again.
As a possible implementation, the starting time of the target time period is the time when the screen of the electronic device is lit. In practical applications, the electronic device may not be used for a period of time, and the electronic device may not be able to collect the access information of the locked page during the period of time. After the screen of the electronic device is lighted up, the electronic device starts to be used, and the electronic device starts to access the page at the moment.
As a possible implementation, the end time of the target time period is the time when the screen of the electronic device is turned off. In the embodiment of the application, the electronic device sets the end time of the target time period as the time when the screen of the electronic device is turned off, so that the electronic device can recover the determined target page when the screen is turned off, and the electronic device can be prevented from influencing the operation of other functions of the electronic device when the target page is recovered.
As a possible implementation, the electronic device determines a target page in the lock page, including: the electronic device periodically determines a target page in the lock page. The period for determining the target page by the electronic device may be a specific time period, or may also be an accumulated time period for the screen of the electronic device to be lit, or a time period corresponding to a preset number of software running on the electronic device, which is not limited herein.
As a possible implementation manner, after the system version of the electronic device is updated, the period of the electronic device for determining the target page in the lock page is shortened. After the system version of the electronic device is updated, the frequently accessed pages in the electronic device may be changed from the previous system version, and in order to timely identify the infrequently accessed pages in the locked pages, the electronic device may shorten the period for determining the target page.
The embodiment of the present application further provides a method for storing a lock page in a memory, where the method is applied to an electronic device, the memory of the electronic device includes a lock page storage region and an exchange page storage region, and the lock page storage region stores a lock page, and the method includes: the electronic equipment determines a target page in the lock pages, wherein the lock pages are pages locked in a memory of the electronic equipment, and the target page is a lock page with access time earlier than an access time threshold; the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released; the electronic device compresses the target page in the memory.
The method provided by the embodiment of the application can identify the use habits of different users according to the access information of the locked pages in the memory, so that the target pages which are not accessed frequently in the pages are locked according to the use habits of the different users. The electronic equipment can judge that the probability of the target page being accessed is low, so that the electronic equipment compresses the target page in the memory, the storage space occupied by the target page in the memory is reduced, a part of memory with low efficiency is released, the part of memory can be used for storing pages which are accessed frequently, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
As a possible implementation, the electronic device determines a target page in the lock page, including: the electronic equipment sorts the locked pages according to the morning and evening of the access time to obtain an ordered queue of the locked pages; and the electronic equipment determines the locked page with the access time being earlier than the access time threshold as the target page according to the ordered queue. In practical application, after the electronic device obtains the ordered queue of the locked pages, the pages ordered in the ordered queue can be determined as target pages, the ordering of the target pages is later than the ordering of other pages in the locked pages, and the percentage of the target pages in the locked pages can be a preset percentage.
As one possible implementation, when the electronic device accesses the target page, the electronic device decompresses the target page and stores the target page in the pinned-page memory region.
As a possible implementation, the electronic device stores the target page in the swap page memory area, including: and when the available memory of the electronic equipment is lower than a first memory threshold value, the electronic equipment stores the target page into the exchange page storage area.
As a possible implementation manner, the method for locking a page in a memory provided in the embodiment of the present application further includes: and when the available memory of the electronic equipment is higher than the second memory threshold value, decompressing the target page and storing the target page into the locked page storage area by the electronic equipment. In practical applications, when the available memory of the electronic device is higher than the second memory threshold, in order to enable the computing resources consumed by the electronic device when decompressing the cached target page not to affect the operation of other programs on the electronic device, the electronic device may decompress the target page and store the target page in the pinned page storage area when the CPU occupancy rate of the electronic device is smaller than the occupancy rate threshold.
According to the above method for storing a lock page in a memory, the present application further provides a device for storing a lock page in a memory, where the device is applied to an electronic device, the memory of the electronic device includes a lock page storage region and an exchange page storage region, and a lock page is stored in the lock page storage region, and the device includes: the first determining module is used for determining a target page in the locked pages, wherein the locked pages are pages locked in a memory of the electronic equipment, and the target page is a locked page which is not accessed in a target time period; the first storage module is used for storing the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released; and the first compression module is used for compressing the target page in the memory.
As a possible implementation manner, the first determining module is specifically configured to: marking a locked page at the starting time of a target time period; when a first page in the locked pages is accessed, clearing the mark of the first page; and determining the locked page with the mark as the target page at the end time of the target time period.
According to the above method for storing a lock page in a memory, the present application also provides a device for storing a lock page in a memory, where the device is applied to an electronic device, the memory of the electronic device includes a lock page storage region and an exchange page storage region, and the lock page storage region stores a lock page, and the device includes: the second determining module is used for determining a target page in the locked pages, wherein the locked pages are pages locked in a memory of the electronic equipment, and the target page is a locked page with access time earlier than an access time threshold; the second storage module is used for storing the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released; and the second compression module is used for compressing the target page in the memory.
As a possible implementation manner, the second determining module is specifically configured to: sequencing the locked pages according to the morning and the evening of the access time to obtain an ordered queue of the locked pages; and according to the ordered queue, determining the locked page with the access time being earlier than the access time threshold as the target page.
According to the above method for storing a locked page in a memory and the apparatus for storing a locked page in a memory, the present application also provides an electronic device, which includes a processor and a memory: the memory is used for storing a computer program; the processor is used for executing the storage method of the locked page in the memory according to the computer program.
According to the storage method of the locked page in the memory and the storage device of the locked page in the memory, the application also provides a computer readable storage medium, wherein the computer readable storage medium is used for storing a computer program, and the computer program is used for executing the storage method of the locked page in the memory.
According to the technical scheme, the method has the following beneficial effects:
the embodiment of the application provides a method and a related device for storing a lock page in a memory, wherein the method is applied to electronic equipment, the memory of the electronic equipment comprises a lock page storage area and an exchange page storage area, and the lock page is stored in the lock page storage area, and the method comprises the following steps: the electronic equipment determines a target page in a lock page, wherein the lock page is a page locked in a memory of the electronic equipment; the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the lock page storage area is released; the electronic device compresses the target page in the memory.
Therefore, the method provided by the embodiment of the application can identify the use habits of different users according to the access information of the locked pages in the memory, so that the target pages which are not frequently accessed in the locked pages are locked according to the use habits of different users. The target page may be a page that is not accessed in the target time period, or a page that is not accessed in the memory for a long time. The electronic equipment can judge that the probability of the target page being accessed is low, so that the electronic equipment compresses the target page in the memory, the storage space occupied by the target page in the memory is reduced, a part of memory with low efficiency is released, the part of memory can be used for storing pages which are accessed frequently, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings.
Fig. 1 is a software architecture diagram of an electronic device according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of a document page provided in an embodiment of the present application;
fig. 3 is an interface diagram of an electronic device according to an embodiment of the present disclosure;
fig. 4 is an interface diagram of another electronic device provided in the embodiments of the present application;
fig. 5 is an interface diagram of an electronic device according to an embodiment of the present application;
fig. 6 is an interface diagram of another electronic device provided in an embodiment of the present application;
fig. 7 is a software architecture diagram of an electronic device according to an embodiment of the present application;
FIG. 8 is a diagram illustrating a lock page memory region and a lock page swap region according to an embodiment of the present disclosure;
fig. 9 is a flowchart of a method for storing a locked page in a memory according to an embodiment of the present disclosure;
fig. 10 is a signaling diagram of a method for storing a lock page in a memory according to an embodiment of the present disclosure;
FIG. 11 is a schematic diagram of a lock page provided in an embodiment of the present application;
FIG. 12 is a schematic diagram of another lock page provided by an embodiment of the present application;
FIG. 13 is a diagram illustrating a lock page according to an embodiment of the present application;
FIG. 14 is a schematic illustration of another lock page provided by an embodiment of the present application;
FIG. 15 is a diagram illustrating a lock page provided by an embodiment of the present application;
fig. 16 is a signaling diagram of a method for storing a lock page in a memory according to an embodiment of the present application;
FIG. 17 is a diagram illustrating a lock page provided by an embodiment of the present application;
FIG. 18 is a schematic illustration of another lock page provided by an embodiment of the present application;
FIG. 19 is a diagram illustrating a lock page provided by an embodiment of the present application;
FIG. 20 is a schematic diagram of another lock page provided by an embodiment of the present application;
FIG. 21 is a diagram illustrating a lock page provided by an embodiment of the present application;
fig. 22 is a schematic diagram of a memory device with locked pages in a memory according to an embodiment of the present disclosure;
fig. 23 is a schematic diagram of another memory device with locked pages in memory according to an embodiment of the present disclosure.
Detailed Description
The terms "first", "second" and "third", etc. in the description and claims of this application and the description of the drawings are used for distinguishing between different objects and not for limiting a particular order.
In the embodiments of the present application, words such as "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
In order to better understand the solutions provided in the embodiments of the present application, an application scenario of the solutions provided in the embodiments of the present application is described first.
The method provided by the embodiment of the application is applied to electronic equipment, and the electronic equipment in the embodiment of the application can comprise a mobile phone, a tablet computer, a notebook computer and the like.
Referring to fig. 1, a diagram of a software architecture of an electronic device according to an embodiment of the present application is shown.
The software architecture of the electronic device may be a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the application takes an Android system with a layered architecture as an example, and exemplarily illustrates a software structure of an electronic device.
The layered architecture divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In an embodiment of the present application, as shown in fig. 1, a hierarchical architecture of Android includes: an application layer, a kernel layer, and a device layer, among others.
Below the application layer and the kernel layer are device layers, that is, hardware devices responding to each IO request, including various Storage devices, such as Multi Media Card (MMC)/Embedded multimedia card (eMMC), scsi (small Computer System interface) hard disk drive, Universal Flash Storage (UFS), and so on.
The application layer may be installed with a plurality of applications. Taking application 1 (APP 1) as an example, application 1 may initiate one or more access (read) requests in response to user operations. For example, in the process of playing a video, an application program executing the function of playing the video may initiate a data access request, and in response to the request, the application program may read video data stored in the storage device, thereby playing the video.
Specifically, the initiated access request may pass through a file system of the kernel layer to reach a read-write scheduling layer (IO scheduler layer) in a Block (Block). The file system may include a Virtual File System (VFS), a Page Cache (Page Cache), a Flash friendly file system (F2 FS), an extensible read-only file system (EROFS), and a fourth generation extended file system (ext 4), and the like. The VFS is a kernel software layer, an interface layer between the physical file system and the service, and abstracts all details of the file system, so that different secondary file systems look the same to other processes running in the system. The size of the page cache is one page, i.e., 4K. When the system reads and writes files, it is used to cache the logical contents of the files, thereby speeding up the access to the images and data on the storage device. F2FS is used for configuring disk layout, selecting allocation and cleaning algorithm, and optimizing IO data read-write performance. The EROFS is used to save memory space while ensuring end-to-end performance of embedded devices. ext4 is used to provide file logging functionality. F2FS, EROFS and ext4 are all specific file system types and have independent file management rules, and one or more file system types can be selected by a storage system of the electronic device. For each mounted file system, the VFS generates a block structure (block) in the kernel, which represents an already mounted file system for storing control information of the file system, such as file system type, size.
The mapping between the file and the memory is managed by page (page), and the page size is usually 4K. A file is generally composed of multiple pages of data, and a page of data in a file may be referred to as a page. The memory also includes a storage space for storing a plurality of pages. As shown in FIG. 2, the file A includes page A1, page A2, page A3, page A4 and page A5. When memory accesses data in file a, typically in units of pages, for example, memory can access pages a2, A3, and a4 in file a. At this time, the memory stores the a2 page, the A3 page and the a4 page in the file a into 1 page, 2 pages and 3 pages of the memory, respectively, and then the electronic device can directly read the a2 page, the A3 page and the a4 page from the memory.
For an IO access request, the storage system may search in a memory of the storage device whether a page corresponding to the request exists. When the page exists in the memory, the storage system can directly read the page from the memory; when the page does not exist in the memory, the storage system can access the file stored in the external memory, read the page searched from the file into the memory, and then read the page from the memory.
Because the memory space in the storage system is limited, when the memory space is insufficient, the mobile phone usually recovers a part of pages in the memory so as to store new data by using the pages occupied by the recovered part of pages. And deleting the data corresponding to the recycled page from the memory. But if the deleted pages are quickly re-accessed by the mobile phone, the memory loads the part of pages into the memory again. Thus, a part of the pages in the memory are repeatedly swapped in and out of the memory, which is called page thrashing. The page jitter will increase the access amount of the external memory, and the access speed of the external memory is slow, thereby possibly causing the phenomenon that the mobile phone is jammed in operation.
To avoid this, electronic devices typically lock some of the core memory pages in memory, which are referred to as lock pages. The lock page is stably stored in the memory and cannot be deleted from the memory, such as an mlock function in a Linux system. However, in practical applications, common functions of different users on electronic devices are greatly different, and core functions provided by the electronic devices are not necessarily common functions of the users. This results in a low frequency of accesses to some of the locked pages in the user's electronic device, which waste memory space.
Taking an electronic device as an example of a mobile phone, if a user a usually only uses the mobile phone to play a game, about 30% of pages related to the game in the locked pages of the mobile phone of the user a are accessed more frequently, and other 70% of pages are accessed less frequently, and the memory space corresponding to the part of pages is left unused by the mobile phone. When a user a uses a mobile phone to play a game requiring more memory resources, the mobile phone may not apply for a sufficient amount of memory for the game because a lock page in the mobile phone cannot be deleted from the memory, which affects the smoothness of the game running on the mobile phone. Therefore, on one hand, a part of memory space exists in the mobile phone memory of the user a and is idle, and on the other hand, the mobile phone of the user a cannot provide enough memory space for running software.
In practical applications, suppose that the user b installs a plurality of different types of applications in the mobile phone, including a social application, a navigation application, a shopping application, a game application, and the like. And when the user b uses the mobile phone, different applications are often switched to use, so that the access frequency of only 80% of pages is higher and the access frequency of 20% of pages is lower in the locked pages of the mobile phone of the user b. Therefore, the mobile phone of the user b still has the problem that part of the memory space occupied by the lock page is idle.
In order to solve the above problem, the present application provides a method and a related apparatus for storing a lock page in a memory, where the method includes: the electronic device obtains access information of a lock page in a memory, wherein the lock page is a page locked in the memory of the electronic device. And the electronic equipment determines a target page which is not frequently accessed by the electronic equipment in the locked page according to the access information. After the target page is determined, the electronic device compresses the target page in the memory. Therefore, according to the method provided by the embodiment of the application, the target page which is accessed infrequently in the pages can be locked according to the access information of the locked pages in the memory and the use habits of different users. And then the electronic equipment compresses the target page in the memory, so that the storage space occupied by the target page in the memory is reduced, a part of memory with lower efficiency is released, the part of memory can be used for storing the page with higher access frequency, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
The method for storing the lock page in the memory provided by the embodiment of the application can be applied to electronic equipment as a lock page management function. Taking a mobile phone as an example, the mobile phone may turn on the lock page management function by default. The user can also set the lock page management function in the mobile phone, and when the user wants to open or close the lock page management function of the mobile phone, as shown in fig. 3, the user can click the setting software on the main display interface of the mobile phone. As shown in fig. 4, the mobile phone will display a plurality of configurable functions, including wlan, bluetooth, cellular, personal hotspot and memory configuration. The user finds the function of the memory setting in the memory setting and opens the memory setting. As shown in fig. 5, after the user opens the memory setting, the mobile phone displays the lock page management function. The user can turn on or off the lock page management function by sliding the switch of the lock page management function. For example, in FIG. 5 the user may slide the slide switch of the lock page management function to the right to turn on the lock page management function.
In actual applications, the user may have turned off the lock page management function. However, if the mobile phone detects that the memory of the mobile phone is insufficient and the performance of the mobile phone is affected, the mobile phone can remind the user to start the locked page management function in a popup mode so as to improve the speed of accessing data by the mobile phone. As shown in fig. 6, the mobile phone may popup into a display interface to display that "it is detected that your mobile phone is running at a slow speed, and whether to start a lock page management function, so as to improve the performance of the mobile phone
Figure 55050DEST_PATH_IMAGE001
". If the user agrees to open the function and clicks the 'yes' case below, the mobile phone can automatically open the lock page management function.
The following describes a software architecture of a method for locking a file in a memory according to an embodiment of the present application. As shown in fig. 7, an electronic device provided in an embodiment of the present application may include an application layer 100, an application framework layer 200, and a kernel layer 400. The application layer 100 includes a plurality of Applications (APPs), such as a camera, a calendar, a map, and settings, among others. The application framework layer 200 includes an efficiency control module 201. When the system running in the electronic device is an android system, the electronic device further includes a system library 300. The system library 300 includes a surface manager, a three-dimensional graphics processing library, a two-dimensional graphics engine, a media library, and the like. The kernel layer 400 includes an identification module 401, a recycle module 402, a restore module 403, a lock page management module 404, and a swap page management module 405. As shown in fig. 8, the memory in the embodiment of the present application may include two storage areas, a lock page storage area and a lock page swap area. The lock page memory region is managed by lock page management module 404. The lock page swap area is managed by swap page management module 405. After the lock page management function is turned on, the application program of the application layer 100 sends an open instruction to the efficiency control module. After receiving the start instruction, the efficiency control module 201 sends an identification instruction to the identification module 401. After receiving the identification instruction, the identification module 401 identifies a target page in the lock page according to the access information of the lock page. The efficiency control module 201 also sends a recovery instruction to the recovery module 402, and after receiving the recovery instruction, the recovery module 402 identifies the information of the target page in the lock page storage area and recovers the target page to the lock page exchange area according to the information of the target page. The swap page management module 405 compresses the target page and locks the compressed target page in the memory. The efficiency control module 201 also sends a recovery instruction to the recovery module 403. After receiving the recovery instruction, the recovery module 403 recovers the page to be recovered to the locked page storage area according to the recovery instruction. The lock page management module 404 locks the restored page in memory.
In order to better understand the storage method of the lock page in the memory provided by the embodiment of the present application, the storage method of the lock page in the memory provided by the embodiment of the present application will be specifically described below with reference to the accompanying drawings.
Referring to fig. 9, a flowchart of a method for storing a locked page in a memory according to an embodiment of the present application is shown.
As shown in fig. 9, a method for storing a lock page in a memory provided in an embodiment of the present application includes:
s901: the electronic equipment determines a target page in a lock page, wherein the lock page is a page locked in a memory of the electronic equipment.
The target page in the embodiment of the present application may be a lock page that is not accessed in the target time period, or may be a lock page whose access time is earlier than an access time threshold, which is not limited herein. The target time period in the embodiment of the present application may be set according to an actual situation of file access, and as an example, the target time period may be one day. The access time threshold in the embodiment of the present application may be determined according to an actual situation of file access, and as an example, the access time threshold may be 5000 s. When the target page is a locked page that has not been accessed within the target time period, the following step S1003 may be referred to in a specific implementation manner corresponding to the step S901. When the target page is a lock page with an access time earlier than the access time threshold, the following step S1603 may be referred to in a specific embodiment corresponding to step S901.
The electronic equipment can identify the use habits of different users according to the access information of the locked page in the memory, so that the target page in the locked page is determined according to the use habits of different users. The memory in the embodiment of the present application may include two storage regions, a lock page storage region and a lock page swap region. The specific description is shown in fig. 8, and the embodiments of the present application are not described herein again. Since the access information is used for determining the target page in the lock page in the page storage region, the electronic device can obtain only the access information of the lock page in the lock page storage region when obtaining the access information of the lock page. It should be noted that the lock page in the embodiment of the present application may be one page, or may be multiple pages; the target page in the embodiment of the present application may be one page or multiple pages, and the embodiment of the present application is not limited herein.
S902: the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released.
After the target page is determined, the electronic device may swap the target page from the lock page memory region into the swap page memory region. As one example, if the lock page includes page A, page B, page C, and page D, page A, page B, page C, and page D are stored in the lock page memory region; when the electronic equipment determines that the page A, the page B and the page C are target pages, the electronic equipment compresses the page A, the page B and the page C and replaces the page A, the page B and the page C into a locked page exchange area. The specific implementation of step S902 may be described with reference to steps S1004 to S1005, or S1604 to S1605.
S903: the electronic device compresses the target page in the memory.
The present embodiment does not limit the order of step S902 and step S903. It should be noted that the electronic device may compress the target page in the lock page storage region, and then swap the compressed target page from the lock page storage region into the lock page swapping region. The electronic device may also swap the target page from the lock page storage area to the lock page swapping area, and compress the target page in the lock page swapping area, which is not limited herein. The specific implementation of step S903 may be described with reference to step S1006 or step S1606.
The method provided by the embodiment of the application can identify the use habits of different users according to the access information of the locked page in the memory, so that the target page which is accessed infrequently in the locked page is determined according to the use habits of different users. And then the electronic equipment compresses the target page in the memory, so that the storage space occupied by the target page in the memory is reduced, a part of storage space with lower efficiency in the memory is released, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
When the electronic device compresses the target page, the page may still be accessed. As one possible implementation, when the compressed target page is accessed, the electronic device may decompress the target page in memory. In practical application, the electronic device may further transfer the target page from the lock page swapping area to the lock page storage area for storage. It should be noted that the electronic device may decompress the target page in the lock page swap area, and then transfer the target page from the lock page swap area to the lock page storage area for storage. The electronic device may also transfer the target page from the lock page swap area to the lock page storage area, and then decompress the target page in the lock page storage area, which is not limited herein. As an example, if the target page includes page A, page B, and page C, page A, page B, and page C are compressed for storage in the lock page swap area; when page B is accessed, the electronic device may decompress page B and transfer page B from the lockpage swap area to the lockpage memory area for storage, while page a and page C may remain compressed for storage in the lockpage swap area.
In order to better understand the method for storing the locked page in the memory provided by the embodiment of the present application, the method will be described below by using two examples.
Referring to fig. 10, a signaling diagram of a method for storing a lock page in a memory according to an embodiment of the present application is shown.
As shown in fig. 10, the method for storing a lock page in a memory provided in the embodiment of the present application includes:
s1001: the electronic equipment starts a lock page management function.
It should be noted that the electronic device may automatically start the lock page management function, and the electronic device may also start the lock page management function in response to a start operation of a user. In practical applications, step S1001 is an optional step, and the electronic device may not perform step S1001, that is, the electronic device may default that the lock page management function is in an on state.
S1002: the efficiency control module 201 sends an identification instruction to the identification module 401.
The efficiency control module 201 in the embodiment of the present application may be located in the application framework layer 200 of the electronic device, and the identification module 401 may be located in the kernel layer 400 of the electronic device. After the efficiency control module 201 receives the instruction to start the lock page management function, the efficiency control module 201 sends an identification instruction to the identification module 401. In this embodiment of the application, the time when the efficiency control module 201 sends the identification instruction to the identification module 401 is the starting time of the target time period, and the identification module 401 identifies the target page that is not accessed in the lock page in the target time period, where the target page may also be referred to as a cold page.
In order to make the determined target page fit the current operation habit of the electronic device, as a possible implementation, the electronic device may periodically update the cold page. Specifically, the efficiency control module 201 may send an identification instruction to the identification module 401 when each cycle is started, so that the identification module 401 identifies the target page in the target time period corresponding to each cycle. The duration of the period may be equal to or greater than the duration of the corresponding target time period, which is not limited herein in this embodiment of the application. When the duration of the period is equal to the duration of the target time period corresponding to the period, the efficiency control module 201 sends an identification instruction to the identification module 401 at the beginning of the period, the identification module 401 starts to acquire access information of the locked page immediately after receiving the identification instruction until the period is finished, and the locked page which is not accessed in the period is determined as the target page, i.e., the cold page. For convenience of understanding, a specific scheme will be described below with the period of the cycle being equal to the period of its corresponding target period as an example.
The duration of each period in the embodiment of the present application may be preset by a developer of the electronic device, or may be set by a user of the electronic device, which is not limited herein. As an example, the duration of the period may be 10 hours or one day. Generally, the longer the cycle, the fewer pages of the locked pages that are not accessed, i.e., the fewer cold pages identified by the identification module 401. As a possible implementation, the electronic device may also shorten or increase the period according to the usage habits of the user. As one example, if the electronic device is used more frequently during the day and less frequently during the night, the electronic device may shorten the period for determining the target pages during the day and increase the period for identifying the target pages during the night.
The duration of the target time period may be a specific time period, and in some embodiments, the target time period may also be an accumulated duration of the screen-up of the electronic device. In practical applications, the electronic device may not be used for a period of time, and the identification module 401 may not be able to collect the access information of the locked page during the period of time. I.e. there may be an invalid period of time within the target time period. To solve this problem, the efficiency control module 201 may count the cumulative time period for which the screen of the electronic device is lit. As an example, the efficiency control module 201 may start a cycle when the electronic device is powered on, and send an identification instruction to the identification module 401, and the identification module 401 starts to identify the target page in the lock page storage area. When the electronic device is turned off, the efficiency control module 201 counts the accumulated time length of the electronic device screen being turned on from the current period turning-on time to the electronic device turning-off time. When the accumulated time length reaches the time length of the target time period, the efficiency control module 201 sends a recovery instruction to the recovery module 402, the recovery module 402 recovers the target page, and the current cycle is finished. When the screen of the electronic device is turned on again, the efficiency control module 201 determines that the next period starts and sends the identification instruction to the identification module 401 again, and the steps are repeated in this way until the lock page management function is turned off.
In the foregoing embodiment, the efficiency control module 201 in this embodiment starts to count the cumulative duration of the electronic device screen being turned on only after the electronic device is turned off, and sends a recycling instruction to the recycling module 402 when the cumulative duration reaches the duration of the target time period, so that the recycling module 402 recycles the target page. Because the recycling module 402 needs to occupy part of system resources of the electronic device in the process of recycling the target page, in this embodiment of the application, the recycling module 402 usually recycles the target page when the electronic device is turned off, and it is possible to avoid that the recycling module 402 affects the operation of other functions of the electronic device when recycling the target page.
As an example, assume that the target time period is 10 hours. When the electronic device is powered on, the efficiency control module 201 determines that the period starts and sends an identification instruction to the identification module 401, and the identification module 401 marks a lock page in the lock page storage area. After the electronic device is turned on, the screen of the electronic device is turned off after being turned on for 4 hours, and the identification module 401 clears the mark of the lock page accessed within the 4 hours. After the electronic device is turned off, the accumulated time for turning on the screen of the electronic device does not increase any more, and the identification module 401 does not clear the mark for locking the page until the screen of the electronic device is turned on. Assuming that the electronic device lights up again for 6 hours after being turned off, the identification module 401 clears the indicia of the locked page that was accessed within the 6 hours. After the electronic device is turned off again, the efficiency control module 201 determines that the cumulative duration of the on-screen of the electronic device has reached the duration of the target time period. The efficiency control module 201 sends a recovery instruction to the recovery module 402, and the recovery module 402 recovers the target page still having the mark, and the current cycle is finished.
The duration of the target time period may also be a time period corresponding to the time period when the number of the software running on the electronic device reaches a preset number. It should be understood that after the electronic device is switched among a plurality of application scenarios, the electronic device still does not access the target page, which indicates that the target page has a low probability of being used and the probability of being subsequently accessed is low, and the electronic device may be determined to be a cold page. As an example, when the preset number is N, the identification module 401 starts to collect access information of the locked page, and the identification module 401 will maintain this state until the efficiency control module 201 detects that the electronic device has run N software accumulatively, and the efficiency control module 201 sends the identification instruction to the identification module 401 again to start a new period.
In practical applications, step S1002 is an optional step, and the recognition module 401 may autonomously start recognition of the target page on the premise of not receiving the recognition instruction sent by the efficiency control module 201. For example, the recognition module 401 may autonomously mark the locked page at a fixed period without the need for the efficiency control module to trigger it.
S1003, carrying out: the identification module 401 marks the lock page in the lock page storage area and clears the mark of the lock page to be accessed at the next time.
The identification module 401 may be located at the core layer 400 of the electronic device. When the target period starts, the recognition module 401 receives the recognition instruction transmitted from the efficiency control module 201 and then marks a lock page in the lock page storage area. After all of the lock pages in the lock page storage area are marked, the identification module 401 will clear the mark of a page when that page in the lock page is accessed. As such, at the end of the target time period, the identification module 401 may determine the locked page for which the flag is still present as a cold page that has not been accessed during the period.
As an example, assume that the lock page memory region stores Page 1, Page 2, Page 3, Page 4, and Page 5. As shown in fig. 11, after receiving the identification instruction, the identification module 401 adds FLAGs to pages 1, 2, 3, 4, and 5, respectively. As shown in fig. 12, during the target time period, if page 2, page 3, and page 5 have been accessed, the identification module 401 clears FLAG in page 2, page 3, and page 5. Therefore, at the end of the target time period, FLAGs FLAG still exist for pages 1 and 4, but no FLAGs exist for pages 2, 3, and 5. At this point, identification module 401 may determine that page 1 and page 4 are cold pages.
S1004: the efficiency control module 201 sends a recycle instruction to the recycle module 402.
The recycling module 402 may be located at the core layer 400 of the electronic device. The efficiency control module 201 sends an identification instruction to the identification module 401 at the beginning of the target time period, and at the end of the target time period, the identification module 401 already identifies the target page in the lock page storage area, and at this time, the efficiency control module 201 sends a recovery instruction to the recovery module 402, so that the recovery module 402 recovers the target page in the lock page storage area.
It should be noted that the identification instruction and the recovery instruction in the embodiment of the present application generally correspond to each other. When the electronic device periodically updates the cold page, the efficiency control module 201 may send an identification instruction to the identification module 401 at the start of each cycle and send a recycle instruction to the recycle module 402 at the end of each cycle. As such, the recognition module 401 may periodically recognize the target page, and in particular, the recognition module 401 may start recognizing the target page at every cycle on. The recycling module 402 may also recycle the target page periodically, and specifically, the recycling module 402 may recycle the target page at the end of each period, so that the target page may be recycled by the recycling module 402 in time, thereby releasing a part of the memory space.
It should be noted that the period for the recycling module 402 to recycle the target page may be a specific time period, or may also be a cumulative time length for the electronic device to turn on the screen, or a time period corresponding to a preset number of software running on the electronic device, and the specific implementation manner is shown with reference to step S1002, which is not described herein again in this embodiment of the present invention.
Similar to step S1002, step S1004 in this embodiment is also an optional step, and the recovery module 402 in this embodiment may autonomously start recovery of the target page on the premise of not receiving the recovery instruction sent by the efficiency control module 201. For example, the recycle module 402 may autonomously recycle the target page at a fixed period without being triggered by the efficiency control module.
S1005: the recycle module 402 recycles the target page in the locked page storage area that still has the tag.
At the end of the target time period, the recycle module 402 receives the recycle instruction sent by the efficiency control module 201, and recycles the page with the mark still in the lock page storage area. As shown in fig. 13, the lock page storage area stores page 1, page 2, page 3, page 4, and page 5. The FLAGs FLAG are still present in the locked page memory areas page 1 and page 4, and no FLAGs are present in page 2, page 3, and page 5. The recycling module 402 receives the recycling instruction sent by the efficiency control module 201, and then recycles the page 1 and the page 4 to the swap page storage area. At this time, the lock page memory area stores only page 2, page 3, and page 5, and the swap page memory area stores page 1 and page 4. As one possible implementation, the electronic device may define a maximum space for the swap page memory area, and the reclamation module 402 may abort reclaiming the target page when the swap page memory area is full.
After the current period is finished, when the next period is started, the efficiency control module 201 sends an identification instruction to the identification module 401 at the starting time of the target time period. As shown in fig. 14, the identification module 401 marks page 2, page 3, and page 5 in the lock page storage region, and does not mark page 1 and page 4 in the swap page storage region.
S1006: the swap page management module 405 compresses and locks the target page in the swap page storage area.
The swap page management module 405 may be located at the kernel layer 400 of the electronic device. The swap page management module 405 is mainly used to manage pages in the swap page storage area. After the recycle module recycles the target page into the swap page storage area, the swap page management module 405 may recycle the target page to the memory or other storage devices. When the swap page management module 405 retrieves the target page to another storage device, the target page does not occupy the memory space, so that the memory space of the electronic device may be directly saved. When the swap page management module 405 reclaims the target page to the memory, the swap page management module 405 may compress and lock the target page in the swap page storage area. On one hand, as the target page is compressed, the memory space occupied by the target page is reduced, and the storage space of the memory can be saved to a certain extent. On the other hand, since the target page is a lock page in the electronic device, a plurality of applications in the electronic device may access the lock page. Even if the application program used by the user does not access the target page within a period of time, deleting the target page in the memory can slow down the speed of accessing the target page by the device, and influence the running of other application programs in the electronic device. According to the scheme provided by the embodiment of the application, the target page is compressed and locked in the memory, so that the speed of the electronic equipment for accessing the target page is increased. Because the target page is still compressed in the memory, when the electronic device accesses the target page, the target page can be directly decompressed and accessed in the memory. The electronic device accesses the compressed target page in the memory directly faster than accessing the target page in other storage devices.
As a possible implementation manner, the swap page management module 405 provided in this application embodiment may also directly compress the target page in the swap page storage area, but does not lock the target page, which is not limited herein. When the swap page management module 405 does not lock the target page, the target page is still compressed in the swap page storage area, which still saves the storage space of the memory. Before the target page is recycled by the memory, the electronic equipment can still access the target page at a higher speed.
S1007: the restore module 403 restores the page in the swap page memory region to the lock page memory region when it is detected that the page is accessed.
The recovery module 403 may be located at the core layer 400 of the electronic device. When the electronic device accesses a page in the swap page memory region, the restore module 403 can decompress the page and restore the page to the lock page memory region. As an example, as shown in FIG. 15, Page 1 and Page 4 are compressed for storage in the swap page memory area; when page 1 is accessed, the restore module 403 may decompress page 1 and transfer page 1 from the pinned page swap area to the pinned page memory area for storage. And since page 1 has just been accessed, the identification module 401 may also eliminate the tag for page 1. Since page 4 is not being accessed, page 4 is still compressed for storage in the locked page swap area.
S1008: the lock page management module 404 locks pages in the lock page storage area.
The lock page management module 404 may be located at the kernel layer 400 of the electronic device. The lock page management module 404 is primarily used to manage pages in the lock page storage area. After the recovery module 403 recovers the accessed page to the lock page memory area, the lock page management module 404 locks the accessed page in the lock page memory area. As one example, lock page management module 404 may lock the page being accessed in an Mlock region in memory. It should be noted that, on one hand, because the target page (cold page) is compressed and stored in the memory, the memory space occupied by the cold page is reduced, and a part of the memory space can be released, thereby improving the utilization rate of the memory resource. On the other hand, because the cold page is still stored in the memory, when the electronic device needs to access the cold page, the cold page can be directly decompressed from the memory and accessed without being searched from other slow storage except the memory. Therefore, compared with the method for deleting the cold page from the memory, the method provided by the application accelerates the speed of accessing the cold page to a certain extent.
According to the embodiments, the method provided by the embodiments of the present application may determine the cold page in the locked page by counting pages that have not been accessed within the target time period. As another possible implementation, the electronic device may also sort the locked pages according to access time to determine cold pages in the locked pages. A method for determining a cold page in a lock page by sorting the lock pages according to access time will be described with reference to the accompanying drawings.
Referring to fig. 16, a signaling diagram of a method for storing a lock page in a memory according to an embodiment of the present application is shown.
As shown in fig. 16, the method for storing a lock page in a memory provided by the embodiment of the present application includes:
s1601: the electronic equipment starts a lock page management function.
It should be noted that the electronic device may automatically start the lock page management function, and the electronic device may also start the lock page management function in response to a start operation of a user.
S1602: the efficiency control module 201 sends an identification instruction to the identification module 401.
The efficiency control module 201 in the embodiment of the present application may be located in the application framework layer 200 of the electronic device, and the identification module 401 may be located in the kernel layer 400 of the electronic device. After the efficiency control module 201 receives the instruction to start the lock page management function, the efficiency control module 201 sends an identification instruction to the identification module 401. While the lock page management function remains in the on state, as an example, after the electronic device is powered on, the efficiency control module 201 may send an identification instruction to the identification module 401. As a possible implementation manner, the efficiency control module 201 in the embodiment of the present application may periodically send the identification instruction to the identification module 401. Specifically, the efficiency control module 201 may send an identification instruction to the identification module 401 at the start of each cycle and a recovery instruction to the recovery module 402 at the end of each cycle. The determination of the period duration in the embodiment of the present application may be described with reference to step S1004, and details of the embodiment of the present application are not described herein. Step S1002 in this embodiment of the application is an optional step, and the identifying module 401 may autonomously start identifying the target page on the premise of not receiving the identifying instruction sent by the efficiency control module 201.
S1603: the identification module 401 determines that a page with an access time earlier than an access time threshold among the locked pages is a target page.
The identification module in the embodiment of the present application may be located in the core layer 400 of the electronic device. The identification module 401 in this embodiment of the present application may directly determine, from the lock pages, a page whose access time is earlier than the access time threshold, or may sequence the lock pages according to the access time, and then determine, according to a queue obtained by the sequencing, a page whose access time is earlier than the access time threshold, which is not limited herein. The access time threshold in the embodiment of the present application may be determined according to the actual situation of file access. The access time threshold may be a time length of the access time of the page from the current time point, for example, 5000s, or may be a real time, for example, 8: 02.
as one example, identification module 401 may order the lock pages in the lock page storage area by access time after time-stamping the pages in the lock page storage area by access time. As shown in FIG. 17, the lock page memory regions include Page 1, Page 2, Page 3, Page 4, and Page 5. Wherein, the time mark of the page 5 is' T: 0 "indicating that page 5 was accessed at the start time. The time stamp of page 1 is "T: 12345 ", indicating that page 1 was accessed 12345s after the start time. The time stamp of page 2 is "T: 12333 ", indicating that page 2 was accessed 12333s after the start time. The time stamp of page 3 is "T: 12200 ", indicating that page 3 was accessed 12200s after the start time. The time stamp of page 4 is "T: 9100 ", indicates that page 4 was accessed 9100s after the start time. The larger the number of the page time stamp, the closer the time the page is accessed to the current time. The recognition module 400 may sort the pages from large to small according to the time stamp to obtain an ordered queue of locked pages. Assuming that page 3 is accessed at this time, as shown in FIG. 18, the identification module 401 swaps page 3 from the fourth bit in the queue to the first bit in the queue and updates the time stamp for page 3, specifically the time stamp "T" for page 3: 12200 "update to" T: 14500". As another possible implementation, the time stamp of the page in the embodiment of the present application may also be a time stamp generated according to the real time, for example, page 1 at 8 am: 02 are accessed, the time stamp for page 1 may be "T: 8: 02 ", the application examples are not limited thereto.
After obtaining the ordered queue of the locked pages, the identifying module 401 determines a target page from the page whose access time is earlier than the access time threshold. As an example, assuming that the current time is 15000s, the identification module 401 may determine a page with an access time more than 5000s from the current time as a target page, that is, a page with an access time less than 10000s as a target page. In this embodiment, the identification module 401 may determine that the page 4 and the page 5 with the access time less than 10000s are target pages.
As another possible implementation, after obtaining the ordered queue of the locked pages, the identifying module 401 may determine a page ordered in the ordered queue as a target page, where the target page is ordered later than the other pages in the locked pages, and the percentage of the target page in the locked pages may be a preset percentage, for example, 20%. In actual applications, the percentage of the target page in the locked page may also be determined according to the actual operating conditions of the electronic device, for example, when the CPU occupancy of the electronic device is low and the available storage space in the memory is small, the percentage of the target page in the locked page may be increased, for example, 30%.
S1604: the efficiency control module 201 sends a recycle instruction to the recycle module 402.
The recycling module 402 may be located at the core layer 400 of the electronic device. In this embodiment, the efficiency control module 201 may send a recycling instruction to the recycling module 402 when detecting that the available memory of the electronic device is lower than the first memory threshold, so as to increase the available memory of the electronic device. As an example, the first memory threshold may be 500 MB.
As another possible implementation, the efficiency control module 201 may send an identification instruction to the identification module 401 at the start of each cycle and send a recovery instruction to the recovery module 402 at the end of each cycle. The determination of the cycle duration in the embodiment of the present application may be described with reference to step S1004. Step S1604 in this embodiment is an optional step, and the recovery module 402 in this embodiment may autonomously start recovery of the target page on the premise of not receiving the recovery instruction sent by the efficiency control module 201.
S1605: the recycle module 402 recycles the target page.
The recycle module 402 recycles the target page in the locked page storage area after receiving the recycle instruction sent by the efficiency control module 201. As one possible implementation, the reclamation module 402 may send a target page query instruction to the access identification module 401. After receiving the target page query instruction sent by the recovery module 402, the identification module 401 determines a target page in the locked page according to the ordered queue of the locked pages, and sends the target page information to the identification module 401. The recycling module 402 receives the target page information sent by the identifying module 401 and recycles the target page according to the target page information. As another possible implementation manner, after receiving the target page query instruction sent by the recovery module 402, the identification module 401 may determine, according to the ordered queue of the locked pages, a target page in the locked pages, and recover the target page. The target page in the lock page may be a lock page whose access time is earlier than the access time threshold, or may be a page ordered in the ordered queue, and the specific implementation manner is shown in step S1603, which is not described herein again in this embodiment of the present application.
As an example, as shown in fig. 19, page 1, page 2, page 3, page 4, and page 5 are stored in the lock page storage area, where page 4 and page 5 are target pages having an access time earlier than an access time threshold. Recycle module 402 may recycle page 4 and page 5 into the swap page memory region. At this time, the lock page memory area stores only page 1, page 2, and page 3, and the swap page memory area stores page 4 and page 5.
S1606: the swap page management module 405 compresses and locks the target page in the swap page storage area.
The swap page management module 405 may be located at the kernel layer 400 of the electronic device. The swap page management module 405 is mainly configured to manage pages in a swap page storage area, and the specific implementation manner is shown in step S1006, which is not described herein again in this embodiment of the present application.
S1607: the recovery module 403 recovers the accessed page when detecting that the page in the swap page storage area is accessed.
The recovery module 403 may be located at the core layer 400 of the electronic device. When the electronic device accesses a page in the swap page memory region, the restore module 403 can decompress the page and restore the page to the lock page memory region. As shown in FIG. 20, when page 5 is accessed, the restore module 403 decompresses page 5 and transfers page 5 from the lock page swap area to the lock page memory area for storage. Since page 5 was accessed, the identification module 401 may also update the timestamp of page 5 to the current time, specifically may update the timestamp "T: 0 "updates to" T: 15600". And since page 5 has just been accessed, the identification module 401 queues page 5 in the first bit of the ordered queue.
S1608: the lock page management module 404 locks pages in the lock page storage area.
The lock page management module 404 may be located at the kernel layer 400 of the electronic device. The lock page management module 404 is mainly configured to manage pages in the lock page storage area, and the specific implementation is shown in step S1008, which is not described herein again in this embodiment of the present application.
S1609: the efficiency control module 201 sends a recovery instruction to the recovery module 403.
In this embodiment of the application, the recovery module 403 may actively recover the page accessed in the swap page storage area, and when the efficiency control module 201 determines that the current memory space is sufficient, the efficiency control module may also send a recovery instruction to the recovery module 403, so that the recovery module 403 recovers the page in the swap page storage area. Specifically, when the efficiency control module 201 detects that the available memory of the electronic device is higher than the second memory threshold, a recovery instruction may be sent to the recovery module 403. As an example, the second memory threshold may be 800 MB.
Further, it is considered that the recovery module 403 may occupy computing resources of a Central Processing Unit (CPU) of the electronic device when recovering the page in the swap page memory area. The recovery module 403 may send a recovery instruction to the recovery module 403 when the available memory of the electronic device is higher than the second memory threshold and the occupancy rate of the CPU of the electronic device is lower than the CPU occupancy threshold. As one example, the CPU occupancy threshold may be 30%.
S1610: the restore module 403 restores the pages in the pinned page swap area to the pinned page memory area.
After the recovery module 403 receives the recovery instruction sent by the efficiency control module 201, all pages or a part of pages in the lock page swap area may be recovered to the lock page storage area. As shown in fig. 21, page 1, page 2, page 3, and page 5 are stored in the lock page storage region, and page 4 is stored in the swap page storage region. After receiving the recovery instruction, the recovery module 403 may swap the page 4 from the swap page memory area to the lock page memory area, and reserve the time stamp "T: 9100".
S1611: the lock page management module 404 locks pages in the lock page storage area.
The lock page management module 404 is mainly configured to manage pages in the lock page storage area, and the specific implementation is shown in step S1608, which is not described herein again in this embodiment of the present application.
In summary, the method provided by the embodiment of the present application can identify the usage habits of different users according to the access information of the locked page in the memory, so as to lock the target page that is not frequently accessed in the page according to the usage habits of different users. And then the electronic equipment compresses the target page in the memory, so that the storage space occupied by the target page in the memory is reduced, a part of memory with lower efficiency is released, and the released storage space can be used for storing other pages accessed frequently, so that the overall use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
In the embodiment of the present application, the lock page swap area may exist in a memory or may be stored in another storage device, which is not limited herein. As one example, a lock page swap area may be included in storage devices other than memory. At this time, the lock page storage area is still in the memory, and the electronic device may swap out the target page that is not frequently accessed in the lock page storage area from the memory and store the target page in the lock page swap area. In this way, the electronic device may completely release the memory space occupied by the target page, but when the swapped-out target page is accessed again, the electronic device needs to swap the target page from the storage device into the memory, so that the access speed of the target page in the storage device is slow.
In summary, the method provided by the embodiment of the present application can identify the usage habits of different users according to the access information of the locked page in the memory, so as to lock the target page that is not frequently accessed in the page according to the usage habits of different users. The target page may be a page that is not accessed in the target time period, or a page that is not accessed in the memory for a long time. The electronic equipment can judge that the probability of the target page being accessed is low, so that the electronic equipment compresses the target page in the memory, the storage space occupied by the target page in the memory is reduced, a part of memory with low efficiency is released, the part of memory can be used for storing pages which are accessed frequently, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
According to the storage method of the locked page in the memory provided by the embodiment, the embodiment of the application further provides a storage device of the locked page in the memory.
Referring to fig. 22, a schematic diagram of a memory device with lock pages in memory according to an embodiment of the present disclosure is shown.
The apparatus is applied to an electronic device, a memory of the electronic device includes a lock page storage region and an exchange page storage region, and a lock page is stored in the lock page storage region, as shown in fig. 22, the apparatus includes:
a first determining module 2201, configured to determine a target page in the locked pages, where the locked page is a page locked in a memory of the electronic device, and the target page is a locked page that is not accessed within a target time period;
a first storage module 2202, configured to store the target page in the swap page storage area, where a storage space occupied by the target page in the lock page storage area is released;
a first compression module 2203, configured to compress the target page in the memory.
As a possible implementation manner, the first determining module is specifically configured to: marking a locked page at the starting time of a target time period; when a first page in the locked pages is accessed, clearing the mark of the first page; and determining the locked page with the mark as the target page at the end time of the target time period.
According to the storage method of the locked page in the memory provided by the embodiment, the embodiment of the application further provides a storage device of the locked page in the memory.
Referring to fig. 23, a schematic diagram of another apparatus for storing a lock page in a memory according to an embodiment of the present application is shown.
The apparatus is applied to an electronic device, a memory of the electronic device includes a lock page storage region and an exchange page storage region, and a lock page is stored in the lock page storage region, as shown in fig. 23, the apparatus includes:
a second determining module 2301, configured to determine a target page in the locked pages, where the locked page is a page locked in a memory of the electronic device, and the target page is a locked page whose access time is earlier than an access time threshold;
the second storage module 2302 is used for storing the target page into the swap page storage area, and releasing the storage space occupied by the target page in the lock page storage area;
a second compression module 2303 for compressing the target page in memory.
As a possible implementation manner, the second determining module is specifically configured to: sequencing the locked pages according to the morning and the evening of the access time to obtain an ordered queue of the locked pages; and according to the ordered queue, determining the locked page with the access time being earlier than the access time threshold as the target page.
In summary, the device provided in the embodiment of the present application can identify the usage habits of different users according to the access information of the locked page in the memory, so as to lock the target page that is not frequently accessed in the page according to the usage habits of different users. The target page may be a page that is not accessed in the target time period, or a page that is not accessed in the memory for a long time. The electronic equipment compresses the target page in the memory, so that the storage space occupied by the target page in the memory is reduced, a part of memory with lower efficiency is released, the part of memory can be used for storing the page accessed frequently, the use efficiency of the memory is improved, and the performance of the electronic equipment is improved.
According to the storage method of the lock page in the memory and the storage device of the lock page in the memory provided by the embodiments, the embodiments of the present application further provide an electronic device, where the electronic device includes a processor and a memory: the memory is used for storing a computer program; the processor is used for executing the storage method of the lock page according to the computer program.
According to the storage method of the locked page in the memory and the storage device of the locked page in the memory provided by the embodiments, the embodiments of the present application further provide a computer-readable storage medium, where the computer-readable storage medium is used for storing a computer program, and the computer program is used for executing the storage method of the locked page.
Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions. For the specific working processes of the system, the apparatus and the unit described above, reference may be made to the corresponding processes in the foregoing method embodiments, and details are not described here again.
In the several embodiments provided in this embodiment, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each functional unit in the embodiments of the present embodiment may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present embodiment essentially or partially contributes to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor to execute all or part of the steps of the method described in the embodiments. And the aforementioned storage medium includes: flash memory, removable hard drive, read only memory, random access memory, magnetic or optical disk, and the like.
The above description is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (18)

1. A method for storing a lock page in a memory is applied to an electronic device, the memory of the electronic device comprises a lock page storage area and an exchange page storage area, and the lock page storage area stores a lock page, and the method comprises the following steps:
the electronic equipment determines a target page in the lock pages, wherein the lock pages are pages locked in a memory of the electronic equipment, and the target page is a lock page which is not accessed in a target time period;
the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released;
and the electronic equipment compresses the target page in the memory.
2. The method of claim 1, the electronic device determining a target page in the lock page, comprising:
at the starting time of the target time period, the electronic equipment marks the lock page;
when a first page in the lock pages is accessed, the electronic equipment clears the mark of the first page;
and at the end moment of the target time period, the electronic equipment determines the locked page with the mark as the target page.
3. The method of claim 1, further comprising:
when the electronic equipment accesses the target page, the electronic equipment decompresses the target page and stores the target page in the locked page storage area.
4. The method of claim 1, wherein the starting time of the target time period is a time when a screen of the electronic device is lit.
5. The method according to claim 1, wherein the end time of the target time period is a time at which a screen of the electronic device is turned off.
6. The method of claim 1, wherein the electronic device determines a target page in the locked page, comprising:
the electronic equipment periodically determines a target page in the lock pages.
7. The method according to claim 6, wherein the period of determining the target page in the lock page by the electronic device is shortened after the system version of the electronic device is updated.
8. A method for storing a lock page in a memory is applied to an electronic device, the memory of the electronic device comprises a lock page storage area and an exchange page storage area, and the lock page storage area stores a lock page, and the method comprises the following steps:
the electronic equipment determines a target page in the lock pages, wherein the lock pages are pages locked in a memory of the electronic equipment, and the target page is a lock page with access time earlier than an access time threshold;
the electronic equipment stores the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released;
and the electronic equipment compresses the target page in the memory.
9. The method of claim 8, wherein the electronic device determines a target page in the locked page, comprising:
the electronic equipment sorts the locking pages according to the morning and evening of the access time to obtain an ordered queue of the locking pages;
and the electronic equipment determines the locked page with the access time being earlier than the access time threshold as the target page according to the ordered queue.
10. The method of claim 8, further comprising:
when the electronic equipment accesses the target page, the electronic equipment decompresses the target page and stores the target page in the locked page storage area.
11. The method of claim 8, wherein the electronic device storing the target page in the swap page memory area comprises:
and when the available memory of the electronic equipment is lower than a first memory threshold value, the electronic equipment stores the target page into the exchange page storage area.
12. The method of claim 8, further comprising:
and when the available memory of the electronic equipment is higher than a second memory threshold value, decompressing the target page and storing the target page into the lock page storage area by the electronic equipment.
13. A storage device of a lock page in a memory is applied to an electronic device, the memory of the electronic device includes a lock page storage area and a swap page storage area, and the lock page storage area stores a lock page, and the device includes:
a first determining module, configured to determine a target page in the lock pages, where the lock page is a page locked in a memory of the electronic device, and the target page is a lock page that is not accessed within a target time period;
the first storage module is used for storing the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released;
the first compression module is used for compressing the target page in the memory.
14. The apparatus of claim 13, wherein the first determining module is specifically configured to:
marking the lock page at the starting time of the target time period;
when a first page in the lock pages is accessed, clearing the mark of the first page;
and determining the locked page with the mark as the target page at the end time of the target time period.
15. An apparatus for storing a lock page in a memory, the apparatus being applied to an electronic device, the memory of the electronic device including a lock page storage area and an exchange page storage area, the lock page storage area storing a lock page, the apparatus comprising:
a second determining module, configured to determine a target page in the lock pages, where the lock page is a page locked in a memory of the electronic device, and the target page is a lock page whose access time is earlier than an access time threshold;
the second storage module is used for storing the target page into the exchange page storage area, and the storage space occupied by the target page in the locking page storage area is released;
and the second compression module is used for compressing the target page in the memory.
16. The apparatus of claim 15, wherein the second determining module is specifically configured to:
sequencing the locking pages according to the morning and the evening of the access time to obtain an ordered queue of the locking pages;
and determining the locked page with the access time being earlier than the access time threshold as the target page according to the ordered queue.
17. An electronic device, comprising a processor and a memory:
the memory is used for storing a computer program;
the processor is configured to perform the method of any of claims 1-7 or claims 8-12 in accordance with the computer program.
18. A computer-readable storage medium, characterized in that the computer-readable storage medium is used to store a computer program for performing the method of any of claims 1-7 or claims 8-12.
CN202210339963.9A 2022-04-01 2022-04-01 Storage method and related device for locking page in memory Active CN114461405B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210339963.9A CN114461405B (en) 2022-04-01 2022-04-01 Storage method and related device for locking page in memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210339963.9A CN114461405B (en) 2022-04-01 2022-04-01 Storage method and related device for locking page in memory

Publications (2)

Publication Number Publication Date
CN114461405A true CN114461405A (en) 2022-05-10
CN114461405B CN114461405B (en) 2022-09-13

Family

ID=81418002

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210339963.9A Active CN114461405B (en) 2022-04-01 2022-04-01 Storage method and related device for locking page in memory

Country Status (1)

Country Link
CN (1) CN114461405B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130073798A1 (en) * 2011-09-20 2013-03-21 Samsung Electronics Co., Ltd. Flash memory device and data management method
US20140188821A1 (en) * 2012-12-28 2014-07-03 Panfeng ZHOU Method and System to Avoid Space Bloating During Run-Time Compression
US20150081965A1 (en) * 2012-04-27 2015-03-19 Hitachi, Ltd. Data management system and data management method
CN105843853A (en) * 2016-03-16 2016-08-10 北京小米移动软件有限公司 Clearing method and apparatus for intelligent device
CN107861999A (en) * 2017-10-20 2018-03-30 北京集奥聚合科技有限公司 The processing method and system of cold data in a kind of hdfs
CN110609708A (en) * 2018-06-15 2019-12-24 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for data processing
CN114116191A (en) * 2021-06-24 2022-03-01 荣耀终端有限公司 Memory cold page processing method and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130073798A1 (en) * 2011-09-20 2013-03-21 Samsung Electronics Co., Ltd. Flash memory device and data management method
US20150081965A1 (en) * 2012-04-27 2015-03-19 Hitachi, Ltd. Data management system and data management method
US20140188821A1 (en) * 2012-12-28 2014-07-03 Panfeng ZHOU Method and System to Avoid Space Bloating During Run-Time Compression
CN105843853A (en) * 2016-03-16 2016-08-10 北京小米移动软件有限公司 Clearing method and apparatus for intelligent device
CN107861999A (en) * 2017-10-20 2018-03-30 北京集奥聚合科技有限公司 The processing method and system of cold data in a kind of hdfs
CN110609708A (en) * 2018-06-15 2019-12-24 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for data processing
CN114116191A (en) * 2021-06-24 2022-03-01 荣耀终端有限公司 Memory cold page processing method and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
(美)包米克·维迪雅著: "《基于GPU加速的计算机视觉编程》", 30 April 2020 *

Also Published As

Publication number Publication date
CN114461405B (en) 2022-09-13

Similar Documents

Publication Publication Date Title
US20210240636A1 (en) Memory Management Method and Apparatus
US11947489B2 (en) Creating snapshots of a storage volume in a distributed storage system
CN110018900B (en) Memory processing method and device, electronic equipment and computer readable storage medium
CN109992523B (en) Memory processing method and device, electronic equipment and computer readable storage medium
CN109992402B (en) Memory processing method and device, electronic equipment and computer readable storage medium
CN110018902B (en) Memory processing method and device, electronic equipment and computer readable storage medium
CN110945486B (en) Storage fragment management method and terminal
US11372779B2 (en) Memory controller and memory page management method
CN114185494B (en) Memory anonymous page processing method, electronic device and readable storage medium
WO2015051641A1 (en) Method and apparatus for reclaiming space of magnetic disk image
CN112000426B (en) Data processing method and device
CN103649927A (en) Techniques for moving data between memory types
US20190188090A1 (en) Snapshot Deletion In A Distributed Storage System
CN114253908A (en) Data management method and device of key value storage system
WO2024099448A1 (en) Memory release method and apparatus, memory recovery method and apparatus, and computer device and storage medium
EP4369191A1 (en) Memory scanning method and apparatus
CN113204407A (en) Memory over-allocation management method and device
CN107133334B (en) Data synchronization method based on high-bandwidth storage system
CN114461405B (en) Storage method and related device for locking page in memory
US10976938B2 (en) Block map cache
US20170315930A1 (en) Cache scoring scheme for a cloud-backed deduplication storage system
CN115543930A (en) Method, device and related equipment for locking file in memory
CN116701298A (en) File system management method and electronic equipment
CN113485642A (en) Data caching method and device
CN110018985B (en) Snapshot deleting method, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20230904

Address after: 201306 building C, No. 888, Huanhu West 2nd Road, Lingang New District, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Patentee after: Shanghai Glory Smart Technology Development Co.,Ltd.

Address before: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Patentee before: Honor Device Co.,Ltd.

TR01 Transfer of patent right