From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753336AbbJFUFy (ORCPT ); Tue, 6 Oct 2015 16:05:54 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:56962 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753077AbbJFUFx (ORCPT ); Tue, 6 Oct 2015 16:05:53 -0400 Date: Tue, 6 Oct 2015 22:05:38 +0200 From: Peter Zijlstra To: "Paul E. McKenney" 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: <20151006200538.GU3604@twins.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151006174204.GL3910@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 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. > 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.