From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752862AbbJFUSJ (ORCPT ); Tue, 6 Oct 2015 16:18:09 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:38363 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbbJFUSH (ORCPT ); Tue, 6 Oct 2015 16:18:07 -0400 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 6 Oct 2015 13:18:01 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Josh Triplett , linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com, Boqun Feng Subject: Re: [PATCH tip/core/rcu 04/13] rcu: Don't disable preemption for Tiny and Tree RCU readers Message-ID: <20151006201801.GU3910@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20151006161305.GA9799@linux.vnet.ibm.com> <1444148028-11551-1-git-send-email-paulmck@linux.vnet.ibm.com> <1444148028-11551-4-git-send-email-paulmck@linux.vnet.ibm.com> <20151006164445.GA9600@cloud> <20151006170101.GG3910@linux.vnet.ibm.com> <20151006171630.GC9600@cloud> <20151006174204.GL3910@linux.vnet.ibm.com> <20151006200538.GU3604@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151006200538.GU3604@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: 15100620-0013-0000-0000-0000191DBDFA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 06, 2015 at 10:05:38PM +0200, Peter Zijlstra wrote: > On Tue, Oct 06, 2015 at 10:42:04AM -0700, Paul E. McKenney wrote: > > > > > Ah. The reason is that Tiny RCU and Tree RCU (the !PREEMPT ones) act > > by implicitly extending (and, if need be, merging) the RCU read-side > > critical sections to include all the code between successive quiescent > > states, for example, all the code between a pair of calls to schedule(). > > > > Therefore, there need to be barrier() calls in the quiescent-state > > functions. Some could be argued to be implicitly present due to > > translation-unit boundaries, but paranoia and all that. > > > > Would adding that sort of explanation help? > > > +++ b/include/linux/rcutiny.h > > @@ -216,6 +216,7 @@ static inline bool rcu_is_watching(void) > > > > static inline void rcu_all_qs(void) > > { > > + barrier(); /* Avoid RCU read-side critical sections leaking across. */ > > } > > > > #endif /* __LINUX_RCUTINY_H */ > > This is more than sheer paranoia I think, inlined functions are not a > compiler barrier. Yep, agreed. > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index b9d9e0249e2f..93c0f23c3e45 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -337,12 +337,14 @@ static void rcu_momentary_dyntick_idle(void) > > */ > > void rcu_note_context_switch(void) > > { > > + barrier(); /* Avoid RCU read-side critical sections leaking down. */ > > trace_rcu_utilization(TPS("Start context switch")); > > rcu_sched_qs(); > > rcu_preempt_note_context_switch(); > > if (unlikely(raw_cpu_read(rcu_sched_qs_mask))) > > rcu_momentary_dyntick_idle(); > > trace_rcu_utilization(TPS("End context switch")); > > + barrier(); /* Avoid RCU read-side critical sections leaking up. */ > > } > > EXPORT_SYMBOL_GPL(rcu_note_context_switch); > > These OTOH could be fixed with a noinline, such that the compiler may > never inline it, even with whole-program-optimizations, thereby > guaranteeing a function call boundary or compiler barrier. I like the barrier() with the comment. I expect it will be a bit more robust against toolchain changes. Thanx, Paul