* [PATCH] mm/z3fold: remove unneeded spinlock
@ 2024-02-04 12:54 Zhongkun He
2024-02-04 18:46 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Zhongkun He @ 2024-02-04 12:54 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, Zhongkun He
There is no need to use spinlock in this section, so
remove it.
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 7c76b396b74c..7f608c0667f3 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -442,8 +442,6 @@ static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked)
WARN_ON(!list_empty(&zhdr->buddy));
set_bit(PAGE_STALE, &page->private);
clear_bit(NEEDS_COMPACTING, &page->private);
- spin_lock(&pool->lock);
- spin_unlock(&pool->lock);
if (locked)
z3fold_page_unlock(zhdr);
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/z3fold: remove unneeded spinlock
2024-02-04 12:54 [PATCH] mm/z3fold: remove unneeded spinlock Zhongkun He
@ 2024-02-04 18:46 ` Matthew Wilcox
2024-02-05 1:08 ` [External] " Zhongkun He
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2024-02-04 18:46 UTC (permalink / raw)
To: Zhongkun He; +Cc: akpm, linux-mm, linux-kernel
On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote:
> There is no need to use spinlock in this section, so
> remove it.
I don't know this code at all, but the idiom is (relatively) common.
It waits until anybody _currently_ holding the lock has released it.
That would, eg, make it safe to free the 'pool' memory.
> - spin_lock(&pool->lock);
> - spin_unlock(&pool->lock);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] Re: [PATCH] mm/z3fold: remove unneeded spinlock
2024-02-04 18:46 ` Matthew Wilcox
@ 2024-02-05 1:08 ` Zhongkun He
2024-02-08 3:29 ` Johannes Weiner
0 siblings, 1 reply; 5+ messages in thread
From: Zhongkun He @ 2024-02-05 1:08 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: akpm, linux-mm, linux-kernel
On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote:
> > There is no need to use spinlock in this section, so
> > remove it.
>
> I don't know this code at all, but the idiom is (relatively) common.
> It waits until anybody _currently_ holding the lock has released it.
>
> That would, eg, make it safe to free the 'pool' memory.
>
> > - spin_lock(&pool->lock);
> > - spin_unlock(&pool->lock);
>
no, please see the commit 'e774a7bc7f0adb'.
spin_lock(&pool->lock);
- if (!list_empty(&page->lru))
- list_del_init(&page->lru);
spin_unlock(&pool->lock);
The original purpose of this lock was to protect page->lru,
which was removed now, so the spinlock is unnecessary.
Thanks for your time.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] Re: [PATCH] mm/z3fold: remove unneeded spinlock
2024-02-05 1:08 ` [External] " Zhongkun He
@ 2024-02-08 3:29 ` Johannes Weiner
2024-02-08 17:39 ` Zhongkun He
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2024-02-08 3:29 UTC (permalink / raw)
To: Zhongkun He; +Cc: Matthew Wilcox, akpm, linux-mm, linux-kernel, Vitaly Wool
On Mon, Feb 05, 2024 at 09:08:05AM +0800, Zhongkun He wrote:
> On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote:
> > > There is no need to use spinlock in this section, so
> > > remove it.
> >
> > I don't know this code at all, but the idiom is (relatively) common.
> > It waits until anybody _currently_ holding the lock has released it.
> >
> > That would, eg, make it safe to free the 'pool' memory.
> >
> > > - spin_lock(&pool->lock);
> > > - spin_unlock(&pool->lock);
> >
>
> no, please see the commit 'e774a7bc7f0adb'.
>
> spin_lock(&pool->lock);
> - if (!list_empty(&page->lru))
> - list_del_init(&page->lru);
> spin_unlock(&pool->lock);
>
> The original purpose of this lock was to protect page->lru,
> which was removed now, so the spinlock is unnecessary.
But pool->lock protects other stuff too? This doesn't rule out that
there is some other ordering dependency on cycling the lock before
freeing the entry. The person who would know best is the maintainer of
this code, Vitaly. Let's CC him.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] Re: [PATCH] mm/z3fold: remove unneeded spinlock
2024-02-08 3:29 ` Johannes Weiner
@ 2024-02-08 17:39 ` Zhongkun He
0 siblings, 0 replies; 5+ messages in thread
From: Zhongkun He @ 2024-02-08 17:39 UTC (permalink / raw)
To: Johannes Weiner; +Cc: Matthew Wilcox, akpm, linux-mm, linux-kernel, Vitaly Wool
On Thu, Feb 8, 2024 at 11:29 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Mon, Feb 05, 2024 at 09:08:05AM +0800, Zhongkun He wrote:
> > On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote:
> > >
> > > On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote:
> > > > There is no need to use spinlock in this section, so
> > > > remove it.
> > >
> > > I don't know this code at all, but the idiom is (relatively) common.
> > > It waits until anybody _currently_ holding the lock has released it.
> > >
> > > That would, eg, make it safe to free the 'pool' memory.
> > >
> > > > - spin_lock(&pool->lock);
> > > > - spin_unlock(&pool->lock);
> > >
> >
> > no, please see the commit 'e774a7bc7f0adb'.
> >
> > spin_lock(&pool->lock);
> > - if (!list_empty(&page->lru))
> > - list_del_init(&page->lru);
> > spin_unlock(&pool->lock);
> >
> > The original purpose of this lock was to protect page->lru,
> > which was removed now, so the spinlock is unnecessary.
>
> But pool->lock protects other stuff too? This doesn't rule out that
> there is some other ordering dependency on cycling the lock before
> freeing the entry. The person who would know best is the maintainer of
> this code, Vitaly. Let's CC him.
Thank you for your reply and look forward to hearing from Vitaly.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-08 17:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-04 12:54 [PATCH] mm/z3fold: remove unneeded spinlock Zhongkun He
2024-02-04 18:46 ` Matthew Wilcox
2024-02-05 1:08 ` [External] " Zhongkun He
2024-02-08 3:29 ` Johannes Weiner
2024-02-08 17:39 ` Zhongkun He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox