Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm, swap: remove fragment clusters counter

It was used for calculating the iteration number when the swap allocator
wants to scan the whole fragment list. Now the allocator only scans one
fragment cluster at a time, so no one uses this counter anymore.

Remove it as a cleanup; the performance change is marginal:

Build linux kernel using 10G ZRAM, make -j96, defconfig with 2G cgroup
memory limit, on top of tmpfs, 64kB mTHP enabled:

Before: sys time: 6278.45s
After: sys time: 6176.34s

Change to 8G ZRAM:

Before: sys time: 5572.85s
After: sys time: 5531.49s

Link: https://lkml.kernel.org/r/20250806161748.76651-3-ryncsn@gmail.com
Signed-off-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Acked-by: Chris Li <chrisl@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Barry Song <baohua@kernel.org>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kairui Song and committed by
Andrew Morton
913fff31 b25786b4

-8
-1
include/linux/swap.h
··· 310 310 /* list of cluster that contains at least one free slot */ 311 311 struct list_head frag_clusters[SWAP_NR_ORDERS]; 312 312 /* list of cluster that are fragmented or contented */ 313 - atomic_long_t frag_cluster_nr[SWAP_NR_ORDERS]; 314 313 unsigned int pages; /* total of usable pages of swap */ 315 314 atomic_long_t inuse_pages; /* number of those currently in use */ 316 315 struct swap_sequential_cluster *global_cluster; /* Use one global cluster for rotating device */
-7
mm/swapfile.c
··· 470 470 else 471 471 list_move_tail(&ci->list, list); 472 472 spin_unlock(&si->lock); 473 - 474 - if (ci->flags == CLUSTER_FLAG_FRAG) 475 - atomic_long_dec(&si->frag_cluster_nr[ci->order]); 476 - else if (new_flags == CLUSTER_FLAG_FRAG) 477 - atomic_long_inc(&si->frag_cluster_nr[ci->order]); 478 473 ci->flags = new_flags; 479 474 } 480 475 ··· 960 965 * allocation, but reclaim may drop si->lock and race with another user. 961 966 */ 962 967 while ((ci = isolate_lock_cluster(si, &si->frag_clusters[o]))) { 963 - atomic_long_dec(&si->frag_cluster_nr[o]); 964 968 found = alloc_swap_scan_cluster(si, ci, cluster_offset(si, ci), 965 969 0, usage); 966 970 if (found) ··· 3211 3217 for (i = 0; i < SWAP_NR_ORDERS; i++) { 3212 3218 INIT_LIST_HEAD(&si->nonfull_clusters[i]); 3213 3219 INIT_LIST_HEAD(&si->frag_clusters[i]); 3214 - atomic_long_set(&si->frag_cluster_nr[i], 0); 3215 3220 } 3216 3221 3217 3222 /*