[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250318150614.6415-5-shikemeng@huaweicloud.com>
Date: Tue, 18 Mar 2025 23:06:10 +0800
From: Kemeng Shi <shikemeng@...weicloud.com>
To: akpm@...ux-foundation.org
Cc: tim.c.chen@...ux.intel.com,
ryncsn@...il.com,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 4/8] 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.
Signed-off-by: Kemeng Shi <shikemeng@...weicloud.com>
Reviewed-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
mm/swapfile.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 40e41e514813..2a08d9e89f90 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1490,10 +1490,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;
--
2.30.0
Powered by blists - more mailing lists