linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/zsmalloc: simplify synchronization between zs_page_migrate() and free_zspage()
@ 2024-02-27  3:02 Chengming Zhou
  2024-02-27  3:02 ` [PATCH 1/2] mm/zsmalloc: don't hold locks of all pages when free_zspage() Chengming Zhou
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Chengming Zhou @ 2024-02-27  3:02 UTC (permalink / raw)
  To: yosryahmed, Sergey Senozhatsky, hannes, nphamcs, Andrew Morton,
	Minchan Kim
  Cc: linux-kernel, linux-mm, Chengming Zhou

Hello,

free_zspage() has to hold locks of all pages, since zs_page_migrate()
path rely on this page lock to protect the race between zs_free() and
it, so it can safely get zspage from page->private.

But this way is not good and simple enough:

1. Since zs_free() couldn't be sleepable, it can only trylock pages,
   or has to kick_deferred_free() to defer that to a work.

2. Even in the worker context, async_free_zspage() can't simply
   lock all pages in lock_zspage(), it's still trylock because of
   the race between zs_free() and zs_page_migrate(). Please see
   the commit 2505a981114d ("zsmalloc: fix races between asynchronous
   zspage free and page migration") for details.

Actually, all free_zspage() needs is to get zspage from page safely,
we can use RCU to achieve it easily. Then free_zspage() don't need to
hold locks of all pages, so don't need the deferred free mechanism
at all. This patchset implements it and remove all of deferred free
related code.

Thanks for review and comments!

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
Chengming Zhou (2):
      mm/zsmalloc: don't hold locks of all pages when free_zspage()
      mm/zsmalloc: remove the deferred free mechanism

 mm/zsmalloc.c | 206 ++++++++++++++++------------------------------------------
 1 file changed, 56 insertions(+), 150 deletions(-)
---
base-commit: ccbd06e764bac9bbf6b4e91c700fe6dd28f08fb3
change-id: 20240226-zsmalloc-zspage-rcu-b2c12f054fb4

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


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

end of thread, other threads:[~2024-02-28  6:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27  3:02 [PATCH 0/2] mm/zsmalloc: simplify synchronization between zs_page_migrate() and free_zspage() Chengming Zhou
2024-02-27  3:02 ` [PATCH 1/2] mm/zsmalloc: don't hold locks of all pages when free_zspage() Chengming Zhou
2024-02-28  4:33   ` Sergey Senozhatsky
2024-02-28  5:14     ` Chengming Zhou
2024-02-28  5:29       ` Sergey Senozhatsky
2024-02-28  5:42         ` Chengming Zhou
2024-02-28  6:07           ` Sergey Senozhatsky
2024-02-28  6:01   ` Sergey Senozhatsky
2024-02-28  6:44     ` Chengming Zhou
2024-02-28  6:14   ` Sergey Senozhatsky
2024-02-28  6:49     ` Chengming Zhou
2024-02-27  3:02 ` [PATCH 2/2] mm/zsmalloc: remove the deferred free mechanism Chengming Zhou
2024-02-28  1:57 ` [PATCH 0/2] mm/zsmalloc: simplify synchronization between zs_page_migrate() and free_zspage() Sergey Senozhatsky
2024-02-28  2:22   ` [External] " Chengming Zhou
2024-02-28  3:54 ` Sergey Senozhatsky

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