Commit 96836d4f authored by Chris Li's avatar Chris Li Committed by Treehugger Robot
Browse files

FROMLIST: BACKPORT: mm: swap: swap cluster switch to double link list



Previously, the swap cluster used a cluster index as a pointer
to construct a custom single link list type "swap_cluster_list".
The next cluster pointer is shared with the cluster->count.
It prevents puting the non free cluster into a list.

Change the cluster to use the standard double link list instead.
This allows tracing the nonfull cluster in the follow up patch.
That way, it is faster to get to the nonfull cluster of that order.

Remove the cluster getter/setter for accessing the cluster
struct member.

The list operation is protected by the swap_info_struct->lock.

Change cluster code to use "struct swap_cluster_info *" to
reference the cluster rather than by using index. That is more
consistent with the list manipulation. It avoids the repeat
adding index to the cluser_info. The code is easier to understand.

Remove the cluster next pointer is NULL flag, the double link
list can handle the empty list pretty well.

The "swap_cluster_info" struct is two pointer bigger, because
512 swap entries share one swap struct, it has very little impact
on the average memory usage per swap entry. For 1TB swapfile, the
swap cluster data structure increases from 8MB to 24MB.

Other than the list conversion, there is no real function change
in this patch.

Signed-off-by: default avatarChris Li <chrisl@kernel.org>
Link: https://lore.kernel.org/r/20240711-swap-allocator-v4-1-0295a4d4c7aa@kernel.org/


Bug: 313807618
Bug: 351082780
[ Fix trivial conflict in include/linux/swap.h swap_info_struct
    - Kalesh Singh ]
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
Change-Id: Ifcc388c6f1d8e5569067ed87aad60766cce7a5b8
parent 2b24dd9d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment