Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755414AbbBUD02 (ORCPT ); Fri, 20 Feb 2015 22:26:28 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:35699 "EHLO e32.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755181AbbBUD00 (ORCPT ); Fri, 20 Feb 2015 22:26:26 -0500 Date: Fri, 20 Feb 2015 19:26:21 -0800 From: "Paul E. McKenney" To: Manfred Spraul Cc: Oleg Nesterov , Peter Zijlstra , Kirill Tkhai , linux-kernel@vger.kernel.org, Ingo Molnar , Josh Poimboeuf Subject: Re: [PATCH 2/2] [PATCH] sched: Add smp_rmb() in task rq locking cycles Message-ID: <20150221032621.GQ5745@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150217121258.GM5029@twins.programming.kicks-ass.net> <20150217130523.GV24151@twins.programming.kicks-ass.net> <20150217160532.GW4166@linux.vnet.ibm.com> <20150217183636.GR5029@twins.programming.kicks-ass.net> <20150217215231.GK4166@linux.vnet.ibm.com> <20150218155904.GA27687@redhat.com> <54E4E479.4050003@colorfullife.com> <20150218224317.GC5029@twins.programming.kicks-ass.net> <20150219141905.GA11018@redhat.com> <54E77CC0.5030401@colorfullife.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54E77CC0.5030401@colorfullife.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15022103-0005-0000-0000-000008F8CBB4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1641 Lines: 59 On Fri, Feb 20, 2015 at 07:28:16PM +0100, Manfred Spraul wrote: > Hi Oleg, > > my example was bad, let's continue with your example. > > And: If sem_lock() needs another smp_xmb(), then we must add it: > Some apps do not have a user space hot path, i.e. it seems that on > some setups, we have millions of calls per second. > If there is a race, then it will happen. > > I've tried to merge your example: > > > > int X = 0, Y = 0; > > > > void func(void) > > { > > bool ll = rand(); > > > > if (ll) { > > spin_lock(&local); > > if (!spin_is_locked(&global)) > > goto done; > > spin_unlock(&local); > > } > > ll = false; > > spin_lock(&global); > > spin_unlock_wait(&local); > > done: > > smp_rmb(); <<<<<<<<<<<<<<< > > BUG_ON(X != Y); > > > > ++X; ++Y; > > > > if (ll) > > spin_unlock(&local); > > else > > spin_unlock(&global); > > } > I agree, we need the smp_rmb(). > I'll write a patch. > > >We need the full barrier to serialize STORE's as well, but probably we can > >rely on control dependancy and thus we only need rmb(). > Do we need a full barrier or not? > > I don't manage to create a proper line of reasoning. This has to be one of the more bizarre forms of Dekker's algorithm that I have seen. ;-) I am going to have to put this through one of the tools... Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/