]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: swap: free each cluster individually in swap_entries_put_map_nr()
authorKemeng Shi <shikemeng@huaweicloud.com>
Tue, 25 Mar 2025 16:25:26 +0000 (00:25 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 May 2025 00:48:13 +0000 (17:48 -0700)
commit4d71d9062dd7b2ace56f2351b9f3f06e6c0acf81
tree46411f7653d0300510e2ca990617f9cf28fd2994
parentf2252acf444764e7de7380201c518ee5ab6fd9da
mm: swap: free each cluster individually in swap_entries_put_map_nr()

1. Factor out general swap_entries_put_map() helper to drop entries
   belonging to one cluster.  If entries are last map, free entries in
   batch, otherwise put entries with cluster lock acquired and released
   only once.

2. Iterate and call swap_entries_put_map() for each cluster in
   swap_entries_put_nr() to leverage batch-remove for last map belonging
   to one cluster and reduce lock acquire/release in fallback case.

3. As swap_entries_put_nr() won't handle SWAP_HSA_CACHE drop, rename
   it to swap_entries_put_map_nr().

4. As we won't drop each entry invidually with swap_entry_put() now,
   do reclaim in free_swap_and_cache_nr() because
   swap_entries_put_map_nr() is general routine to drop reference and the
   relcaim work should only be done in free_swap_and_cache_nr().  Remove
   stale comment accordingly.

Link: https://lkml.kernel.org/r/20250325162528.68385-7-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>
mm/swapfile.c