diff options
author | Kemeng Shi <shikemeng@huaweicloud.com> | 2025-03-26 00:25:24 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2025-05-11 17:48:13 -0700 |
commit | 46e0ab2c62067a8d5e62ae90088b1743af83725d (patch) | |
tree | 930a08429c0b0c78171dbc59271fa085074df997 | |
parent | 835b868878d0127bd29b8c0009dc424a63dadffb (diff) |
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>
-rw-r--r-- | mm/swapfile.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index f0ba27db9b3e..f8fe507be4f3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1498,10 +1498,11 @@ static bool swap_entries_put_nr(struct swap_info_struct *si, unlock_cluster(ci); goto fallback; } - for (i = 0; i < nr; i++) - WRITE_ONCE(si->swap_map[offset + i], SWAP_HAS_CACHE); if (!has_cache) swap_entries_free(si, ci, entry, nr); + else + for (i = 0; i < nr; i++) + WRITE_ONCE(si->swap_map[offset + i], SWAP_HAS_CACHE); unlock_cluster(ci); return has_cache; |