linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/zswap: optimize the scalability of zswap rb-tree
@ 2024-01-17  9:23 Chengming Zhou
  2024-01-17  9:23 ` [PATCH 1/2] mm/zswap: make sure each swapfile always have " Chengming Zhou
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Chengming Zhou @ 2024-01-17  9:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Yosry Ahmed, Chengming Zhou, linux-kernel, Johannes Weiner,
	linux-mm, Chris Li, Nhat Pham

When testing the zswap performance by using kernel build -j32 in a tmpfs
directory, I found the scalability of zswap rb-tree is not good, which
is protected by the only spinlock. That would cause heavy lock contention
if multiple tasks zswap_store/load concurrently.

So a simple solution is to split the only one zswap rb-tree into multiple
rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M). This idea is
from the commit 4b3ef9daa4fc ("mm/swap: split swap cache into 64MB trunks").

Although this method can't solve the spinlock contention completely, it
can mitigate much of that contention. Below is the results of kernel build
in tmpfs with zswap shrinker enabled:

     linux-next  zswap-lock-optimize
real 1m9.181s    1m3.820s
user 17m44.036s  17m40.100s
sys  7m37.297s   4m54.622s

So there are clearly improvements. And it's complementary with the ongoing
zswap xarray conversion by Chris. Anyway, I think we can also merge this
first, it's complementary IMHO. So I just refresh and resend this for
further discussion.

Thanks for review and comment!

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
Chengming Zhou (2):
      mm/zswap: make sure each swapfile always have zswap rb-tree
      mm/zswap: split zswap rb-tree

 include/linux/zswap.h |  7 +++--
 mm/swapfile.c         | 10 ++++---
 mm/zswap.c            | 74 ++++++++++++++++++++++++++++++++-------------------
 3 files changed, 59 insertions(+), 32 deletions(-)
---
base-commit: ab27740f76654ed58dd32ac0ba0031c18a6dea3b
change-id: 20240117-b4-zswap-lock-optimize-44e071c13427

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


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

end of thread, other threads:[~2024-01-19  6:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17  9:23 [PATCH 0/2] mm/zswap: optimize the scalability of zswap rb-tree Chengming Zhou
2024-01-17  9:23 ` [PATCH 1/2] mm/zswap: make sure each swapfile always have " Chengming Zhou
2024-01-18 15:05   ` Johannes Weiner
2024-01-18 17:37   ` Yosry Ahmed
2024-01-18 18:16   ` Nhat Pham
2024-01-17  9:23 ` [PATCH 2/2] mm/zswap: split " Chengming Zhou
2024-01-18 15:11   ` Johannes Weiner
2024-01-19  6:20     ` Chengming Zhou
2024-01-18 19:24   ` Nhat Pham
2024-01-19  6:24     ` Chengming Zhou
2024-01-17 18:37 ` [PATCH 0/2] mm/zswap: optimize the scalability of " Yosry Ahmed
2024-01-17 23:41   ` Chris Li
2024-01-17 23:47     ` Yosry Ahmed
2024-01-18  0:17       ` Chris Li
2024-01-18  0:34         ` Yosry Ahmed
2024-01-18  1:03           ` Chris Li
2024-01-18  3:51             ` Yosry Ahmed
2024-01-18  0:49         ` Nhat Pham
2024-01-18 15:34   ` Johannes Weiner
2024-01-18 17:30     ` Yosry Ahmed
2024-01-18 18:06       ` Johannes Weiner
2024-01-18 18:37         ` Yosry Ahmed
2024-01-19  6:40           ` Chengming Zhou

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).