Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7131437ybf; Fri, 6 Mar 2020 11:00:14 -0800 (PST) X-Google-Smtp-Source: ADFU+vu0bxGxMbfRrV8QUTPjBhv5qbQd1JKCp/Jeno+DD3oGSAGRujzOnCenKkx3syDPvWwvEjs/ X-Received: by 2002:aca:4983:: with SMTP id w125mr2057048oia.52.1583521214867; Fri, 06 Mar 2020 11:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583521214; cv=none; d=google.com; s=arc-20160816; b=OZGttXONtLmi/HJ6E3RqvKQfEZm/YiFHT36E6zTQMMVjYNyKA8HEK4SOtKVHGzMQEn LU8LiCbw/5I+IoB0KJq88RlTJfZ5m2TGQZjA1GdnPz2pm/s2OSvrM+R9tETIfREnVuCl gB98+H1V6oRJoNE2qrpXH3ObMGRApQOZV3mOtXVCETdLO6ApejrE2rSgKRhBNTsEV5cu Ac2Bl4DZGF2JwiGEomsxD22BAxxgMyQHmxntuWLuu9JgN7wIh2PjUU06HuJ3owlg5mbd ond8K0kp2uOAIoTRzmk23yaJ2Vsc8zH4+T8KIBl2D4fZkxfW2xGzoRP+y6+UsEkNUV6e xCCA== 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=Kxxc9gqTVZHuuC8miUsfNH+AEQi1t9/GFCY/RepYmbE=; b=YgiDFaJZlhPwu6FmhhDka750zy4poSVRq6lmYjBTGPfephGjIk48yd1FcKA98R5gJO ilquakkhzypgP3wEn8q1GjQNzYckcPko/qSuMNhnbqYGES1fZO+4x9Gj2dWXfw623ECg OOV3oqwCHyUZpFaTRacynf6d1xNxoJyQgX9lph8FioEnNKtSwQ74CY9dGdK/JnmQmruK bg6wXHdmWs+hZVvrwa9flZWcNntfRLYB59jryCLiNoVSXJYfyAelW7jofsFaR11De5jj LDc8Cz96ehG6pp2me5dMsvq/eBFCAQve+QawXg7kheM/1VMeqiTpwf0X3EaOIqHVtUI+ b7BA== 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 c129si146296oib.48.2020.03.06.11.00.02; Fri, 06 Mar 2020 11:00:14 -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 S1726237AbgCFS73 (ORCPT + 99 others); Fri, 6 Mar 2020 13:59:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:34804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbgCFS73 (ORCPT ); Fri, 6 Mar 2020 13:59:29 -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 BD94520637; Fri, 6 Mar 2020 18:59:26 +0000 (UTC) Date: Fri, 6 Mar 2020 13:59:25 -0500 From: Steven Rostedt To: Joel Fernandes Cc: Mathieu Desnoyers , Alexei Starovoitov , Peter Zijlstra , linux-kernel , linux-arch , Ingo Molnar , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Thomas Gleixner , paulmck , Josh Triplett , Lai Jiangshan , Andy Lutomirski , Tony Luck , Frederic Weisbecker , dan carpenter , Masami Hiramatsu Subject: Re: [PATCH v4 16/27] tracing: Remove regular RCU context for _rcuidle tracepoints (again) Message-ID: <20200306135925.50c38bec@gandalf.local.home> In-Reply-To: <20200306184538.GA92717@google.com> References: <20200221133416.777099322@infradead.org> <20200221134216.051596115@infradead.org> <20200306104335.GF3348@worktop.programming.kicks-ass.net> <20200306113135.GA8787@worktop.programming.kicks-ass.net> <1896740806.20220.1583510668164.JavaMail.zimbra@efficios.com> <20200306125500.6aa75c0d@gandalf.local.home> <20200306184538.GA92717@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 On Fri, 6 Mar 2020 13:45:38 -0500 Joel Fernandes wrote: > On Fri, Mar 06, 2020 at 12:55:00PM -0500, Steven Rostedt wrote: > > On Fri, 6 Mar 2020 11:04:28 -0500 (EST) > > Mathieu Desnoyers wrote: > > > > > If we care about not adding those extra branches on the fast-path, there is > > > an alternative way to do things: BPF could provide two distinct probe callbacks, > > > one meant for rcuidle tracepoints (which would have the trace_rcu_enter/exit), and > > > the other for the for 99% of the other callsites which have RCU watching. > > > > > > I would recommend performing benchmarks justifying the choice of one approach over > > > the other though. > > > > I just whipped this up (haven't even tried to compile it), but this should > > satisfy everyone. Those that register a callback that needs RCU protection > > simply registers with one of the _rcu versions, and all will be done. And > > since DO_TRACE is a macro, and rcuidle is a constant, the rcu protection > > code will be compiled out for locations that it is not needed. > > > > With this, perf doesn't even need to do anything extra but register with > > the "_rcu" version. > > Looks nice! Some comments below: > > > -- Steve > > > > diff --git a/include/linux/tracepoint-defs.h b/include/linux/tracepoint-defs.h > > index b29950a19205..582dece30170 100644 > > --- a/include/linux/tracepoint-defs.h > > +++ b/include/linux/tracepoint-defs.h > > @@ -25,6 +25,7 @@ struct tracepoint_func { > > void *func; > > void *data; > > int prio; > > + int requires_rcu; > > }; > > > > struct tracepoint { > > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h > > index 1fb11daa5c53..5f4de82ffa0f 100644 > > --- a/include/linux/tracepoint.h > > +++ b/include/linux/tracepoint.h > > @@ -179,25 +179,28 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > * For rcuidle callers, use srcu since sched-rcu \ > > * doesn't work from the idle path. \ > > */ \ > > - if (rcuidle) { \ > > + if (rcuidle) \ > > __idx = srcu_read_lock_notrace(&tracepoint_srcu);\ > > Small addition: > To prevent confusion, we could make more clear that SRCU here is just to > protect the tracepoint function table and not the callbacks themselves. > > > - rcu_irq_enter_irqson(); \ > > - } \ > > \ > > it_func_ptr = rcu_dereference_raw((tp)->funcs); \ > > \ > > if (it_func_ptr) { \ > > do { \ > > + int rcu_flags; \ > > it_func = (it_func_ptr)->func; \ > > + if (rcuidle && \ > > + (it_func_ptr)->requires_rcu) \ > > + rcu_flags = trace_rcu_enter(); \ > > __data = (it_func_ptr)->data; \ > > ((void(*)(proto))(it_func))(args); \ > > + if (rcuidle && \ > > + (it_func_ptr)->requires_rcu) \ > > + trace_rcu_exit(rcu_flags); \ > > Nit: If we have incurred the cost of trace_rcu_enter() once, we can call > it only once and then call trace_rcu_exit() after the do-while loop. That way > we pay the price only once. > I thought about that, but the common case is only one callback attached at a time. To make the code complex for the non common case seemed too much of an overkill. If we find that it does help, it's best to do that as a separate patch because then if something goes wrong we know where it happened. Currently, this provides the same overhead as if each callback did it themselves like we were proposing (but without the added need to do it for all instances of the callback). -- Steve