WO2021218502A1 - 一种页交换的方法、存储系统和电子设备 - Google Patents

一种页交换的方法、存储系统和电子设备 Download PDF

Info

Publication number
WO2021218502A1
WO2021218502A1 PCT/CN2021/082671 CN2021082671W WO2021218502A1 WO 2021218502 A1 WO2021218502 A1 WO 2021218502A1 CN 2021082671 W CN2021082671 W CN 2021082671W WO 2021218502 A1 WO2021218502 A1 WO 2021218502A1
Authority
WO
WIPO (PCT)
Prior art keywords
swap
page
memory
pages
swapped
Prior art date
Application number
PCT/CN2021/082671
Other languages
English (en)
French (fr)
Inventor
李昌龙
易见
周未来
杜维
李家欣
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to US17/922,276 priority Critical patent/US20230176980A1/en
Priority to EP21797595.2A priority patent/EP4134829B1/en
Publication of WO2021218502A1 publication Critical patent/WO2021218502A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/123Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/122Replacement control using replacement algorithms of the least frequently used [LFU] type, e.g. with individual count value
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0862Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with prefetch
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0868Data transfer between cache memory and other subsystems, e.g. storage devices or host systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/126Replacement control using replacement algorithms with special data handling, e.g. priority of data or instructions, handling errors or pinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • G06F2212/1024Latency reduction

