From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755437Ab3LJRfu (ORCPT ); Tue, 10 Dec 2013 12:35:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14565 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751830Ab3LJRft (ORCPT ); Tue, 10 Dec 2013 12:35:49 -0500 Date: Tue, 10 Dec 2013 18:35:24 +0100 From: Oleg Nesterov To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com, sbw@mit.edu, Ingo Molnar , Linus Torvalds , Will Deacon , Tim Chen , Waiman Long , Andrea Arcangeli , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Rik van Riel , Peter Hurley , "H. Peter Anvin" , Arnd Bergmann , Benjamin Herrenschmidt Subject: Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK Message-ID: <20131210173524.GB25934@redhat.com> References: <20131210012738.GA24317@linux.vnet.ibm.com> <1386638883-25379-1-git-send-email-paulmck@linux.vnet.ibm.com> <1386638883-25379-5-git-send-email-paulmck@linux.vnet.ibm.com> <20131210164436.GA23506@redhat.com> <20131210171522.GR4208@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131210171522.GR4208@linux.vnet.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/10, Paul E. McKenney wrote: > > On Tue, Dec 10, 2013 at 05:44:37PM +0100, Oleg Nesterov wrote: > > > > Well, but smp_mb__before_spinlock + LOCK is not wmb... But it is not > > the full barrier. It should guarantee that, say, > > > > CONDITION = true; // 1 > > > > // try_to_wake_up > > smp_mb__before_spinlock(); > > spin_lock(&task->pi_lock); > > > > if (!(p->state & state)) // 2 > > return; > > > > can't race with with set_current_state() + check(CONDITION), this means > > that 1 and 2 above must not be reordered. > > > > But a LOAD before before spin_lock() can leak into the critical section. > > > > Perhaps this should be clarified somehow, or perhaps it should actually > > imply mb (if combined with LOCK). > > If we leave the implementation the same, does the following capture the > constraints? > > Memory operations issued before the LOCK may be completed after > the LOCK operation has completed. An smp_mb__before_spinlock(), > combined with a following LOCK, orders prior loads against > subsequent stores prior stores against subsequent loads ;) Otherwise - thanks! Oleg.