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: drop last SWAP_MAP_SHMEM flag in batch in swap_entries_put_nr()

The SWAP_MAP_SHMEM indicates last map from shmem. Therefore we can drop
SWAP_MAP_SHMEM in batch in similar way to drop last ref count in batch.

Link: https://lkml.kernel.org/r/20250325162528.68385-6-shikemeng@huaweicloud.com
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
Reviewed-by: Baoquan He <bhe@redhat.com>
Cc: Kairui Song <kasong@tencent.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kemeng Shi and committed by
Andrew Morton
f2252acf 46e0ab2c

+5 -2
+5 -2
mm/swapfile.c
··· 192 192 unsigned char *map_end = map + nr_pages; 193 193 unsigned char count = *map; 194 194 195 - if (swap_count(count) != 1) 195 + if (swap_count(count) != 1 && swap_count(count) != SWAP_MAP_SHMEM) 196 196 return false; 197 197 198 198 while (++map < map_end) { ··· 1487 1487 unsigned char count; 1488 1488 int i; 1489 1489 1490 - if (nr <= 1 || swap_count(data_race(si->swap_map[offset])) != 1) 1490 + if (nr <= 1) 1491 + goto fallback; 1492 + count = swap_count(data_race(si->swap_map[offset])); 1493 + if (count != 1 && count != SWAP_MAP_SHMEM) 1491 1494 goto fallback; 1492 1495 /* cross into another cluster */ 1493 1496 if (nr > SWAPFILE_CLUSTER - offset % SWAPFILE_CLUSTER)