Definitions

  • This application relates to the technical field of memory management, and in particular to a page swapping method, storage system and electronic equipment.
  • terminal device memory With the increasing use of terminal devices by users, more and more applications are installed by users, and various applications have an increasing demand for terminal device memory. For example, many common applications such as chat, games, cameras, etc. occupy terminal device memory in the order of kilomegabytes (GB), but the memory capacity of terminal devices is limited.
  • GB kilomegabytes
  • the system can reclaim some pages to other spaces based on the page swap technology, such as the process heap, stack, data segment, and pages used by shared memory (shmem) mapping.
  • the page is the smallest unit of the address space in the memory management process.
  • the page swapping technology includes the page swap-out process and the page swap-in process, there is time overhead, which affects the performance of the system.
  • the present application provides a method, storage system, and electronic device for page exchange, which can improve the accuracy of page exchange and improve the operating performance of the system during the process of page exchange.
  • a page swapping method is provided.
  • the method is applied to a storage system including a processor, a memory device, and a swap device.
  • the memory device stores multiple pages of different applications.
  • the method includes: The first swap-out page to be swapped out of the memory device is determined in the LRU linked list; the second swap-out page is determined from the LRU linked list according to the first swap-out page; when the first swap-out page is swapped out from the memory device When outputting, the first swap-out page and the second swap-out page are continuously swapped out to the swap device.
  • the page swap method for a certain page of the page to be swapped out in the LRU linked list, one or more other pages to be swapped out belonging to the same application are determined according to the certain page to be swapped out. Furthermore, in the page swapping out process, the pages belonging to the same application in the page to be swapped out are preferentially swapped out, and the swapped out pages belonging to the same application are continuously stored in the swap device.
  • the swap-out process can realize the continuous storage of logically related pages of the same application according to the logical correlation of the pages to be swapped out and the sequence of the LRU linked list.
  • the first swap-out page and the second swap-out page have the same application identifier
  • the first swap-out page is determined from the LRU linked list according to the first swap-out page.
  • the second swap-out page includes: determining the application identifier of the first swap-out page, and determining from the LRU linked list that the page to be swapped out having the same application identifier as the first swap-out page is the second swap-out page.
  • each application (APP) used by the user has a unique identity (ID).
  • ID unique identity
  • each service may include multiple processes, each service may have a fixed identifier, or each process may also have a different identifier. Then, in the page swap-out process, in addition to considering the application identifier, the system can also perform the swap-out process based on the process identifier or the service identifier.
  • the system can switch pages with the same service ID to the switching device according to the service ID judgment, and accordingly, during the page swapping process, swap in adjacent pages with the same service ID as the target page. Memory device.
  • the system can also determine that the page with the same process ID is swapped out to the swap device according to the process ID.
  • the page with the same process ID as the target page will be swapped out.
  • the adjacent pages are swapped into the memory device, which is not limited in the embodiment of the present application.
  • the memory device stores a memory mapping table, and the memory mapping table is used to indicate the logical address and application identifier of each page in the plurality of pages
  • determining the second swap-out page from the LRU linked list includes: obtaining the logical address of the first swap-out page; and according to the memory mapping table and the first swap-out page The logical address of the page out is used to determine the application identifier of the first swap-out page; the page to be swapped out that has the same application identifier as the first swap-out page is determined from the LRU linked list as the second swap-out page.
  • the logical address of each page to be swapped out is determined, and the application identifier of each page is further determined, thereby determining that it belongs to Pages to be swapped out of the same application.
  • the pages belonging to the same application in the page to be swapped out are preferentially swapped out, and the swap-out pages belonging to the same application are continuously stored in the swap device.
  • the swap-out process can realize the continuous storage of logically related pages of the same application according to the logical correlation of the pages to be swapped out and the sequence of the LRU linked list.
  • the memory device in the embodiment of the present application includes a memory manager, and the memory manager can maintain a memory mapping table.
  • application A requests memory from the processor, and the processor can obtain the ID of application A, and according to the request of application A, allocate the memory area of the memory device logical address PGD 1 to application A, the logical address is PGD The memory area of 2 is allocated to application B. According to this, the memory mapping table of the system can be obtained, and the memory manager of the memory device can save the memory mapping table.
  • the method further includes: in response to a swap-in request for the target page, swapping the target page from the swap device to the memory device, And preload the adjacent pages of the target page.
  • the target page and the page adjacent to the target page can be swapped into the memory, or the target page can be removed from the swap device Swap into the memory device, and preload adjacent pages of the target page.
  • the pre-loading process may be implemented by the memory manager through a cache (cache), which will not be repeated here. This process can ensure that the pages that are swapped in are logically related pages of the same application, which improves the prefetch accuracy of the swap-in process, thereby improving the operating performance of the system.
  • the successively swapping out the first swap-out page and the second swap-out page to the switching device includes: The out page and the second swap out page are swapped out to the exchange device at the same time, or the first swap out page and the second swap out page are continuously swapped out to the swap device in the first order.
  • the first order is the sequence of pages with the same application identifier in the LRU linked list.
  • the logical address of each page in the plurality of pages is the global page table entry PGD address.
  • the method further includes: determining the number of pages to be swapped out according to the space capacity of the memory device, and according to the space capacity of the memory device To determine the number of the target page to be swapped in.
  • an electronic device in a second aspect, includes a processing unit, a memory device, and a switching device.
  • the memory device stores multiple pages of different applications.
  • the processing unit is configured to: determine from the least used LRU linked list The first swap-out page to be swapped out of the memory device; according to the first swap-out page, the second swap-out page is determined from the LRU linked list; when the first swap-out page is swapped out from the memory device, the The first swap-out page and the second swap-out page are continuously swapped out to the swap device.
  • the first swap-out page and the second swap-out page have the same application identifier
  • the processing unit is specifically configured to: determine the application of the first swap-out page Identification, determining from the LRU linked list that the page to be swapped out with the same application identifier as the first swap-out page is the second swap-out page.
  • the memory device stores a memory mapping table, and the memory mapping table is used to indicate the logical address and application identifier of each page in the plurality of pages
  • the electronic device further includes: an acquiring unit, configured to acquire the logical address of the first swap-out page; and the processing unit, further configured to: according to the memory mapping table and the logic of the first swap-out page Address, determine the application identifier of the first swap-out page; determine from the LRU linked list that the page to be swapped out with the same application identifier as the first swap-out page is the second swap-out page.
  • the processing unit is further configured to: in response to a swap-in request for the target page, swap the target page from the swap device to the memory Device, and preload adjacent pages of the target page.
  • the processing unit is specifically configured to: simultaneously swap out the first swap-out page and the second swap-out page to the switching device, or The first swap-out page and the second swap-out page are continuously swapped out to the swap device in the first order.
  • the first order is the sequence of pages with the same application identifier in the LRU linked list.
  • the logical address of each page in the plurality of pages is the PGD address of the global page table entry.
  • the processing unit is further configured to: determine the number of pages to be swapped out according to the space capacity of the memory device, and determine the number of pages to be swapped out according to the size of the memory device The space capacity determines the number of the target page to be swapped in.
  • an electronic device including: one or more processors; a memory; a memory device and a switching device; a plurality of application programs; and one or more programs, wherein the one or more programs are stored in In the memory, when the one or more programs are executed by the processor, the electronic device is caused to execute any one method of the first aspect and the implementation manner of the first aspect.
  • a device in a fourth aspect, is provided, the device is included in an electronic device, and the device has the function of realizing the above aspects and the behavior of the electronic device in the possible implementation manners of the above aspects.
  • This function can be realized by hardware, or by hardware executing corresponding software.
  • the hardware or software includes one or more modules or units corresponding to the above-mentioned functions. For example, a display module or unit, a detection module or unit, a processing module or unit, and so on.
  • a storage system includes: a memory device and a switching device; a processor and an interface, and the processor and the interface cooperate with each other so that the storage system executes the above-mentioned first aspect and the first aspect. Any one of the implementation methods.
  • this application provides an electronic device, including: a touch display screen, wherein the touch display screen includes a touch-sensitive surface and a display; a camera; one or more processors; a memory; a memory device and a switching device; Application programs; and one or more computer programs, wherein one or more computer programs are stored in the memory, one or more computer programs include instructions, when the instructions are executed by an electronic device, the electronic device executes any of the above aspects Any possible method.
  • the present application provides an electronic device including one or more processors and one or more memories.
  • the one or more memories are coupled with one or more processors, and the one or more memories are used to store computer program codes.
  • the computer program codes include computer instructions.
  • the electronic device executes The foregoing is a method in any one of the first aspect and the implementation manner of the first aspect.
  • the present application provides a computer-readable storage medium, including computer instructions, which when the computer instructions run on an electronic device, cause the electronic device to execute any one of the above-mentioned implementations such as the first aspect and the first aspect method.
  • this application provides a computer program product, which when the computer program product runs on an electronic device, causes the electronic device to execute any one of the above-mentioned methods such as the first aspect and the implementation manner of the first aspect.
  • Fig. 1 is a schematic structural diagram of a storage system provided by an embodiment of the present application.
  • Figure 2 is a schematic diagram of an example of a page exchange process provided by this application.
  • FIG. 3 is a schematic flowchart of an example of a page exchange method provided by an embodiment of the present application.
  • Fig. 4 is a schematic diagram of another example of a page exchange process provided by an embodiment of the present application.
  • Fig. 5 is a schematic structural diagram of an example of an electronic device provided by an embodiment of the present application.
  • first and second are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features.
  • the features defined with “first” and “second” may explicitly or implicitly include one or more features.
  • the embodiment of the application provides a page swap method, which can be applied to a separate storage system, or an electronic device containing the storage system, or a separate application program, which can implement the page swap method in this application.
  • a page In the process of memory management, a page is the smallest unit of the address space. Generally, a page is 4 kilobytes (KB) or 64KB.
  • the memory space of the process is only virtual memory, that is, "logical memory”, and the operation of the program requires real physical memory, that is, random access memory (RAM).
  • RAM random access memory
  • the operating system can map the logical memory applied for during the running of the program to RAM so that the process can use the physical memory.
  • the memory space of the logical memory is called the "logical address space”.
  • the logical address space can be divided into multiple fixed-size virtual pages (VP), and the size of the virtual page can be 4 kilobytes (KB).
  • the memory space of the physical memory is called the "physical address space”.
  • the physical address space can be divided into multiple fixed-size physical pages (PP), and the size of the physical page can be 4KB.
  • the virtual page and the file mapping of the hard disk storage device are then cached to the physical page.
  • logical addresses are used, and each process maintains a separate page table.
  • the page table is an array structure that stores the status information of each virtual page, such as whether each virtual page is mapped, whether it is cached, etc.
  • zRAM technology can use system memory to replace hard disk storage devices to provide swap space for the system by paging on the system memory (RAM), and make better use of system memory until the swap space of the hard disk storage device must be used to avoid the hard disk storage device Perform paging on the page to improve performance.
  • RAM system memory
  • an area is allocated from the system memory (RAM) to be used as a swap area. If the system memory space is insufficient, the memory data occupied by the application program is compressed and copied to the swap area. When you need to switch back to the application, you can directly restore the compressed data of the application to the memory, saving the time required to restart the application. Moreover, after the data in the swap area is compressed, more data of different applications can be stored, which expands the size of the system memory (RAM) in a disguised form.
  • the system When the process is executed, when the value stored in the logical address needs to be accessed, the system will first find the virtual page (VP) where the logical address is located. According to the page table, find out the physical page (PP) corresponding to the virtual page (VP) in the page table. ).
  • RAM system memory
  • FIG. 1 is a schematic structural diagram of a storage system 100 provided by an embodiment of the present application.
  • the storage system 100 may include a processor 10, a memory device 20, and a switching device 30.
  • the processor 10 is a control center or a core component of the storage system 100, and may also be a control center of electronic equipment including the storage system.
  • the processor 10 may use various interfaces and lines to connect various parts of the entire electronic device, and execute the electronic device by running or executing software programs and/or modules stored in the memory, and calling data stored in the memory.
  • the various functions and processing data of the electronic equipment can be used to monitor the electronic equipment as a whole.
  • the processor 10 may control data processing procedures, such as page swapping procedures and data reading and writing procedures.
  • the processor 10 may correspond to a central processing unit (CPU) of an electronic device, and the processor 10 may include one or more processing units.
  • the processor 10 may optionally include an arithmetic unit and a controller for obtaining instructions and processing data. Specifically, it can be used to control the execution sequence of instructions, operation control, time control, and perform arithmetic and logical operations on data, or perform other information processing.
  • the memory device 20 is the most common system memory, and can also be referred to as "memory" or "system memory”.
  • the memory device 20 can retain data for a short period of time. In order to maintain data, the memory device 20 can use capacitor charges for storage, so it must be refreshed once a period of time. In addition, if the electronic device is turned off, the data stored in the memory device 20 will be lost.
  • the memory device 20 includes a memory manager inside, and the memory manager stores a memory index table, and the memory index table is used to indicate the block management principle of the memory device 20.
  • the memory index table may include the aforementioned page table, which is used to indicate the mapping relationship between virtual pages and physical pages, and files of hard disk storage devices.
  • the memory device 20 may be a dynamic random access memory (DRAM).
  • DRAM dynamic random access memory
  • the swap device 30 is also called a "swap area", and is used to store processes or data swapped out from the memory device 20.
  • part of the processes or data in the memory device 20 can be migrated to the switching device 30, thereby freeing up space in the memory device 20, which is called a "swap-out process”.
  • migrating part of the processes or data of the switching device 30 to the memory device 20 is called a "swap-in process”.
  • the swap device 30 may be a storage device independent of the memory device 20, or may be a swap area formed by a part of the memory device 20.
  • the switching device 30 may be an area in the DRAM; or the switching device may be an independent storage device, such as a flash memory (NAND flash memory, NAND).
  • NAND flash memory NAND flash memory
  • the switching device 30 is an external storage device independent of the memory device 20.
  • part of the page can be swapped out to the external storage device of the PC.
  • a page fault exception occurs in the system, and the page is requested to be swapped out into the memory again, which is not limited in this application.
  • the processor 10 may write the relevant processes or data of the application A into the memory device 20, and migrate the relevant processes or data of the application B in the memory device 20 to Exchange equipment 30.
  • the processor 10 may re-migrate the process or data related to the application B in the memory device 20 to the memory device 20.
  • the storage system 100 may also include one or more different types of interfaces or lines, the interfaces may include internal interfaces or external interfaces, and the lines may include a system bus, a memory bus, or input/output (input/output, I/O). O) Bus, etc., interfaces or lines can be used to connect various modules of the storage system.
  • Figure 1 is only a schematic diagram of the storage system. For simplicity, interfaces or lines are not shown in Figure 1.
  • the storage system 100 may also adopt different interface connection modes, or a combination of multiple interface connection modes, and the embodiment of the present application does not limit the type and connection mode of the interface.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the storage system 100.
  • the storage system 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the electronic devices that include the storage system 100 in this application may be mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR)/virtual reality (VR) devices, notebook computers, For ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (personal digital assistants, PDAs), etc., the embodiments of this application do not impose any restrictions on the specific types of electronic devices.
  • AR augmented reality
  • VR virtual reality
  • UMPCs ultra-mobile personal computers
  • PDAs personal digital assistants
  • the embodiments of this application do not impose any restrictions on the specific types of electronic devices.
  • electronic devices in addition to the storage system 100 described above, other components may also be included.
  • electronic devices may also include charging management modules, power management modules, batteries, antennas, mobile communication modules, wireless communication modules, audio modules, speakers, receivers, microphones, earphone jacks, sensor modules, buttons, motors, indicators, cameras , A display screen, and one or more of subscriber identification module (subscriber identification module, SIM) card interfaces, etc.
  • subscriber identification module subscriber identification module, SIM
  • the sensor module may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
  • a pressure sensor a gyroscope sensor
  • an air pressure sensor a magnetic sensor
  • an acceleration sensor a distance sensor
  • a proximity light sensor a fingerprint sensor
  • a temperature sensor a touch sensor
  • an ambient light sensor a bone conduction sensor
  • Fig. 2 is a schematic diagram of an example of the page swap process provided by the present application, in which (a) is a schematic diagram of the page swap-out phase, and (b) is a schematic diagram of the page swap-in phase.
  • the page swap process it is generally implemented based on the least recently used (LRU) linked list.
  • the system kernel maintains an active anon list and an inactive anon list. Pages that are determined to be cold by the kernel algorithm are changed from the active anon list to an inactive anon list. ;
  • the pages in the inactive anon list are sequentially swapped out of the memory until the memory demand is met.
  • the page that is swapped out is swapped into memory when the user uses it.
  • the page to be swapped out in the inactive linked list is called the "page to be swapped out"
  • the page to be swapped in is called the "target page”.
  • the active page is listed in the active linked list, and the active page can be understood as a page with a high frequency of system reading or a page related to an application currently running in the system.
  • the data of the active page has not been read for a long time, it will migrate from the active linked list to the inactive linked list, and then swap out the inactive linked list to the switching device 30.
  • the small boxes in FIG. 2 represent pages of different applications.
  • box A is the page of application A.
  • the pages of application A are first migrated to the inactive linked list, followed by application B-application C-application A-application D-application A-application D-application B -Application C-Application A, and arrange all pages.
  • application B-application C-application A-application D-application A-application D-application B -Application C-Application A are marked with numbers 1-10.
  • relevant pages related to application A are marked as 1, 4, 6, and 10.
  • the relevant pages 1, 4, 6, and 10 related to application A are consecutive pages of logical addresses of application A.
  • the pages are swapped out only according to the sequence of the LRU linked list, and the pages being swapped out have no logical relevance.
  • the pages of application A-application B-application C-application A-application D-application A-application D-application B-application C-application A are sequentially swapped out from inactive pages.
  • the adjacent pages in the linked list are After being swapped out, the switching device is also stored adjacently, which results in that the pages stored adjacently in the switching device may often belong to different applications and are logically irrelevant. In other words, when the page is swapped out, the pages of the same application are stored discretely in the swap device.
  • prefetch In order to improve the efficiency of swap-in, in the corresponding swap-in process, consider swapping in pages adjacent to the target page, which is called "prefetch". For example, if the target page is related page 4 of application A, the adjacent pages of related page 4 will also be swapped in.
  • the adjacent pages are related pages of application C and application D, that is, a large number of prefetched pages may not belong to the same Application, resulting in low accuracy of prefetching in the swap-in phase. If the related pages of other applications that are prefetched (for example, related pages of application C and application D) will not be used by the system subsequently, it will occupy memory and affect the performance of the system.
  • prefetching is performed for consecutive pages of logical addresses.
  • the relevant pages 1, 4, 6, and 10 of application A are logical address consecutive pages.
  • the target page is swapped in, the logical addresses before and after the adjacent The pages will be swapped back to memory at the same time.
  • the relevant page 4 of the application A is swapped in, the relevant pages 1 and 6 of the application A with adjacent logical addresses are also swapped back to the memory.
  • the above method improves the accuracy of prefetching to a certain extent, but the physical addresses actually stored in the swap device 30 of the relevant pages 1, 4, and 6 of the swapped-in application A are not continuous, that is, the prefetched application A’s physical addresses are not continuous.
  • the related pages 1, 4, and 6 are discretely stored in the storage space of the switching device 30, and the physical addresses are not adjacent, and the performance of the discrete data swap-in process is low. From the user level, it affects the user's experience of using the application A.
  • FIG. 3 is a schematic flowchart of an example of a page swap method provided by an embodiment of the present application.
  • the method may be implemented in the storage system 100 shown in FIG. Multiple pages of the application. Specifically, the method may be executed by the processor 10. As shown in FIG. 3, the method 300 may include the following steps:
  • the processor 10 determines a first page to be swapped out of the memory device from a plurality of pages stored in the memory device 20.
  • the processor 10 determines a second swap-out page from the LRU linked list according to the first swap-out page.
  • the processor 10 continuously swaps out the first swap-out page and the second swap-out page to the swap device.
  • first swap-out page herein may be any one of the multiple pages to be swapped out stored in the memory device 20, for example, the first swap-out page is a certain page in the LRU.
  • the first swap-out page and the second swap-out page have the same application identifier
  • the processor 10 may determine the application identifier of the first swap-out page, and determine from the LRU linked list with the The page to be swapped out for which the first swap-out page has the same application identifier is the second swap-out page.
  • the processor 10 may obtain the logical address of the first swap-out page, and determine the application identifier of the first swap-out page according to the memory mapping table and the logical address of the first swap-out page, It is determined from the LRU linked list that the page to be swapped out with the same application identifier as the first swap-out page is the second swap-out page.
  • the memory device 20 in the embodiment of the present application includes a memory manager, and the memory manager can maintain a memory mapping table.
  • the memory mapping table is used to indicate the correspondence between the logical address of the memory device 20 and the application identifier.
  • the memory mapping table may be generated by the processor 10 and stored in the memory manager of the memory device 20, which is not limited in the embodiment of the present application.
  • Table 1 is an example of a memory mapping table of the memory device 20 provided in an embodiment of the present application. As shown in Table 1 below, the storage space of the memory device 20 can be divided into multiple regions. Each area of the memory device has a different logical address, and the logical address can be distinguished by the address of a page global directory (PGD).
  • PPD page global directory
  • each application (APP) used by the user has a unique identity (ID).
  • ID In the application process, you can apply for memory in sequence, and divide different areas for different applications according to the user's request.
  • processor 10 can obtain the ID of application A, and according to application A’s request, allocate the memory area of memory device 20 with logical address PGD 1 to application A, logically The memory area with address PGD 2 is allocated to application B. Accordingly, the memory mapping table shown in Table 1 can be obtained, and the memory manager of the memory device 20 can save the memory mapping table.
  • the logical address of the page to be swapped out is determined based on the LRU linked list.
  • logical backtracking is performed on each page to determine the logical address of each page.
  • the logical backtracking process for each page can be understood as: according to the structure of the page table, the logical address of the page is determined level by level. E.g,
  • mm_struct*mm (mm_struct structure describes the operating state of virtual memory)
  • the vm_area_struct*vm, mm_struct*mm, and pgd_t*pgd listed above can be understood as pointer addresses. This application does not limit the data structure. Regardless of the level of the data structure, the one pointed to by the PGD pointer can be determined according to the above logical backtracking method.
  • the base address of the level page table to determine the logical address of the page to be swapped out Exemplarily, when it is determined that the logical address of a page to be swapped out is PGD 4, according to the memory mapping table, the application identifier corresponding to the page to be swapped out can be known, that is, the application A to which it belongs is determined.
  • the above process may determine the logical address of each page according to the pages in the active linked list, or determine the logical address of each page according to the pages in the inactive linked list, which is not limited in this embodiment of the application. Among them, determining the logical address of each page according to the pages in the inactive linked list can reduce the number of determined pages, which can reduce the amount of calculation of the processor 10 to a certain extent.
  • the system can determine that the page to be swapped out belongs to the same application. Therefore, it is possible to determine which of the pages to be swapped out in the LRU linked list are logically related pages belonging to the same application.
  • the page with the first application identifier in the page to be swapped out is swapped out to the swap device.
  • FIG. 4 is a schematic diagram of another example of a page swap process provided by an embodiment of the present application, wherein (a) is a schematic diagram of a page swap-out process, and (b) is a schematic diagram of a page swap-in process.
  • the pages in the inactive linked list are called "pages to be swapped out".
  • the page is determined in step 302
  • the logical address of each page determines the application ID to which each page belongs, and the pages with the same application ID are continuously swapped out to the switching device 30.
  • the target page is swapped in from the swap device to the memory device, and adjacent pages of the target page are preloaded.
  • the processor 10 swaps in the target page and adjacent pages of the target page to the memory device 20 at the same time.
  • the target page is swapped in from the swap device to the memory device, and adjacent pages of the target page are preloaded.
  • the pre-loading process may be implemented by the memory manager through a cache (cache), which will not be repeated here.
  • the logically related pages of the same application are swapped out according to the above-mentioned steps 301 to 303, the logically related pages are also continuously stored in the switching device 30, that is, the physical address continuity is realized.
  • the target page and the adjacent pages of the target page can be swapped into the memory.
  • the prefetching process can ensure that the pages swapped in are logically related pages of the same application, which improves the prefetching accuracy of the swapping process.
  • the page swap method for the pages to be swapped out in the LRU linked list, by determining the logical address of each page to be swapped out, the application ID of each page is further determined, thereby determining that it belongs to Pages to be swapped out of the same application. Furthermore, in the page swap-out process, the pages belonging to the same application in the page to be swapped out are preferentially swapped out, and the swap-out pages belonging to the same application are continuously stored in the swap device.
  • the swap-out process can realize the continuous storage of logically related pages of the same application according to the logical correlation of the pages to be swapped out and the sequence of the LRU linked list.
  • the target page and the adjacent page of the target page are swapped into the memory to ensure that the page being swapped in is of the same application
  • Logic related pages improve the prefetch accuracy of the swap-in process, thereby improving the operating performance of the system.
  • the system may also determine to swap out pages with the same service ID or the same process ID to the switching device based on the service ID or the process ID.
  • the method of the present application may also be used for different service processes, each service may include multiple processes, each service may have a fixed identifier, or each process may also have a different identifier. Then, in the page swap-out process, in addition to considering the application identifier, the system can further execute the swap-out process based on the process identifier or the service identifier.
  • the system can switch pages with the same service ID to the switching device according to the service ID judgment, and accordingly, during the page swapping process, swap in adjacent pages with the same service ID as the target page. Memory device.
  • the system can also determine that the page with the same process ID is swapped out to the swap device according to the process ID.
  • the page with the same process ID as the target page will be swapped out.
  • the adjacent pages are swapped into the memory device, which is not limited in the embodiment of the present application.
  • the electronic device 500 includes an acquisition unit 510 and a processing unit 520, a memory device 20, and a switching device 30.
  • the memory device 20 stores a memory mapping table and different applications.
  • the memory mapping table is used to indicate the correspondence between the logical address of each page in the plurality of pages and the application identifier, and the electronic device includes an acquiring unit 510 and a processing unit 520.
  • the processing unit 520 is configured to determine the first page to be swapped out of the memory device from the least used LRU linked list.
  • the processing unit 520 is further configured to determine a second swap-out page from the LRU linked list according to the first swap-out page; when the first swap-out page is swapped out from the memory device 20, the first swap-out page The out page and the second swap out page are continuously swapped out to the switching device 30.
  • the first swap-out page and the second swap-out page have the same application identifier
  • the processing unit 520 is specifically configured to: determine the application identifier of the first swap-out page, from the LRU linked list It is determined that the page to be swapped out with the same application identifier as the first swap-out page is the second swap-out page.
  • the memory device stores a memory mapping table, and the memory mapping table is used to indicate the correspondence between the logical address of each page in the plurality of pages and the application identifier.
  • the acquiring unit 510 is configured to acquire the logical address of the first swap-out page; the processing unit 520 is further configured to: determine the logical address of the first swap-out page according to the memory mapping table and the logical address of the first swap-out page Application ID; from the LRU linked list, it is determined that the page to be swapped out with the same application ID as the first swap-out page is the second swap-out page.
  • the processing unit 520 is further configured to, when a swap-in request for the target page is received, in response to the swap-in request for the target page, swap the target page from the swap device 30 to the memory device 20, and check The adjacent pages of the target page are preloaded.
  • the electronic device 500 may also include more functional modules, or two or more functions may be integrated into one processing module.
  • Each function and each module can implement the page swapping method 300 in FIG. 3, which is used to execute the corresponding steps in the above method 300.
  • page swapping method 300 in FIG. 3, which is used to execute the corresponding steps in the above method 300.
  • the page exchange method of the present application can be used in the storage system 100 shown in FIG. 1, or can be used in electronic devices such as mobile phones, tablets, PCs, and smart watches. Storage continuity in the swap-out stage, correspondingly, during the page swap-in process, it is ensured that the swapped-in pages are logically related pages of the same application, which improves the prefetch accuracy of the swap-in process, thereby improving system performance.
  • the electronic devices include hardware and/or software modules corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Those skilled in the art can use different methods for each specific application in combination with the embodiments to implement the described functions, but such implementation should not be considered as going beyond the scope of the present application.
  • the electronic device can be divided into functional modules according to the foregoing method examples.
  • each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • the electronic device may include: a display unit, a detection unit, and a processing unit. It should be noted that all relevant content of the steps involved in the foregoing method embodiments can be cited in the functional description of the corresponding functional module, and will not be repeated here.
  • the electronic device provided in this embodiment is used to perform the above-mentioned page swapping method, and therefore can achieve the same effect as the above-mentioned implementation method.
  • the electronic device may include a processing module, a storage module, and a communication module.
  • the processing module can be used to control and manage the actions of the electronic device, for example, can be used to support the electronic device to execute the steps performed by the above-mentioned display unit, detection unit, and processing unit.
  • the storage module can be used to support the electronic device to execute the storage program code and data.
  • the communication module can be used to support the communication between electronic devices and other devices.
  • the processing module may be a processor or a controller. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the disclosure of this application.
  • the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and so on.
  • the storage module may be a memory.
  • the communication module may specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, and other devices that interact with other electronic devices.
  • the processing module may be a processor, and the storage module may be a memory.
  • the electronic device involved in this embodiment may be a mobile phone, a tablet, a PC, a smart watch, etc.
  • This embodiment also provides a computer storage medium in which computer instructions are stored, and when the computer instructions run on an electronic device, the electronic device executes the above-mentioned related method steps to implement the page swapping method in the above-mentioned embodiment .
  • This embodiment also provides a computer program product, which when the computer program product runs on a computer, causes the computer to execute the above-mentioned related steps, so as to implement the page swapping method in the above-mentioned embodiment.
  • the embodiments of the present application also provide a device.
  • the device may specifically be a chip, component or module.
  • the device may include a processor and a memory connected to each other.
  • the memory is used to store computer execution instructions.
  • the processor can execute the computer-executable instructions stored in the memory, so that the chip executes the page swapping method in the foregoing method embodiments.
  • the electronic device, computer storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding method provided above. The beneficial effects of the method will not be repeated here.
  • Module completion means dividing the internal structure of the device into different functional modules to complete all or part of the functions described above.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of modules or units is only a logical function division.
  • there may be other division methods for example, multiple units or components may be combined or It can be integrated into another device, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product, and the software product is stored in a storage medium. It includes several instructions to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods of the various embodiments of the present application.
  • the foregoing storage media include: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

