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: skip scanning cluster range if it's empty cluster

Since ci->lock has been taken when isolating cluster from
si->free_clusters or taking si->percpu_cluster->next[order], it's
unnecessary to scan and check the cluster range availability if i'ts empty
cluster, and this can accelerate the huge page swapping.

Link: https://lkml.kernel.org/r/20250205092721.9395-5-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <ryncsn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
9b9cba72 0eb7d2c3

+3
+3
mm/swapfile.c
··· 730 730 unsigned long offset, end = start + nr_pages; 731 731 unsigned char *map = si->swap_map; 732 732 733 + if (cluster_is_empty(ci)) 734 + return true; 735 + 733 736 for (offset = start; offset < end; offset++) { 734 737 switch (READ_ONCE(map[offset])) { 735 738 case 0: