Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754866AbbFPRjy (ORCPT ); Tue, 16 Jun 2015 13:39:54 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:41040 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752916AbbFPRjr (ORCPT ); Tue, 16 Jun 2015 13:39:47 -0400 X-Helo: d03dlp02.boulder.ibm.com X-MailFrom: paulmck@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 16 Jun 2015 10:39:42 -0700 From: "Paul E. McKenney" To: Alexei Starovoitov Cc: Steven Rostedt , Daniel Wagner , LKML Subject: Re: call_rcu from trace_preempt Message-ID: <20150616173942.GP3913@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <557F509D.2000509@plumgrid.com> <20150615230702.GB3913@linux.vnet.ibm.com> <557F7764.5060707@plumgrid.com> <20150616021458.GE3913@linux.vnet.ibm.com> <557FB7E1.6080004@plumgrid.com> <20150616122733.GG3913@linux.vnet.ibm.com> <20150616113738.3ab2667b@gandalf.local.home> <20150616160546.GL3913@linux.vnet.ibm.com> <55805960.2030008@plumgrid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55805960.2030008@plumgrid.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15061617-0025-0000-0000-00000BA30699 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3743 Lines: 104 On Tue, Jun 16, 2015 at 10:14:08AM -0700, Alexei Starovoitov wrote: > On 6/16/15 9:05 AM, Paul E. McKenney wrote: > >On Tue, Jun 16, 2015 at 11:37:38AM -0400, Steven Rostedt wrote: > >>On Tue, 16 Jun 2015 05:27:33 -0700 > >>"Paul E. McKenney" wrote: > >> > >>>On Mon, Jun 15, 2015 at 10:45:05PM -0700, Alexei Starovoitov wrote: > >>>>On 6/15/15 7:14 PM, Paul E. McKenney wrote: > >>>>> > >>>>>Why do you believe that it is better to fix it within call_rcu()? > >>>> > >>>>found it: > >>>>diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > >>>>index 8cf7304b2867..a3be09d482ae 100644 > >>>>--- a/kernel/rcu/tree.c > >>>>+++ b/kernel/rcu/tree.c > >>>>@@ -935,9 +935,9 @@ bool notrace rcu_is_watching(void) > >>>> { > >>>> bool ret; > >>>> > >>>>- preempt_disable(); > >>>>+ preempt_disable_notrace(); > >>>> ret = __rcu_is_watching(); > >>>>- preempt_enable(); > >>>>+ preempt_enable_notrace(); > >>>> return ret; > >>>> } > >>>> > >>>>the rcu_is_watching() and __rcu_is_watching() are already marked > >>>>notrace, so imo it's a good 'fix'. > >>>>What was happening is that the above preempt_enable was triggering > >>>>recursive call_rcu that was indeed messing 'rdp' that was > >>>>prepared by __call_rcu and before __call_rcu_core could use that. > >>> > >>>>btw, also noticed that local_irq_save done by note_gp_changes > >>>>is partially redundant. In __call_rcu_core path the irqs are > >>>>already disabled. > >>> > >> > >>If rcu_is_watching() and __rcu_is_watching() are both marked as > >>notrace, it makes sense to use preempt_disable/enable_notrace() as it > >>otherwise defeats the purpose of the notrace markers on rcu_is_watching. And __rcu_is_watching() is marked notrace as well. > >>That is regardless of what the rest of this thread is about. > > > >Good enough! Alexei, are you OK with my adding your Signed-off-by > >to the above patch? > > sure. > Signed-off-by: Alexei Starovoitov > > >(Still not sold on reentrant call_rcu() and > >kfree_rcu(), but getting notrace set up correctly is worthwhile.) > > I'm not sold on it either. So far trying to understand > all consequences. Here is the updated patch. Steven, I added your "Acked-by" based on your positive comments above, please let me know if you would like me to remove it. Thanx, Paul ------------------------------------------------------------------------ commit 9611f225d383a2edbdf74ca7f00c8d0b1e56dc45 Author: Alexei Starovoitov Date: Tue Jun 16 10:35:18 2015 -0700 rcu: Make rcu_is_watching() really notrace Although rcu_is_watching() is marked notrace, it invokes preempt_disable() and preempt_enable(), both of which can be traced. This defeats the purpose of the notrace on rcu_is_watching(), so this commit substitutes preempt_disable_notrace() and preempt_enable_notrace(). Signed-off-by: Alexei Starovoitov Signed-off-by: Paul E. McKenney Acked-by: Steven Rostedt diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index fc0385380e97..c844ef3c2fae 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -973,9 +973,9 @@ bool notrace rcu_is_watching(void) { bool ret; - preempt_disable(); + preempt_disable_notrace(); ret = __rcu_is_watching(); - preempt_enable(); + preempt_enable_notrace(); return ret; } EXPORT_SYMBOL_GPL(rcu_is_watching); -- 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/