一种页交换方法、存储系统和电子设备,应用于内存管理技术领域。该方法包括:从最少使用LRU链表中确定所述内存设备的待换出的第一换出页(301);根据所述第一换出页,从所述LRU链表中确定第二换出页(302);当所述第一换出页从所述内存设备换出时,将所述第一换出页和所述第二换出页连续换出到所述交换设备(303)。该方法可以保证换入的页为同一应用的逻辑相关页,提高了换入过程的预取准确率,从而提高了系统的运行性能。

Description

一种页交换的方法、存储系统和电子设备
本申请要求于2020年4月30日提交中国专利局、申请号为202010360522.8、申请名称为“一种页交换的方法、存储系统和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及内存管理技术领域,尤其涉及一种页交换的方法、存储系统和电子设备。
背景技术
随着用户对终端设备的使用率越来越高,用户安装应用的数量也越来越多,各类应用对终端设备内存的需求也日益增加。例如,聊天、游戏、相机等常见的多款应用占用终端设备内存的规模均达到千兆字节(kilomegabyte,GB)的量级,但是,终端设备的内存容量是有限的。
为了缓解终端设备内存的压力,在应用的使用过程中,系统可以基于页交换技术将部分页回收到其它空间,例如进程堆、栈、数据段、共享内存(shmem)映射使用的页等。其中,页是内存管理过程中地址空间的最小单位。
由于页交换技术包括的页换出过程和页换入过程存在时间开销,影响了系统的性能。
发明内容
本申请提供一种页交换的方法、存储系统和电子设备,能够在页交换的过程中,提高了页交换的准确率,提高系统的运行性能。
第一方面,提供了一种页交换的方法,该方法应用于包括处理器、内存设备和交换设备的存储系统中,该内存设备存储有不同应用的多个页,该方法包括:从最少使用LRU链表中确定该内存设备的待换出的第一换出页;根据该第一换出页,从该LRU链表中确定第二换出页;当该第一换出页从该内存设备换出时,将该第一换出页和该第二换出页连续换出到该交换设备。
通过本申请实施例提供的页交换方法,对于LRU链表中的待换出页的某一个换出页,根据该某一个换出页确定属于同一应用的其他的一个或者多个待换出页。进而在页换出过程中,优先将待换出页中属于同一应用的页连续换出,并将属于同一应用的换出页在交换设备中进行连续存储。该换出过程按照待换出页的逻辑相关度和LRU链表顺序,可以实现同一应用的逻辑相关页的连续存储。
结合第一方面,在第一方面的某些实现方式中,第一换出页和该第二换出页具有相同的应用标识,该根据该第一换出页,从该LRU链表中确定第二换出页,包括:确定该第一换出页的应用标识,从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
应理解,用户使用的每一款应用(application,APP)有唯一的标识(identity,ID)。应用的使用过程中,可以依次申请内存,根据用户的请求,划分不同的区域给不同的应用。
还应理解,本申请的方法还可以用于不同的服务过程,每一个服务可以包括多个进程,每一个服务可以有固定的标识,或者每一个进程也可以有不同的标识。那么在页换出过程中,系统除了考虑应用标识之外,还可以进一步根据进程标识或者服务标识执行也换出过程。
示例性的,系统可以根据服务标识判断将具有相同的服务标识的页换出到交换设备,相应地,在页换入过程中,将和目标页具有相同的服务标识的相邻页换入到内存设备。
或者,在页换出过程中,系统还可以根据进程标识判断将具有相同的进程标识的页换出到交换设备,相应地,在页换入过程中,将和目标页具有相同的进程标识的相邻页换入到内存设备,本申请实施例对此不作限定。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,该内存设备存储有内存映射表,该内存映射表用于指示该多个页中每个页的逻辑地址和应用标识之间的对应关系,该根据该第一换出页,从该LRU链表中确定第二换出页,包括:获取该第一换出页的逻辑地址;根据该内存映射表和该第一换出页的逻辑地址,确定该第一换出页的应用标识;从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
综上所述,通过本申请实施例提供的页交换方法,对于LRU链表中的待换出页,通过确定每个待换出页的逻辑地址,进一步确定每个页的应用标识,从而确定属于同一应用的待换出页。进而在页换出过程中,优先将待换出页中属于同一应用的页连续换出,并将属于同一应用的换出页在交换设备中连续存储。该换出过程按照待换出页的逻辑相关度和LRU链表顺序,可以实现同一应用的逻辑相关页的连续存储。
可选地,本申请实施例的内存设备内部包括内存管理器,该内存管理器可以维护内存映射表。
当用户使用应用A时,应用A向处理器请求内存,处理器可以获取应用A的ID,并根据应用A的请求将内存设备逻辑地址为PGD 1的内存区域分配给应用A,逻辑地址为PGD 2的内存区域分配给应用B。据此,可以得到系统的内存映射表,内存设备的内存管理器可以保存该内存映射表。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,该方法还包括:响应于对目标页的换入请求,将该目标页从该交换设备换入到该内存设备,且对该目标页的相邻页进行预加载。
相应地,在页换入过程中,对于将换入的目标页,按照预取原则,可以将该目标页和目标页相邻的页换入到内存,或者,将该目标页从该交换设备换入到该内存设备,且对该目标页的相邻页进行预加载。该预加载过程可以由内存管理器通过缓存(cache)实现预加载,此处不再赘述。该过程可以保证被换入的页为同一应用的逻辑相关页,提高了换入过程的预取准确率,从而提高了系统的运行性能。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,该将该第一换出页和该第二换出页连续换出到该交换设备,包括:将该第一换出页和该第二换出页同时换出到该交换设备,或者将该第一换出页和该第二换出页连续换出到该交换设备按照第一顺序换 出到该交换设备。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,第一顺序是具有相同应用标识的页在该LRU链表的先后排列顺序。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,多个页中每个页的逻辑地址为全局页表项PGD地址。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,该方法还包括:根据该内存设备的空间容量,确定该待换出页的数量,以及根据该内存设备的空间容量,确定待换入的该目标页的数量。
第二方面,提供了一种电子设备,该电子设备包括处理单元,内存设备和交换设备,该内存设备存储有不同应用的多个页,该处理单元,用于:从最少使用LRU链表中确定该内存设备的待换出的第一换出页;根据该第一换出页,从该LRU链表中确定第二换出页;当该第一换出页从该内存设备换出时,将该第一换出页和该第二换出页连续换出到该交换设备。
结合第二方面,在第二方面的某些实现方式中,第一换出页和该第二换出页具有相同的应用标识,该处理单元具体用于:确定该第一换出页的应用标识,从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,该内存设备存储有内存映射表,该内存映射表用于指示该多个页中每个页的逻辑地址和应用标识之间的对应关系,该电子设备还包括:获取单元,用于获取该第一换出页的逻辑地址;该处理单元,还用于:根据该内存映射表和该第一换出页的逻辑地址,确定该第一换出页的应用标识;从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,该处理单元还用于:响应于对目标页的换入请求,将该目标页从该交换设备换入到该内存设备,且对该目标页的相邻页进行预加载。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,该处理单元具体用于:将该第一换出页和该第二换出页同时换出到该交换设备,或者将该第一换出页和该第二换出页连续换出到该交换设备按照第一顺序换出到该交换设备。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,第一顺序是具有相同应用标识的页在该LRU链表的先后排列顺序。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,多个页中每个页的逻辑地址为全局页表项PGD地址。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,该处理单元还用于:根据该内存设备的空间容量,确定该待换出页的数量,以及根据该内存设备的空间容量,确定待换入的该目标页的数量。
第三方面,提供了一种电子设备,包括:一个或多个处理器;存储器;内存设备和交换设备;多个应用程序;以及一个或多个程序,其中该一个或多个程序被存储在该存储器中,当该一个或者多个程序被该处理器执行时,使得该电子设备执行如第一方面和第一方面的实现方式中任一项方法。
第四方面,提供了一种装置,该装置包含在电子设备中,该装置具有实现上述方面及 上述方面的可能实现方式中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的模块或单元。例如,显示模块或单元、检测模块或单元、处理模块或单元等。
第五方面,一种存储系统,该存储系统包括:内存设备和交换设备;处理器和接口,所述处理器和接口相互配合,使得所述存储系统执行上述如第一方面和第一方面的实现方式中任一项方法。
第六方面,本申请提供了一种电子设备,包括:触摸显示屏,其中,触摸显示屏包括触敏表面和显示器;摄像头;一个或多个处理器;存储器;内存设备和交换设备;多个应用程序;以及一个或多个计算机程序,其中,一个或多个计算机程序被存储在存储器中,一个或多个计算机程序包括指令,当指令被电子设备执行时,使得电子设备执行上述任一方面任一项可能的方法。
第七方面,本申请提供了一种电子设备,包括一个或多个处理器和一个或多个存储器。该一个或多个存储器与一个或多个处理器耦合,一个或多个存储器用于存储计算机程序代码,计算机程序代码包括计算机指令,当一个或多个处理器执行计算机指令时,使得电子设备执行上述如第一方面和第一方面的实现方式中任一项方法。
第八方面,本申请提供了一种计算机可读存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行上述如第一方面和第一方面的实现方式中任一项方法。
第九方面,本申请提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行上述如第一方面和第一方面的实现方式中任一项方法。
附图说明
图1是本申请实施例提供的一种存储系统的结构示意图。
图2是本申请提供的一例页交换过程的示意图。
图3是本申请实施例提供的一例页交换方法的示意性流程图。
图4是本申请实施例提供的又一例页交换过程的示意图。
图5是本申请实施例提供的一例电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个特征。
本申请实施例提供了一种页交换的方法,可以应用于单独的存储系统,或者包含该存储系统的电子设备,也可是单独的应用程序,该应用程序可实现本申请中页交换的方法。
在介绍本申请实施例的页交换方法之前,先介绍一下几个与存储系统的内存管理机制相关的概念。
1、页
在内存管理过程中,页是地址空间的最小单位,一般一个页为4千字节(kilobyte,KB)或者64KB。
2、逻辑内存和逻辑地址空间、物理内存和物理地址空间
进程的内存空间只是虚拟内存,即“逻辑内存”,而程序的运行需要的是实实在在的物理内存,即随机存取存储器(random access memory,RAM)。必要时,操作系统可以将程序运行中申请的逻辑内存映射到RAM,让进程能够使用物理内存。
逻辑内存的内存空间称为“逻辑地址空间”,逻辑地址空间可以划分为多个固定大小的虚拟页(virtual page,VP),虚拟页的大小可以为4千字节(kilobyte,KB)。物理内存的内存空间称为“物理地址空间”,物理地址空间可以划分为多个固定大小的物理页(physical page,PP),物理页的大小可以为4KB。
虚拟页和硬盘存储设备的文件映射,然后缓存到物理页。对于进程来说,使用的都是逻辑地址,每个进程维护一个单独的页表。页表是一种数组结构,存放着各虚拟页的状态信息,例如各虚拟页是否映射,是否缓存等状态信息。
3、虚拟内存压缩(zRAM)技术
zRAM技术通过在系统内存(RAM)上进行分页,可以用系统内存替代硬盘存储设备为系统提供交换空间,更好的利用系统内存,直到必须使用硬盘存储设备的交换空间,以避免在硬盘存储设备上进行分页,从而提高性能。
具体地,从系统内存(RAM)分配一块区域出来用作交换(swap)区,如果系统内存空间不够了,把应用程序所占用的内存数据经过压缩之后复制到交换区。当需要切换回该应用程序的时候,就可以直接把该应用程序的压缩数据恢复到内存当中,节省重新开启该应用程序所需的时间。而且,交换区的数据经过压缩之后,可以存放更多的不同应用程序的数据,变相扩展了系统内存(RAM)的大小。
4、进程执行过程
进程执行时,当需要访问逻辑地址中存放的值时,系统会先找到逻辑地址所在的虚拟页(VP),根据页表,找出页表中该虚拟页(VP)对应的物理页(PP)。
如果发生缺页异常,调用内核的缺页异常处理程序。将该缺页的内容从对应映射的硬盘存储设备的文件区缓存到系统内存(RAM)。
以上介绍了与存储系统的内存管理机制相关的概念,下面结合存储系统100介绍本申请实施例提供的页交换方法。图1是本申请实施例提供的一种存储系统100的结构示意图,如图1所示,存储系统100可以包括处理器10、内存设备20和交换设备30。
示例性的,处理器10是存储系统100的控制中心或者核心部件,也可以是包含该存储系统的电子设备的控制中心。可选地,处理器10可以利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器内的软件程序和/或模块,以及调用存储在存储器内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。在本申请中,处理器10可以控制数据处理的过程,例如页交换过程和数据的读写过程等。
可选的,处理器10可以对应电子设备的中央处理器(central processing unit,CPU),处理器10可以包括一个或多个处理单元。处理器10可以选择性包括运算器和控制器,用于获取指令并处理数据。具体地可以用于进行指令执行顺序的控制、操作控制、时间控制以及对数据进行算术运算和逻辑运算,或进行其他信息的处理等。
内存设备20是最为常见的系统内存,还可以称为“内存”或者“系统内存”。内存设备20可以将数据保持很短的时间。为了保持数据,内存设备20可以使用电容电荷进行存储,所以必须隔一段时间刷新(refresh)一次。此外,电子设备如果关机,内存设备20存储的数据就会丢失。
可选地,内存设备20内部包含内存管理器,该内存管理器存储有内存索引表,该内存索引表用于指示该内存设备20的分块管理原则。该内存索引表可以包括前述介绍的页表,用于指示虚拟页和物理页、硬盘存储设备的文件之间的映射关系。
示例性的,以手机为例,内存设备20可以是动态随机存取存储器(dynamic random access memory,DRAM)。
交换设备30也称为“交换区”,用于存放从内存设备20中换出的进程或数据等。在处理器10的调度原则下,内存设备20中的部分进程或者数据可以迁移到交换设备30中,从而把内存设备20的空间腾出来,称为“换出过程”。同理,在处理器10的调度原则下,将交换设备30的部分进程或者数据迁移到内存设备20,称为“换入过程”。
应理解,该交换设备30可以是独立于内存设备20的存储器件,也可以是内存设备20的一部分形成的交换区。
示例性的,以手机为例,内存设备20是DRAM时,交换设备30可以是DRAM中的一个区域;或者,交换设备可以是独立的存储器件,例如闪存存储器(NAND flash memory,NAND)等。在进行页交换时,可以通过前述介绍的zRAM技术,可以将部分页压缩后放在手机内存;当用户需要使用被换出页时,系统发生缺页异常,请求将被压缩的页解压换回内存。
或者,以个人电脑(personal computer,PC)为例,交换设备30是独立于内存设备20的外部存储器件。在进行页交换时,可以将部分页换出到PC的外部存储设备。当用户需要使用被换出的页时,系统发生缺页异常,请求将被换出的页重新换入内存,本申请对此不作限定。
示例性的,当用户将应用A切换到前台使用并关闭应用B时,处理器10可以将应用A的相关进程或者数据写进内存设备20,将内存设备20中应用B相关进程或者数据迁移到交换设备30。当用户又运行应用B时,处理器10可以将内存设备20中应用B相关进程或者数据重新迁移到内存设备20。
此外,应理解,存储系统100还可以包括一个或多个的不同种类的接口或者线路,接口可以包括内部接口或者外部接口,线路可以包括系统总线、内存总线或者输入输出(input/output,I/O)总线等,接口或者线路可以用于连接存储系统的各个模块。图1仅为存储系统的示意图,为了简便,图1中没有示出接口或者线路。
还应理解,存储系统100也可以采用不同的接口连接方式,或多种接口连接方式的组合,本申请实施例对接口的类型和连接方式不做限定。
还应理解,本申请实施例示意的结构并不构成对存储系统100的具体限定。在本申请 另一些实施例中,存储系统100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
可选地,本申请包含该存储系统100的电子设备可以是手机、平板电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等,本申请实施例对电子设备的具体类型不作任何限制。
应理解,对于上述列举的电子设备,除了包括上述的存储系统100之外,还可以包括其他更多的部件。例如,电子设备还可以包括充电管理模块,电源管理模块,电池,天线,移动通信模块,无线通信模块,音频模块,扬声器,受话器,麦克风,耳机接口,传感器模块,按键,马达,指示器,摄像头,显示屏,以及用户标识模块(subscriber identification module,SIM)卡接口等的一种或者多种。其中,传感器模块可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。本申请实施例对终端设备包括的部件的数量和种类不作任何限制。
图2是本申请提供的一例页交换过程的示意图,其中(a)图为页换出阶段的示意图,(b)图为页换入阶段的示意图。
在页交换过程中,一般基于最少使用(least recently used,LRU)链表实现。具体地,系统内核维护有活跃链表(active anon list)和非活跃链表(inactive anon list),被内核算法判定为冷的页由活跃链表(active anon list)换到非活跃链表(inactive anon list);当系统进行内存回收时,非活跃链表(inactive anon list)中的页被依次换出内存,直至满足内存需求。被换出的页在用户使用时再被换入内存。在本申请中,将非活跃链表中将要换出的页称为“待换出页”,将被换入的页称为“目标页”。
如图2中的(a)图所示的页换出过程,活跃链表中列出的是活跃页,活跃页可以理解为系统读取频率高的页或者系统当前运行的应用相关的页。当活跃页的数据很久没有被读取时,会从活跃链表迁移到非活跃链表,再由非活跃链表换出到交换设备30。
示例性地,图2中的小方框代表不同应用的页。例如方框A为应用A的页。按照页迁入非活跃链表的顺序,例如图(a)中应用A的页最先迁入非活跃链表,依次为应用B-应用C-应用A-应用D-应用A-应用D-应用B-应用C-应用A,并将所有页进行排列,为了便于描述,用数字1-10进行标记,其中,涉及应用A的相关页被标注为1、4、6和10。
应理解,涉及应用A的相关页1、4、6和10为应用A的逻辑地址连续页。如图2中的(a)图所示,在页被换出的过程中,仅仅依据LRU链表顺序换出,被换出页在逻辑上不具有关联性。例如,从非活跃页中依次换出应用A-应用B-应用C-应用A-应用D-应用A-应用D-应用B-应用C-应用A的页,链表中相邻的页,被换出后在交换设备也为相邻存储,这导致交换设备中相邻存储的页往往可能属于不同的应用,在逻辑上无关。换言之,页换出时,同一应用的页在交换设备是离散存储的。
为了提高换入效率,相应地换入过程中,考虑将与目标页相邻的页换入,称之为“预取”。例如,目标页为应用A的相关页4,会将相关页4的相邻页也换入,该相邻页是应 用C和应用D的相关页,即大量被预取的页可能不属于同一应用,导致换入阶段预取的准确率很低。如果被预取的其他应用的相关页(例如应用C和应用D的相关页)后续也不会被系统用到的话,反而占用了内存,影响了系统的性能。
在另一种可能的实现方式中,为提高预取准确率,针对逻辑地址连续页进行预取。示例性地,如图2中的(b)图所示,应用A的相关页1、4、6和10是逻辑地址连续页,当目标页被换入时,将其逻辑地址相邻的前后页会被同时换回内存。换言之,在将应用A的相关页4换入时,将逻辑地址相邻的应用A的相关页1和6也一起换回内存。
上述这种方式一定程度上提高了预取的准确率,但是换入的应用A的相关页1、4和6在交换设备30中实际存储的物理地址不连续,即被预取的应用A的相关页1、4和6在交换设备30的存储空间上是离散存储的,物理地址不相邻,离散数据的换入过程性能低下,从用户层面上,影响用户使用该应用A的体验。
图3是本申请实施例提供的一例页交换方法的示意性流程图,该方法可以在如图1所示的存储系统100中实现,该存储系统100的内存设备20存储有内存映射表和不同应用的多个页。具体地,该方法可以由处理器10来执行。如图3所示,该方法300可以包括以下步骤:
301,处理器10从内存设备20存储的多个页中确定该内存设备的待换出的第一换出页。
302,处理器10根据该第一换出页,从该LRU链表中确定第二换出页。
303,当该第一换出页从该内存设备换出时,处理器10将该第一换出页和该第二换出页连续换出到该交换设备。
应理解,这里“第一换出页”可以是内存设备20存储的多个待换出页中的任意一个页,例如第一换出页是LRU中的某个页。
一种可能的实现方式中,该第一换出页和该第二换出页具有相同的应用标识,处理器10可以确定该第一换出页的应用标识,从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
一种可能的实现方式中,处理器10可以获取该第一换出页的逻辑地址,根据该内存映射表和该第一换出页的逻辑地址,确定该第一换出页的应用标识,从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
可选地,本申请实施例的内存设备20内部包括内存管理器,该内存管理器可以维护内存映射表,内存映射表用于指示内存设备20的逻辑地址和应用标识之间的对应关系。可选地,该内存映射表可以由处理器10生成并存储到内存设备20的内存管理器,本申请实施例对此不作限定。
表1是本申请实施例提供的一例内存设备20的内存映射表。如下表1所示,内存设备20的存储空间可以被划分为多个区域。内存设备的每个区域具有不同的逻辑地址,逻辑地址可以用全局页表项(page global directory,PGD)地址进行区分。
应理解,用户使用的每一款应用(application,APP)有唯一的标识(identity,ID)。应用的使用过程中,可以依次申请内存,根据用户的请求,划分不同的区域给不同的应用。当用户使用应用A时,应用A向处理器10请求内存,处理器10可以获取应用A的ID,并根据应用A的请求将内存设备20逻辑地址为PGD 1的内存区域分配给应用A,逻辑地 址为PGD 2的内存区域分配给应用B。据此,可以得到如表1所示的内存映射表,内存设备20的内存管理器可以保存该内存映射表。
表1
逻辑地址 应用标识
PGD 1 应用A
PGD 2 应用B
PGD 3 应用C
PGD 4 应用A
PGD 5 应用D
PGD 6 应用A
PGD 7 应用D
PGD 8 应用B
PGD 9 应用C
PGD 10 应用A
…… ……
在一种可能的实现方式中,在页换出时,基于LRU链表,确定待换出页的逻辑地址。
可选地,在页交换过程中,基于非活跃链表或者活跃链表中的页,对每个页进行逻辑回溯,确定每个页的逻辑地址。
示例性的,对每个页的逻辑回溯过程可以理解为:根据页表的结构,逐级确定该页的逻辑地址。例如,
address_space*mapping
vm_area_struct*vm(vm_area_struct描述area的结构)
mm_struct*mm(mm_struct结构描述虚拟内存的运行状态)
pgd_t*pgd(pgd指针指向进程的一级页表的基地址)
以上列举的vm_area_struct*vm、mm_struct*mm、pgd_t*pgd可以理解为指针地址,本申请对数据结构不作限定,不论是多少级的数据结构,都可以根据以上逻辑回溯的方法确定PGD指针指向的一级页表的基地址,从而确定该待换出页的逻辑地址。示例性地,当确定一个待换出页的逻辑地址为PGD 4,根据内存映射表,就可以知道该待换出页对应的应用标识,即确定所属应用A。
应理解,以上过程可以按照活跃链表中的页确定每个页的逻辑地址,也可以按照非活跃链表中的页确定每个页的逻辑地址,本申请实施例对此不做限定。其中,按照非活跃链表中的页确定每个页的逻辑地址可以减少确定页的数量,一定程度上可以降低处理器10的运算量。
经过上述步骤确定了待换出页的逻辑地址之后,如果待换出页具有相同的应用标识,系统可以确定具有该待换出页属于同一个应用。因此,可以据此判断LRU链表中的待换出页中有哪些页为属于同一应用的逻辑相关页。
当待换出页从内存设备20换出时,将所述待换出页中具有第一应用标识的页换出到所述交换设备。
图4是本申请实施例提供的又一例页交换过程的示意图,其中(a)图为页换出过程的示意图,(b)图为页换入过程的示意图。如图4中的(a)图所示,将非活跃链表中的页称为“待换出页”,该待换出页从非活跃链表迁移到交换设备30时,根据步骤302中确定的每个页的逻辑地址,进而确定每个页所属的应用ID,将具有相同的应用ID的页连续换出到交换设备30。
应理解,将具有相同的应用ID的页连续换出到交换设备30,可以保证换出到交换设备30的页为逻辑连续页,且在交换设备30中,该逻辑连续页一起进行存储,可以具有连续的物理地址。例如,将应用A的相关页1、4、6和10连续换出到交换设备30,应用A的相关页1、4、6和10在交换设备30中占用的物理地址也是连续的。该过程相比于现有技术,可以实现同一应用的逻辑相关页的连续存储。此外,该应用A的相关页1、4、6和10在交换设备30的物理地址连续可以提高zRAM的空间局部性。
当接收到针对目标页的换入请求时,响应于对目标页的换入请求,将该目标页从该交换设备换入到该内存设备,且对该目标页的相邻页进行预加载。
一种可能的实现方式中,响应于对目标页的换入请求,处理器10将所述目标页和所述目标页的相邻页同时换入到所述内存设备20。
或者,将该目标页从该交换设备换入到该内存设备,且对该目标页的相邻页进行预加载。该预加载过程可以由内存管理器通过缓存(cache)实现预加载,此处不再赘述。
具体地,当按照上述介绍的步骤301-步骤303将同一应用的逻辑相关页换出之后,该逻辑相关页在交换设备30也是连续存储的,即实现了物理地址连续。在页换入过程中,对于需要换入的目标页,按照预取原则,可以将该目标页和目标页相邻的页换入到内存。该预取过程可以保证换入的页为同一应用的逻辑相关页,提高了换入过程的预取准确率。
示例性的,如图4中的(b)图所示,当应用A的相关页4为目标页时,换入过程中将该应用A的相关页4和相关页1、相关页6换入到内存设备20。或者,也可以将该应用A的所有相关页1、4、6和10都换入到内存设备20,本申请实施例对此不作限定。
综上所述,通过本申请实施例提供的页交换方法,对于LRU链表中的待换出页,通过确定每个待换出页的逻辑地址,进一步确定每个页的应用ID,从而确定属于同一应用的待换出页。进而在页换出过程中,优先将待换出页中属于同一应用的页连续换出,并将属于同一应用的换出页在交换设备中连续存储。该换出过程按照待换出页的逻辑相关度和LRU链表顺序,可以实现同一应用的逻辑相关页的连续存储。
相应地,在页换入过程中,对于将换入的目标页,按照预取原则,将该目标页和目标页相邻的页换入到内存,可以保证被换入的页为同一应用的逻辑相关页,提高了换入过程的预取准确率,从而提高了系统的运行性能。
一种可能的实现方式中,系统还可以根据服务标识或者进程标识,判断将具有相同的服务标识或者相同的进程标识的页换出到交换设备。
具体地,本申请的方法还可以用于不同的服务过程,每一个服务可以包括多个进程,每一个服务可以有固定的标识,或者每一个进程也可以有不同的标识。那么在页换出过程中,系统除了考虑应用标识之外,还可以进一步根据进程标识或者服务标识执行也换出过 程。
示例性的,系统可以根据服务标识判断将具有相同的服务标识的页换出到交换设备,相应地,在页换入过程中,将和目标页具有相同的服务标识的相邻页换入到内存设备。
或者,在页换出过程中,系统还可以根据进程标识判断将具有相同的进程标识的页换出到交换设备,相应地,在页换入过程中,将和目标页具有相同的进程标识的相邻页换入到内存设备,本申请实施例对此不作限定。
图5是本申请实施例提供的一例电子设备500的结构示意图,该电子设备500包括获取单元510和处理单元520,内存设备20和交换设备30,该内存设备20存储有内存映射表和不同应用的多个页,所述内存映射表用于指示所述多个页中每个页的逻辑地址和应用标识之间的对应关系,所述电子设备包括获取单元510和处理单元520。
处理单元520,用于从最少使用LRU链表中确定该内存设备的待换出的第一换出页。
所述处理单元520,还用于根据该第一换出页,从该LRU链表中确定第二换出页;当该第一换出页从该内存设备20换出时,将该第一换出页和该第二换出页连续换出到该交换设备30。
一种可能的实现方式中,第一换出页和该第二换出页具有相同的应用标识,该处理单元520具体用于:确定该第一换出页的应用标识,从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
一种可能的实现方式中,该内存设备存储有内存映射表,该内存映射表用于指示该多个页中每个页的逻辑地址和应用标识之间的对应关系。该获取单元510,用于获取该第一换出页的逻辑地址;该处理单元520还用于:根据该内存映射表和该第一换出页的逻辑地址,确定该第一换出页的应用标识;从该LRU链表中确定与该第一换出页具有相同的应用标识的待换出页为该第二换出页。
所述处理单元520还用于,当接收到针对目标页的换入请求时,响应于对目标页的换入请求,将该目标页从该交换设备30换入到该内存设备20,且对该目标页的相邻页进行预加载。
应理解,该电子设备500还可以包括更多的功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。各个功能各模块可以实现图3中的页交换方法300,用于执行上述方法300中的相应步骤,为了简洁,此处不再赘述。
还应理解,本申请的页交换方法可以用在图1所示的存储系统100中,或者可以用于手机、平板、PC、智能手表等电子设备上,在页交换过程中,确保逻辑相关页在换出阶段的存储连续性,相应地,在页换入过程中,保证换入的页为同一应用的逻辑相关页,提高了换入过程的预取准确率,进而提升系统性能。
可以理解的是,该页交换方法用于手机、平板、PC、智能手表等电子设备上时,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本实施例可以根据上述方法示例对电子设备进行功能模块的划分,例如,可以对应各 个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,电子设备可以包括:显示单元、检测单元和处理单元。需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本实施例提供的电子设备,用于执行上述页交换的方法,因此可以达到与上述实现方法相同的效果。
在采用集成的单元的情况下,电子设备可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对电子设备的动作进行控制管理,例如,可以用于支持电子设备执行上述显示单元、检测单元和处理单元执行的步骤。存储模块可以用于支持电子设备执行存储程序代码和数据等。通信模块,可以用于支持电子设备与其他设备的通信。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性地逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他电子设备交互的设备。
在一个实施例中,处理模块可以为处理器,存储模块为存储器,本实施例所涉及的电子设备可以为手机、平板、PC、智能手表等。
本实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得电子设备执行上述相关方法步骤实现上述实施例中的页交换的方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的页交换的方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的页交换的方法。
其中,本实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上实施方式的描述,领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨 论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种页交换的方法,其特征在于,所述方法应用于包括处理器、内存设备和交换设备的存储系统中,所述内存设备存储有不同应用的多个页,所述方法包括:
    从最少使用LRU链表中确定所述内存设备的待换出的第一换出页;
    根据所述第一换出页,从所述LRU链表中确定第二换出页;
    当所述第一换出页从所述内存设备换出时,将所述第一换出页和所述第二换出页连续换出到所述交换设备。
  2. 根据权利要求1所述的方法,其特征在于,所述第一换出页和所述第二换出页具有相同的应用标识,所述根据所述第一换出页,从所述LRU链表中确定第二换出页,包括:
    确定所述第一换出页的应用标识,从所述LRU链表中确定与所述第一换出页具有相同的应用标识的待换出页为所述第二换出页。
  3. 根据权利要求1或2所述的方法,其特征在于,所述内存设备存储有内存映射表,所述内存映射表用于指示所述多个页中每个页的逻辑地址和应用标识之间的对应关系,所述根据所述第一换出页,从所述LRU链表中确定第二换出页,包括:
    获取所述第一换出页的逻辑地址;
    根据所述内存映射表和所述第一换出页的逻辑地址,确定所述第一换出页的应用标识;
    从所述LRU链表中确定与所述第一换出页具有相同的应用标识的待换出页为所述第二换出页。
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述方法还包括:
    响应于对目标页的换入请求,将所述目标页从所述交换设备换入到所述内存设备,且对所述目标页的相邻页进行预加载。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述将所述第一换出页和所述第二换出页连续换出到所述交换设备,包括:
    将所述第一换出页和所述第二换出页同时换出到所述交换设备,或者
    将所述第一换出页和所述第二换出页连续换出到所述交换设备按照第一顺序换出到所述交换设备。
  6. 根据权利要求5所述的方法,其特征在于,所述第一顺序是具有相同应用标识的页在所述LRU链表的先后排列顺序。
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,所述多个页中每个页的逻辑地址为全局页表项PGD地址。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,所述方法还包括:
    根据所述内存设备的空间容量,确定所述待换出页的数量,以及
    根据所述内存设备的空间容量,确定待换入的所述目标页的数量。
  9. 一种电子设备,其特征在于,所述电子设备包括处理单元,内存设备和交换设备,所述内存设备存储有不同应用的多个页,所述处理单元,用于:
    从最少使用LRU链表中确定所述内存设备的待换出的第一换出页;
    根据所述第一换出页,从所述LRU链表中确定第二换出页;
    当所述第一换出页从所述内存设备换出时,将所述第一换出页和所述第二换出页连续换出到所述交换设备。
  10. 根据权利要求9所述的电子设备,其特征在于,所述第一换出页和所述第二换出页具有相同的应用标识,所述处理单元具体用于:
    确定所述第一换出页的应用标识,从所述LRU链表中确定与所述第一换出页具有相同的应用标识的待换出页为所述第二换出页。
  11. 根据权利要求9或10所述的电子设备,其特征在于,所述内存设备存储有内存映射表,所述内存映射表用于指示所述多个页中每个页的逻辑地址和应用标识之间的对应关系,所述电子设备还包括:
    获取单元,用于获取所述第一换出页的逻辑地址;
    所述处理单元,还用于:
    根据所述内存映射表和所述第一换出页的逻辑地址,确定所述第一换出页的应用标识;
    从所述LRU链表中确定与所述第一换出页具有相同的应用标识的待换出页为所述第二换出页。
  12. 根据权利要求9至11中任一项所述的电子设备,其特征在于,所述处理单元还用于:
    响应于对目标页的换入请求,将所述目标页从所述交换设备换入到所述内存设备,且对所述目标页的相邻页进行预加载。
  13. 根据权利要求9至12中任一项所述的电子设备,其特征在于,所述处理单元具体用于:
    将所述第一换出页和所述第二换出页同时换出到所述交换设备,或者
    将所述第一换出页和所述第二换出页连续换出到所述交换设备按照第一顺序换出到所述交换设备。
  14. 根据权利要求13所述的电子设备,其特征在于,所述第一顺序是具有相同应用标识的页在所述LRU链表的先后排列顺序。
  15. 根据权利要求9至14中任一项所述的电子设备,其特征在于,所述多个页中每个页的逻辑地址为全局页表项PGD地址。
  16. 根据权利要求9至15中任一项所述的电子设备,其特征在于,所述处理单元还用于:
    根据所述内存设备的空间容量,确定所述待换出页的数量,以及
    根据所述内存设备的空间容量,确定待换入的所述目标页的数量。
  17. 一种电子设备,其特征在于,包括:一个或多个处理器;存储器;内存设备和交换设备;安装有多个应用程序的模块;以及一个或多个程序,其中所述一个或多个程序被存储在所述存储器中,当所述一个或者多个程序被所述处理器执行时,使得所述电子设备执行如权利要求1至8中任一项所述的页交换的方法。
  18. 一种存储系统,其特征在于,包括:内存设备,交换设备,处理器和接口,所述 处理器存储有一个或多个程序,当所述一个或者多个程序被所述处理器执行时,使得所述存储系统执行如权利要求1至8中任一项所述的页交换的方法。
  19. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1至8中任一项所述的页交换的方法。
  20. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1至8中任一项所述的页交换的方法。
