Re: [PATCH] kernel: fix data race in put_pid
From: Peter Zijlstra
Date: Fri Sep 18 2015 - 08:40:13 EST
On Fri, Sep 18, 2015 at 01:31:27PM +0100, James Hogan wrote:
> Hi Peter,
>
> On Fri, Sep 18, 2015 at 11:27:32AM +0200, Peter Zijlstra wrote:
> > On Fri, Sep 18, 2015 at 10:57:32AM +0200, Peter Zijlstra wrote:
> > > diff --git a/arch/metag/include/asm/atomic_lnkget.h b/arch/metag/include/asm/atomic_lnkget.h
> > > index 21c4c268b86c..1bd21c933435 100644
> > > --- a/arch/metag/include/asm/atomic_lnkget.h
> > > +++ b/arch/metag/include/asm/atomic_lnkget.h
> > > @@ -3,7 +3,8 @@
> > >
> > > #define ATOMIC_INIT(i) { (i) }
> > >
> > > -#define atomic_set(v, i) ((v)->counter = (i))
> > > +/* XXX: should be LNKSETD ? */
> > > +#define atomic_set(v, i) WRITE_ONCE((v)->counter, (i))
> > >
> > > #include <linux/compiler.h>
> > >
> >
> > James?
>
> It should be fine without a LNKSET. The only reason LNKGET is required
> for atomic_read() is that on certain cores the LNKGET/LNKSET
> instructions went around the cache, but those cores also have write
> through caches, so it shouldn't result in incoherence.
>
> I've just double checked, and the pipeline seems to handle the linked
> read after write correctly, so e.g. after:
>
> 0220002c MOV D0FrT,#0x5
> b6208042 SETD [D1Ar3],D0FrT
> ad1080cc LNKGETD D0Ar4,[D1Ar3]
>
> D0Ar4 is correct (0x5).
Thanks! XXX removed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/