[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250407234223.1059191-15-nphamcs@gmail.com>
Date: Mon, 7 Apr 2025 16:42:15 -0700
From: Nhat Pham <nphamcs@...il.com>
To: linux-mm@...ck.org
Cc: akpm@...ux-foundation.org,
hannes@...xchg.org,
hughd@...gle.com,
yosry.ahmed@...ux.dev,
mhocko@...nel.org,
roman.gushchin@...ux.dev,
shakeel.butt@...ux.dev,
muchun.song@...ux.dev,
len.brown@...el.com,
chengming.zhou@...ux.dev,
kasong@...cent.com,
chrisl@...nel.org,
huang.ying.caritas@...il.com,
ryan.roberts@....com,
viro@...iv.linux.org.uk,
baohua@...nel.org,
osalvador@...e.de,
lorenzo.stoakes@...cle.com,
christophe.leroy@...roup.eu,
pavel@...nel.org,
kernel-team@...a.com,
linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: [RFC PATCH 14/14] zswap: do not start zswap shrinker if there is no physical swap slots
When swap is virtualized, we no longer pre-allocate a slot on swapfile
for each zswap entry. Do not start the zswap shrinker if there is no
physical swap slots available.
Signed-off-by: Nhat Pham <nphamcs@...il.com>
---
mm/zswap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mm/zswap.c b/mm/zswap.c
index 15429825d667..f2f412cc1911 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1277,6 +1277,14 @@ static unsigned long zswap_shrinker_count(struct shrinker *shrinker,
if (!zswap_shrinker_enabled || !mem_cgroup_zswap_writeback_enabled(memcg))
return 0;
+ /*
+ * When swap is virtualized, we do not have any swap slots on swapfile
+ * preallocated for zswap objects. If there is no slot available, we
+ * cannot writeback and should just bail out here.
+ */
+ if (IS_ENABLED(CONFIG_VIRTUAL_SWAP) && !get_nr_swap_pages())
+ return 0;
+
/*
* The shrinker resumes swap writeback, which will enter block
* and may enter fs. XXX: Harmonize with vmscan.c __GFP_FS
--
2.47.1
Powered by blists - more mailing lists