* [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc
@ 2024-02-04 13:15 Zhongkun He
2024-02-08 3:34 ` Johannes Weiner
2024-02-21 22:23 ` Andrew Morton
0 siblings, 2 replies; 5+ messages in thread
From: Zhongkun He @ 2024-02-04 13:15 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, Zhongkun He
The spinklock in z3fold_alloc() is used to protect page->lru,
but now it was removed in commit 'e774a7bc7f0ad', so remove
the spinlock too.
Signed-off-by: Zhongkun He <hezhongkun.hzk@bytedance.com>
---
mm/z3fold.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 7f608c0667f3..58946cacbfbb 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -1068,9 +1068,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
add_to_unbuddied(pool, zhdr);
headless:
- spin_lock(&pool->lock);
*handle = encode_handle(zhdr, bud);
- spin_unlock(&pool->lock);
if (bud != HEADLESS)
z3fold_page_unlock(zhdr);
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc
2024-02-04 13:15 [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc Zhongkun He
@ 2024-02-08 3:34 ` Johannes Weiner
2024-02-08 17:29 ` [External] " Zhongkun He
2024-02-21 22:23 ` Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2024-02-08 3:34 UTC (permalink / raw)
To: Zhongkun He; +Cc: akpm, linux-mm
On Sun, Feb 04, 2024 at 09:15:43PM +0800, Zhongkun He wrote:
> The spinklock in z3fold_alloc() is used to protect page->lru,
> but now it was removed in commit 'e774a7bc7f0ad', so remove
> the spinlock too.
The pool->lock clearly protects things other than page->lru.
I'm not saying that you're wrong, but your changelog doesn't make a
strong case that you're right, either ;)
Please CC Vitaly (scripts/get_maintainer.pl) on these patches.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] Re: [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc
2024-02-08 3:34 ` Johannes Weiner
@ 2024-02-08 17:29 ` Zhongkun He
0 siblings, 0 replies; 5+ messages in thread
From: Zhongkun He @ 2024-02-08 17:29 UTC (permalink / raw)
To: Johannes Weiner; +Cc: akpm, linux-mm
On Thu, Feb 8, 2024 at 11:34 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Sun, Feb 04, 2024 at 09:15:43PM +0800, Zhongkun He wrote:
> > The spinklock in z3fold_alloc() is used to protect page->lru,
> > but now it was removed in commit 'e774a7bc7f0ad', so remove
> > the spinlock too.
>
> The pool->lock clearly protects things other than page->lru.
Yes, it protects pool unbuddied lists now.
I mean the following page-lru is removed in z3fold_alloc:
headless:
spin_lock(&pool->lock);
- /* Add/move z3fold page to beginning of LRU */
- if (!list_empty(&page->lru))
- list_del(&page->lru);
-
- list_add(&page->lru, &pool->lru);
-
*handle = encode_handle(zhdr, bud);
spin_unlock(&pool->lock);
if (bud != HEADLESS)
z3fold_page_unlock(zhdr);
For more detail please see the commit 'e774a7bc7f0ad'.
>
> I'm not saying that you're wrong, but your changelog doesn't make a
> strong case that you're right, either ;)
>
Hi Johannes, I am confused by the annotation :
The __encode_handle() annotation show:
* Pool lock should be held as this function accesses first_num.
but I did not find any use cases where first_num was protected by pool lock.
Furthermore, encode_handle() is protected by z3fold_page_lock() as I can
see.
> Please CC Vitaly (scripts/get_maintainer.pl) on these patches.
Got it, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc
2024-02-04 13:15 [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc Zhongkun He
2024-02-08 3:34 ` Johannes Weiner
@ 2024-02-21 22:23 ` Andrew Morton
2024-02-22 2:40 ` [External] " Zhongkun He
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-02-21 22:23 UTC (permalink / raw)
To: Zhongkun He; +Cc: linux-mm
On Sun, 4 Feb 2024 21:15:43 +0800 Zhongkun He <hezhongkun.hzk@bytedance.com> wrote:
> The spinklock in z3fold_alloc() is used to protect page->lru,
> but now it was removed in commit 'e774a7bc7f0ad', so remove
> the spinlock too.
>
I think I'll drop this patch and "mm/z3fold: remove unneeded spinlock"
pending some more clarity and agreement on whether these are
safe. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] Re: [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc
2024-02-21 22:23 ` Andrew Morton
@ 2024-02-22 2:40 ` Zhongkun He
0 siblings, 0 replies; 5+ messages in thread
From: Zhongkun He @ 2024-02-22 2:40 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm
>
> I think I'll drop this patch and "mm/z3fold: remove unneeded spinlock"
> pending some more clarity and agreement on whether these are
> safe. Thanks.
Hi Andrew.
Per my understanding, these patches are safe and I hope they can be
reviewed by some experts.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-22 2:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-04 13:15 [PATCH] mm/z3fold:remove unneeded spinlock in z3fold_alloc Zhongkun He
2024-02-08 3:34 ` Johannes Weiner
2024-02-08 17:29 ` [External] " Zhongkun He
2024-02-21 22:23 ` Andrew Morton
2024-02-22 2:40 ` [External] " Zhongkun He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox