Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030528AbbD1Ocv (ORCPT ); Tue, 28 Apr 2015 10:32:51 -0400 Received: from casper.infradead.org ([85.118.1.10]:52963 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965902AbbD1Ocs (ORCPT ); Tue, 28 Apr 2015 10:32:48 -0400 Date: Tue, 28 Apr 2015 16:32:35 +0200 From: Peter Zijlstra To: "Paul E. McKenney" 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: <20150428143235.GE23123@twins.programming.kicks-ass.net> References: <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> <20150220184551.GQ2896@worktop.programming.kicks-ass.net> <20150425195602.GA26676@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150425195602.GA26676@linux.vnet.ibm.com> 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 Content-Length: 2932 Lines: 71 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 ? > 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) > 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/