Patent ID: 11928359
Assignee: HUAWEI TECHNOLOGIES CO., LTD.
Field: Computer technology (Electrical engineering)
Classification: CPC G | IPC G

Claim 3:
4. A memory swapping method, comprising:
selecting n to-be-swapped-out pages, wherein n is an integer greater than 0;
compressing the n to-be-swapped-out pages into n compressed blocks, grouping the n compressed blocks into at least one group based on a group identifier, and buffering the at least one group in a compressed data buffer area, wherein compressed blocks comprised in each group have a same group identifier;
organizing at least one compressed block in one group into m to-be-written units, wherein m is an integer less than or equal to n and greater than 0, and a size of each of the m to-be-written units is an integer quantity of pages; and
writing the n to-be-written units into a swap area of a non-volatile storage device in a maximum of m batches, wherein at least one to-be-written unit in the m to-be-written units is stored in a segment of continuous space in the swap area,
wherein before the writing the m to-be-written units into a swap area of a non-volatile storage device in a maximum of m batches, the method further comprises:
creating a mapping table, wherein the mapping table comprises a correspondence between a page identifier of the at least one of the n compressed blocks and a swap area address corresponding to the at least one of the n compressed blocks, the page identifier is an identifier of at least one to-be-swapped-out page corresponding to the at least one of the n compressed blocks, the swap area address is an address of a segment of space that belongs to the swap area and that is allocated to the at least one of the n compressed blocks, and the mapping table is used to obtain the swap area address during page swap-in by using the page identifier.