Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751247AbbD3Hnm (ORCPT ); Thu, 30 Apr 2015 03:43:42 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:57961 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750887AbbD3Hni (ORCPT ); Thu, 30 Apr 2015 03:43:38 -0400 Date: Tue, 28 Apr 2015 13:33:23 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Manfred Spraul , Oleg Nesterov , 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: <20150428203323.GF5553@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <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> <20150220184551.GQ2896@worktop.programming.kicks-ass.net> <20150425195602.GA26676@linux.vnet.ibm.com> <20150428143235.GE23123@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150428143235.GE23123@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15043007-0017-0000-0000-00000A6B2CA5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3189 Lines: 80 On Tue, Apr 28, 2015 at 04:32:35PM +0200, Peter Zijlstra wrote: > On Sat, Apr 25, 2015 at 12:56:03PM -0700, Paul E. McKenney wrote: > > smp: Make control dependencies work on Alpha, improve documentation > > > > The current formulation of control dependencies fails on DEC Alpha, which > > does not respect dependencies of any kind unless an explicit memory is > > + barrier ? Good catch, fixed! > > provided. This means that the current fomulation of control dependencies > > fails on Alpha. This commit therefore creates a READ_ONCE_CTRL() that > > has the same overhead on non-Alpha systems, but causes Alpha to produce > > the needed ordering. This commit also applies READ_ONCE_CTRL() to the > > one known use of control dependencies. > > > > Use of READ_ONCE_CTRL() also has the beneficial effect of adding a bit > > of self-documentation to control dependencies. > > > > Signed-off-by: Paul E. McKenney > > Acked-by: Peter Zijlstra (Intel) Applied, thank you! Thanx, Paul > > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > > index 1b45e4a0519b..a57eacde2b84 100644 > > --- a/include/linux/compiler.h > > +++ b/include/linux/compiler.h > > @@ -264,6 +264,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s > > #define WRITE_ONCE(x, val) \ > > ({ typeof(x) __val = (val); __write_once_size(&(x), &__val, sizeof(__val)); __val; }) > > > > +/** > > + * READ_ONCE_CTRL - Read a value heading a control dependency > > + * @x: The value to be read, heading the control dependency > > + * > > + * Control dependencies are tricky. See Documentation/memory-barriers.txt > > + * for important information on how to use them. Note that in many cases, > > + * use of smp_load_acquire() will be much simpler. Control dependencies > > + * should be avoided except on the hottest of hotpaths. > > + */ > > +#define READ_ONCE_CTRL(x) \ > > +({ \ > > + typeof(x) __val = READ_ONCE(x); \ > > + smp_read_barrier_depends(); /* Enforce control dependency. */ \ > > + __val; \ > > +}) > > + > > #endif /* __KERNEL__ */ > > > > #endif /* __ASSEMBLY__ */ > > We mostly try and align the \ for multi-line macros. > > > diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c > > index eadb95ce7aac..67548d5de4cb 100644 > > --- a/kernel/events/ring_buffer.c > > +++ b/kernel/events/ring_buffer.c > > @@ -141,7 +141,7 @@ int perf_output_begin(struct perf_output_handle *handle, > > perf_output_get_handle(handle); > > > > do { > > - tail = ACCESS_ONCE(rb->user_page->data_tail); > > + tail = READ_ONCE_CTRL(rb->user_page->data_tail); > > offset = head = local_read(&rb->head); > > if (!rb->overwrite && > > unlikely(CIRC_SPACE(head, tail, perf_data_size(rb)) < size)) > > Right. I could not remember any other current usage. > -- 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/