From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E6AC34047 for ; Wed, 19 Feb 2020 15:49:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA5582465D for ; Wed, 19 Feb 2020 15:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726750AbgBSPtH (ORCPT ); Wed, 19 Feb 2020 10:49:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:45824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgBSPtG (ORCPT ); Wed, 19 Feb 2020 10:49:06 -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 07A4C24654; Wed, 19 Feb 2020 15:49:04 +0000 (UTC) Date: Wed, 19 Feb 2020 10:49:03 -0500 From: Steven Rostedt To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mingo@kernel.org, joel@joelfernandes.org, gregkh@linuxfoundation.org, gustavo@embeddedor.com, tglx@linutronix.de, paulmck@kernel.org, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, luto@kernel.org, tony.luck@intel.com, frederic@kernel.org, dan.carpenter@oracle.com, mhiramat@kernel.org Subject: Re: [PATCH v3 08/22] rcu,tracing: Create trace_rcu_{enter,exit}() Message-ID: <20200219104903.46686b81@gandalf.local.home> In-Reply-To: <20200219150744.832297480@infradead.org> References: <20200219144724.800607165@infradead.org> <20200219150744.832297480@infradead.org> 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 On Wed, 19 Feb 2020 15:47:32 +0100 Peter Zijlstra wrote: > To facilitate tracers that need RCU, add some helpers to wrap the > magic required. > > The problem is that we can call into tracers (trace events and > function tracing) while RCU isn't watching and this can happen from > any context, including NMI. > > It is this latter that is causing most of the trouble; we must make > sure in_nmi() returns true before we land in anything tracing, > otherwise we cannot recover. > > These helpers are macros because of header-hell; they're placed here > because of the proximity to nmi_{enter,exit{(). > > Signed-off-by: Peter Zijlstra (Intel) > --- > include/linux/hardirq.h | 32 ++++++++++++++++++++++++++++++++ > +/* > + * Tracing vs RCU > + * -------------- > + * > + * tracepoints and function-tracing can happen when RCU isn't watching (idle, > + * or early IRQ/NMI entry). > + * > + * When it happens during idle or early during IRQ entry, tracing will have > + * to inform RCU that it ought to pay attention, this is done by calling > + * rcu_irq_enter_irqsave(). > + * > + * On NMI entry, we must be very careful that tracing only happens after we've > + * incremented preempt_count(), otherwise we cannot tell we're in NMI and take > + * the special path. > + */ > + > +#define trace_rcu_enter() \ > +({ \ > + unsigned long state = 0; \ > + if (!rcu_is_watching()) { \ > + rcu_irq_enter_irqsave(); \ > + state = 1; \ > + } \ > + state; \ > +}) > + > +#define trace_rcu_exit(state) \ > +do { \ > + if (state) \ > + rcu_irq_exit_irqsave(); \ > +} while (0) > + Is there a reason that these can't be static __always_inline functions? -- Steve > #endif /* LINUX_HARDIRQ_H */ >