[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMZfGtUfefDjTw-rSfv=OHQzDWpvAFJtspOrv3+J2hCRFoLBAA@mail.gmail.com>
Date: Thu, 19 Aug 2021 10:04:06 +0800
From: Muchun Song <songmuchun@...edance.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
yanghui <yanghui.def@...edance.com>,
Linux Memory Management List <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task
On Wed, Aug 18, 2021 at 11:07 PM Matthew Wilcox <willy@...radead.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@...radead.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.
Powered by blists - more mailing lists