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: use swap_entries_free() drop last ref count in swap_entries_put_nr()

Use swap_entries_free() to directly free swap entries when the swap
entries are not cached and referenced, without needing to set swap entries
to set intermediate SWAP_HAS_CACHE state.

Link: https://lkml.kernel.org/r/20250325162528.68385-5-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
46e0ab2c 835b8688

+3 -2
+3 -2
mm/swapfile.c
··· 1498 1498 unlock_cluster(ci); 1499 1499 goto fallback; 1500 1500 } 1501 - for (i = 0; i < nr; i++) 1502 - WRITE_ONCE(si->swap_map[offset + i], SWAP_HAS_CACHE); 1503 1501 if (!has_cache) 1504 1502 swap_entries_free(si, ci, entry, nr); 1503 + else 1504 + for (i = 0; i < nr; i++) 1505 + WRITE_ONCE(si->swap_map[offset + i], SWAP_HAS_CACHE); 1505 1506 unlock_cluster(ci); 1506 1507 1507 1508 return has_cache;