PCT/CN2021/082671 2020-04-30 2021-03-24 一种页交换的方法、存储系统和电子设备 WO2021218502A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US17/922,276 US20230176980A1 (en) 2020-04-30 2021-03-24 Page Swap Method, Storage System, and Electronic Device
EP21797595.2A EP4134829B1 (en) 2020-04-30 2021-03-24 Page swapping method, storage system, and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010360522.8A CN113590509B (zh) 2020-04-30 2020-04-30 一种页交换的方法、存储系统和电子设备
CN202010360522.8 2020-04-30

Publications (1)

Publication Number Publication Date
WO2021218502A1 true WO2021218502A1 (zh) 2021-11-04

Family

ID=78236874

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/082671 WO2021218502A1 (zh) 2020-04-30 2021-03-24 一种页交换的方法、存储系统和电子设备

Country Status (4)

Country Link
US (1) US20230176980A1 (zh)
EP (1) EP4134829B1 (zh)
CN (2) CN118210741A (zh)
WO (1) WO2021218502A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230046354A1 (en) * 2021-08-04 2023-02-16 Walmart Apollo, Llc Method and apparatus to reduce cache stampeding
CN117785371A (zh) * 2022-09-20 2024-03-29 成都华为技术有限公司 一种页面换入方法以及装置
CN118363875A (zh) * 2023-01-18 2024-07-19 腾讯科技(深圳)有限公司 内存回收方法、装置、设备、介质及产品
CN117687932A (zh) * 2023-08-31 2024-03-12 荣耀终端有限公司 一种内存分配的方法及装置

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102831069A (zh) * 2012-06-30 2012-12-19 华为技术有限公司 内存处理方法、内存管理设备
CN106294192A (zh) * 2015-05-26 2017-01-04 龙芯中科技术有限公司 内存分配方法、内存分配装置及服务器
US20170109290A1 (en) * 2015-10-16 2017-04-20 International Business Machines Corporation Method to share a coherent accelerator context inside the kernel
CN107885666A (zh) * 2016-09-28 2018-04-06 华为技术有限公司 一种内存管理方法和装置
CN110018900A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110888821A (zh) * 2019-09-30 2020-03-17 华为技术有限公司 一种内存管理方法及装置
CN110955495A (zh) * 2019-11-26 2020-04-03 网易(杭州)网络有限公司 虚拟化内存的管理方法、装置和存储介质
CN111078587A (zh) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 内存分配方法、装置、存储介质及电子设备
CN111078410A (zh) * 2019-12-11 2020-04-28 Oppo(重庆)智能科技有限公司 内存分配方法、装置、存储介质及电子设备

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1182567B1 (en) * 2000-08-21 2012-03-07 Texas Instruments France Software controlled cache configuration
JP2012203729A (ja) * 2011-03-25 2012-10-22 Fujitsu Ltd 演算処理装置および演算処理装置の制御方法
US20140115241A1 (en) * 2011-05-30 2014-04-24 Qingsong Wei Buffer management apparatus and method
KR102165460B1 (ko) * 2013-11-27 2020-10-14 삼성전자 주식회사 전자 장치 및 전자 장치의 메모리 관리 방법
US20170024326A1 (en) * 2015-07-22 2017-01-26 CNEX-Labs, Inc. Method and Apparatus for Caching Flash Translation Layer (FTL) Table
US9710383B1 (en) * 2015-09-29 2017-07-18 EMC IP Holding Company LLC Caching techniques
US20170168957A1 (en) * 2015-12-10 2017-06-15 Ati Technologies Ulc Aware Cache Replacement Policy
US10496544B2 (en) * 2016-12-29 2019-12-03 Intel Corporation Aggregated write back in a direct mapped two level memory
US10318421B2 (en) * 2017-04-12 2019-06-11 International Business Machines Corporation Lightweight mechanisms for selecting infrequently executed methods for eviction from code cache
US20200026659A1 (en) * 2017-11-20 2020-01-23 Nutanix, Inc. Virtualized memory paging using random access persistent memory devices
JP6968016B2 (ja) * 2018-03-22 2021-11-17 キオクシア株式会社 ストレージデバイスおよびコンピュータシステム

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102831069A (zh) * 2012-06-30 2012-12-19 华为技术有限公司 内存处理方法、内存管理设备
CN106294192A (zh) * 2015-05-26 2017-01-04 龙芯中科技术有限公司 内存分配方法、内存分配装置及服务器
US20170109290A1 (en) * 2015-10-16 2017-04-20 International Business Machines Corporation Method to share a coherent accelerator context inside the kernel
CN107885666A (zh) * 2016-09-28 2018-04-06 华为技术有限公司 一种内存管理方法和装置
CN110018900A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110888821A (zh) * 2019-09-30 2020-03-17 华为技术有限公司 一种内存管理方法及装置
CN110955495A (zh) * 2019-11-26 2020-04-03 网易(杭州)网络有限公司 虚拟化内存的管理方法、装置和存储介质
CN111078587A (zh) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 内存分配方法、装置、存储介质及电子设备
CN111078410A (zh) * 2019-12-11 2020-04-28 Oppo(重庆)智能科技有限公司 内存分配方法、装置、存储介质及电子设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4134829A4

Also Published As

Publication number Publication date
CN118210741A (zh) 2024-06-18
CN113590509B (zh) 2024-03-26
EP4134829B1 (en) 2024-09-18
US20230176980A1 (en) 2023-06-08
EP4134829A1 (en) 2023-02-15
CN113590509A (zh) 2021-11-02
EP4134829A4 (en) 2023-09-06

Similar Documents

Publication Publication Date Title
WO2021218502A1 (zh) 一种页交换的方法、存储系统和电子设备
CN107885666B (zh) 一种内存管理方法和装置
US20190370009A1 (en) Intelligent swap for fatigable storage mediums
US11853223B2 (en) Caching streams of memory requests
US9823854B2 (en) Priority-based access of compressed memory lines in memory in a processor-based system
EP3163451B1 (en) Memory management method and device, and memory controller
KR20060023963A (ko) 멀티쓰레디드 컴퓨터 프로세싱을 제공하는 방법, 장치 및시스템
US9323774B2 (en) Compressed pointers for cell structures
WO2021147330A1 (zh) 内存交换的方法、装置
CN108351818B (zh) 用于在存储器中实现纠错码的系统和方法
CN114546897A (zh) 内存访问方法、装置、电子设备及存储介质
JP6674460B2 (ja) 不均一メモリアーキテクチャにおける改善されたレイテンシのためのシステムおよび方法
CN112199039B (zh) 虚拟存储管理方法及处理器
CN107111560B (zh) 用于在非统一存储器架构中提供改进的延迟的系统和方法
CN109165172B (zh) 缓存数据处理方法及相关设备
US20180356991A1 (en) Defragmentation of persistent main memory
US20240143220A1 (en) Data swapping method and apparatus
US20090024798A1 (en) Storing Data
CN112988074B (zh) 一种存储系统管理软件适配方法及装置
US10977176B2 (en) Prefetching data to reduce cache misses
CN115269169A (zh) 内存回收的方法及电子设备
CN116627876A (zh) 地址重映射方法、装置、设备及存储介质
CN116954511A (zh) 存储处理方法和电子设备、可读存储介质
CN117707639A (zh) 应用启动加速方法、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21797595

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021797595

Country of ref document: EP

Effective date: 20221108

NENP Non-entry into the national phase

Ref country code: DE