From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753762AbbIRMkI (ORCPT ); Fri, 18 Sep 2015 08:40:08 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45693 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753487AbbIRMkG (ORCPT ); Fri, 18 Sep 2015 08:40:06 -0400 Date: Fri, 18 Sep 2015 14:34:34 +0200 From: Peter Zijlstra To: James Hogan Cc: Oleg Nesterov , Dmitry Vyukov , ebiederm@xmission.com, Al Viro , Andrew Morton , Ingo Molnar , Paul McKenney , mhocko@suse.cz, LKML , ktsan@googlegroups.com, Kostya Serebryany , Andrey Konovalov , Alexander Potapenko , Hans Boehm Subject: Re: [PATCH] kernel: fix data race in put_pid Message-ID: <20150918123434.GU3816@twins.programming.kicks-ass.net> References: <1442496268-47803-1-git-send-email-dvyukov@google.com> <20150917160837.GA26050@redhat.com> <20150917174456.GA30178@redhat.com> <20150917180919.GA32116@redhat.com> <20150918085156.GS3816@twins.programming.kicks-ass.net> <20150918085732.GC11639@twins.programming.kicks-ass.net> <20150918092732.GD11639@twins.programming.kicks-ass.net> <20150918123127.GC26975@jhogan-linux.le.imgtec.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150918123127.GC26975@jhogan-linux.le.imgtec.org> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > > > > 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.