LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Muchun Song <songmuchun@bytedance.com>
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: Wed, 18 Aug 2021 16:07:11 +0100	[thread overview]
Message-ID: <YR0iHyBHuYufepWV@casper.infradead.org> (raw)
In-Reply-To: <CAMZfGtVNJxTw-TPXHGF0kCwYMQK8hVG6=Z+hE3yuQRZh6ak-mw@mail.gmail.com>

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.

  reply	other threads:[~2021-08-18 15:08 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 [this message]
2021-08-19  2:04         ` Muchun Song

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=YR0iHyBHuYufepWV@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=songmuchun@bytedance.com \
    --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).