LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
yanghui <yanghui.def@bytedance.com>,
Linux Memory Management List <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task
Date: Thu, 19 Aug 2021 10:04:06 +0800 [thread overview]
Message-ID: <CAMZfGtUfefDjTw-rSfv=OHQzDWpvAFJtspOrv3+J2hCRFoLBAA@mail.gmail.com> (raw)
In-Reply-To: <YR0iHyBHuYufepWV@casper.infradead.org>
On Wed, Aug 18, 2021 at 11:07 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Aug 18, 2021 at 10:02:46PM +0800, Muchun Song wrote:
> > On Tue, Aug 17, 2021 at 9:43 AM Matthew Wilcox <willy@infradead.org> wrote:
> > > > > + unsigned int target, nnodes;
> > > > > int i;
> > > > > int nid;
> > > > > + /*
> > > > > + * The barrier will stabilize the nodemask in a register or on
> > > > > + * the stack so that it will stop changing under the code.
> > > > > + *
> > > > > + * Between first_node() and next_node(), pol->nodes could be changed
> > > > > + * by other threads. So we put pol->nodes in a local stack.
> > > > > + */
> > > > > + barrier();
> > >
> > > I think this could be an smp_rmb()?
> >
> > Hi Matthew,
> >
> > I have a question. Why is barrier() not enough?
>
> I think barrier() may be more than is necessary. We don't need a
> barrier on non-SMP systems (or do we?) And we only need to order reads,
> not writes.
Here barrier() is just a compiler barrier, which is cheaper than
smp_rmb() which usually equals to memory barrier instruction
plus barrier(). So I think barrier() , which will stabilize the
nodemask in a register or on the stack, is more appropriate here.
Thanks.
prev parent reply other threads:[~2021-08-19 2:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-15 6:10 yanghui
2021-08-17 0:59 ` Andrew Morton
2021-08-17 1:43 ` Matthew Wilcox
2021-08-18 14:02 ` Muchun Song
2021-08-18 15:07 ` Matthew Wilcox
2021-08-19 2:04 ` Muchun Song [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMZfGtUfefDjTw-rSfv=OHQzDWpvAFJtspOrv3+J2hCRFoLBAA@mail.gmail.com' \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=yanghui.def@bytedance.com \
--subject='Re: [PATCH v3] mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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).