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. 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. Change-Id: Iee0a56f864f16524c6b13d5eb8a94e225393a7d2 Signed-off-by:Chris Li <chrisl@kernel.org> Bug: 313807618 Link: https://lore.kernel.org/r/20240524-swap-allocator-v1-1-47861b423b26@kernel.org/ Signed-off-by:
Kalesh Singh <kaleshsingh@google.com>
Loading
Please sign in to comment