Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1004059ybv; Thu, 13 Feb 2020 13:48:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwUPfCd7a9VtxOM6BY9iAFj4PIYkxfvTOpwWh3yZC61fNNp3P1z5UzR3K7z22VpGCxIfIms X-Received: by 2002:a05:6830:140b:: with SMTP id v11mr15002157otp.340.1581630531313; Thu, 13 Feb 2020 13:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581630531; cv=none; d=google.com; s=arc-20160816; b=KJcOk41S+0jKiEfCh/t9OFAPPgGF6+YBG5W4SEtNUuvFEqQDLB/mo9D6TJSb02upqb l9QNOs+uYuF5F4dBl8Uh7TBLrrb5ppvejKCvoeSfDFYdO+fIzK20C0JekqYJwjGY7WRV Rwwf2uxrUUBlr7SFOrm1CaLQl4W2XFxSNxesNFbDZ7HJDk1GN1+SjZ7X5xvKewc6wy1J WFb9b7pY7HmpM9ezErLIXilOblzjE6rTo+uN4YwtkEN2rldGAeZpzqRPoYNaeHjLQOl1 0ykqCGxEQdWorFDtoBafkVZen/b/4qijnJTGgQZZepzvoASMULQwGnvwCxiiKS4cPUeU vl8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=MhtGCdXyVn6rlZCgmK9tQ+8fE6rC9hocu+5oouiAKAk=; b=ymyskeOJE86M3t1TycWxrF8ybvJwz+Mm6QazKZhO3ZqBjGUwMRXN2tFcrrn6LgY3p6 2+iYffbvVJTxsKFQ9vKDv9zQ5WtIqzoGbRj9rQ/36/SwgcrglJsztwkRhYlio1dzLmx7 vQ654lUJV9l0l3h0nAmKF99JDHQKYjpblh19N5JBcedi89EgdIs3BOHFw8Ruj2Tf4dug t9FSIBtnm2AdqZPeBMvP1jL77LzRD4DDHrxnOwegiVlLOR6tIQ94PA66qv/5yNVcHdgm Kn7IxA5LsrwHiQoIklRWLr4cKwUPHNLMePAaVfGgWoqYC6yevwPs2I9myZKkNgfBdgRr YMpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z199si1655929oia.192.2020.02.13.13.48.38; Thu, 13 Feb 2020 13:48:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728699AbgBMVi3 (ORCPT + 99 others); Thu, 13 Feb 2020 16:38:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:45060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728690AbgBMVi2 (ORCPT ); Thu, 13 Feb 2020 16:38:28 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BD062168B; Thu, 13 Feb 2020 21:38:26 +0000 (UTC) Date: Thu, 13 Feb 2020 16:38:25 -0500 From: Steven Rostedt To: Joel Fernandes Cc: "Paul E. McKenney" , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mingo@kernel.org, gregkh@linuxfoundation.org, gustavo@embeddedor.com, tglx@linutronix.de, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, Masami Hiramatsu Subject: Re: [PATCH v2 3/9] rcu,tracing: Create trace_rcu_{enter,exit}() Message-ID: <20200213163800.5c51a5f1@gandalf.local.home> In-Reply-To: <20200213211930.GG170680@google.com> References: <20200212210139.382424693@infradead.org> <20200212210749.971717428@infradead.org> <20200212232005.GC115917@google.com> <20200213082716.GI14897@hirez.programming.kicks-ass.net> <20200213135138.GB2935@paulmck-ThinkPad-P72> <20200213164031.GH14914@hirez.programming.kicks-ass.net> <20200213185612.GG2935@paulmck-ThinkPad-P72> <20200213204444.GA94647@google.com> <20200213205442.GK2935@paulmck-ThinkPad-P72> <20200213211930.GG170680@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Added Masami ] On Thu, 13 Feb 2020 16:19:30 -0500 Joel Fernandes wrote: > On Thu, Feb 13, 2020 at 12:54:42PM -0800, Paul E. McKenney wrote: > > On Thu, Feb 13, 2020 at 03:44:44PM -0500, Joel Fernandes wrote: > > > On Thu, Feb 13, 2020 at 10:56:12AM -0800, Paul E. McKenney wrote: > > > [...] > > > > > > It might well be that I could make these functions be NMI-safe, but > > > > > > rcu_prepare_for_idle() in particular would be a bit ugly at best. > > > > > > So, before looking into that, I have a question. Given these proposed > > > > > > changes, will rcu_nmi_exit_common() and rcu_nmi_enter_common() be able > > > > > > to just use in_nmi()? > > > > > > > > > > That _should_ already be the case today. That is, if we end up in a > > > > > tracer and in_nmi() is unreliable we're already screwed anyway. > > > > > > > > So something like this, then? This is untested, probably doesn't even > > > > build, and could use some careful review from both Peter and Steve, > > > > at least. As in the below is the second version of the patch, the first > > > > having been missing a couple of important "!" characters. > > > > > > I removed the static from rcu_nmi_enter()/exit() as it is called from > > > outside, that makes it build now. Updated below is Paul's diff. I also added > > > NOKPROBE_SYMBOL() to rcu_nmi_exit() to match rcu_nmi_enter() since it seemed > > > asymmetric. > > > > My compiler complained about the static and the __always_inline, so I > > fixed those. But please help me out on adding the NOKPROBE_SYMBOL() > > to rcu_nmi_exit(). What bad thing happens if we leave this on only > > rcu_nmi_enter()? > > It seemed odd to me we were not allowing kprobe on the rcu_nmi_enter() but > allowing it on exit (from a code reading standpoint) so my reaction was to > add it to both, but we could probably keep that as a separate > patch/discussion since it is slightly unrelated to the patch.. Sorry to > confuse the topic. > rcu_nmi_enter() was marked NOKPROBE or other reasons. See commit c13324a505c77 ("x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()") The issue was that we must not allow anything in do_int3() call kprobe code before kprobe_int3_handler() is called. Because ist_enter() (in do_int3()) calls rcu_nmi_enter() it had to be marked NOKPROBE. It had nothing to do with it being RCU nor NMI, but because it was simply called in do_int3(). Thus, there's no reason to make rcu_nmi_exit() NOKPROBE. But a commont to why rcu_nmi_enter() would probably be useful, like below: -- Steve diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 1694a6b57ad8..e2c9e3e2f480 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -846,6 +846,12 @@ void rcu_nmi_enter(void) { rcu_nmi_enter_common(false); } +/* + * On x86, All functions in do_int3() must be marked NOKPROBE before + * kprobe_int3_handler() is called. ist_enter() which is called in do_int3() + * before kprobe_int3_handle() happens to call rcu_nmi_enter() in which case + * rcu_nmi_enter() must be marked NOKRPOBE. + */ NOKPROBE_SYMBOL(rcu_nmi_enter); /**