mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
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>
This commit is contained in:
parent
835b868878
commit
46e0ab2c62
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user