linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/zswap: optimize for dynamic zswap_pools
@ 2024-02-11 13:57 Chengming Zhou
  2024-02-11 13:57 ` [PATCH 1/2] mm/zswap: global lru and shrinker shared by all zswap_pools Chengming Zhou
  2024-02-11 13:57 ` [PATCH 2/2] mm/zswap: change zswap_pool kref to percpu_ref Chengming Zhou
  0 siblings, 2 replies; 18+ messages in thread
From: Chengming Zhou @ 2024-02-11 13:57 UTC (permalink / raw)
  To: Andrew Morton, Johannes Weiner, Yosry Ahmed, Nhat Pham
  Cc: linux-mm, linux-kernel, Chengming Zhou

Dynamic pool creation has been supported for a long time, which maybe
not used so much in practice. But with the per-memcg lru merged, the
current structure of zswap_pool's lru and shrinker become less optimal.

In the current structure, each zswap_pool has its own lru, shrinker and
shrink_work, but only the latest zswap_pool will be the current used.

1. When memory has pressure, all shrinkers of zswap_pools will try to
   shrink its lru list, there is no order between them.

2. When zswap limit hit, only the last zswap_pool's shrink_work will
   try to shrink its own lru, which is inefficient.

A more natural way is to have a global zswap lru shared between all
zswap_pools, and so is the shrinker. The code becomes much simpler too.

Another optimization is changing zswap_pool kref to percpu_ref, which
will be taken reference by every zswap entry. So the scalability is
better.

Testing kernel build in tmpfs with memory.max=2GB (zswap shrinker and
writeback enabled with one 50GB swapfile).

        mm-unstable  zswap-global-lru
real    63.20        63.12
user    1061.75      1062.95
sys     268.74       264.44

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
Chengming Zhou (2):
      mm/zswap: global lru and shrinker shared by all zswap_pools
      mm/zswap: change zswap_pool kref to percpu_ref

 mm/zswap.c | 183 +++++++++++++++++++++++++------------------------------------
 1 file changed, 76 insertions(+), 107 deletions(-)
---
base-commit: 191d97734e41a5c9f90a2f6636fdd335ae1d435d
change-id: 20240210-zswap-global-lru-94d49316178b

Best regards,
-- 
Chengming Zhou <zhouchengming@bytedance.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-02-13 17:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-11 13:57 [PATCH 0/2] mm/zswap: optimize for dynamic zswap_pools Chengming Zhou
2024-02-11 13:57 ` [PATCH 1/2] mm/zswap: global lru and shrinker shared by all zswap_pools Chengming Zhou
2024-02-11 19:01   ` kernel test robot
2024-02-12 13:17     ` Chengming Zhou
2024-02-11 21:04   ` Nhat Pham
2024-02-12 13:20     ` Chengming Zhou
2024-02-11 22:05   ` kernel test robot
2024-02-13 12:57   ` Yosry Ahmed
2024-02-13 14:20     ` Chengming Zhou
2024-02-13 17:43       ` Yosry Ahmed
2024-02-11 13:57 ` [PATCH 2/2] mm/zswap: change zswap_pool kref to percpu_ref Chengming Zhou
2024-02-11 21:21   ` Nhat Pham
2024-02-12 13:29     ` Chengming Zhou
2024-02-12 18:53       ` Nhat Pham
2024-02-13 14:22         ` Chengming Zhou
2024-02-12 22:42   ` Yosry Ahmed
2024-02-13 14:31     ` Chengming Zhou
2024-02-13 17:45       ` Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).