Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7202089ybf; Fri, 6 Mar 2020 12:23:25 -0800 (PST) X-Google-Smtp-Source: ADFU+vvcwKkYed5vJ+UaHWhT4h1sYRdKKPcOUXSv96f7BWwQvnydd/hLmH4al7pYjJhCqOsShuio X-Received: by 2002:a9d:64ca:: with SMTP id n10mr4043071otl.325.1583526205572; Fri, 06 Mar 2020 12:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583526205; cv=none; d=google.com; s=arc-20160816; b=nLLFD0A+OSWDl8x8bVeiVTPw3+kHVMJmObuqOUvqf5ind+mVu6pi3UsYn/1gorGGlk tsVw5wynAF00wiEJogbNozw+lclrK7J3Y5fHc8EKTxWD0vRmbtt0bPyo6KxRNNm2yUDT LTQB1Aamhs7NYUaW7rydlXj3jMtUiWFnN4o8sjxJPwriIKDPsCIdYxCwl3DFyFH5L42A /Q+y+hxYWQZ5QrNJVk+YbAJdTi7Olk9NcLiTXNj151Vr51MQD4fHjk2gS8HOWenVAGBz N99pCO+tt4awmSnihNCKOV2hMNs1yPREViNnvImkMvpihsOiS8RnDnUsXOlqWJUqGc20 cdPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=r+lBEt5STJwJzj6tJ/OfbFfU87Bc66ZCYDieRzIweKg=; b=ST6fIfm8b8g0uFYxG8ehbfZRAKJdE9X0VpNPPCbzX5yeKKZeBiZTdqSMmOneDOIGoX sPz4PBieyFh3JLK3d8kegwHC3Y+NqQEdJB2hIgkE1CZbrWNKh7lL3tcpdeWLBV6VxE0F 8izuJHTUOrfevNxxaOl0naUIBgIFXU2NmE1O9MnnGrwdrRyQ21G9xIFMGJ36TLAWO7us bQdOd4KHSB9NTxPMCIV9kkKP8aoC2KZHjHUwskDPFBnTJvk21xc4kZCZbTQi8fr9bMw5 JMuxTus5mxpU0Qlo2rsgGI9tKVFg5ZauUD33JuKfBhcymJ2s4/t0h4LCCF7rrZAXiQCu Mqng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=DCVLzUiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si1987298oti.51.2020.03.06.12.23.12; Fri, 06 Mar 2020 12:23:25 -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; dkim=pass header.i=@efficios.com header.s=default header.b=DCVLzUiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgCFUWt (ORCPT + 99 others); Fri, 6 Mar 2020 15:22:49 -0500 Received: from mail.efficios.com ([167.114.26.124]:54530 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbgCFUWs (ORCPT ); Fri, 6 Mar 2020 15:22:48 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id EEBC2268B52; Fri, 6 Mar 2020 15:22:46 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id zO7JmsQsDJM9; Fri, 6 Mar 2020 15:22:46 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 8631E26896D; Fri, 6 Mar 2020 15:22:46 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 8631E26896D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1583526166; bh=r+lBEt5STJwJzj6tJ/OfbFfU87Bc66ZCYDieRzIweKg=; h=Date:From:To:Message-ID:MIME-Version; b=DCVLzUiHd8NlIOA4CUd57TuDsLhDDgLtXTFJXHdSdCygDqcQ+WuE8nK1gYY+2vncX N/BbNEOxPr5ZgdbBJba0dycsEF9GP1SNPsZ+Fh5vTzZX6mMJ8Y3iF9gar2uoXIoudo 6eu4HcZktQW6zdZkZ3f7OrbDB4fKtX+frK6ywAgw15+6jNORgq4qzyE9vIm5HFpCqr 2An98eKkku/w/QfF75feCpxFVJYm2F6etUjmt8wrq6dwvH9N3l/4L35kgb8I60Zo9V +o0KhQQ1RLwpQm3Kn3LQOo/lmXfmUvhjMZKsqN+6LoRy37HNI4M7y3ycJylpECQgrG Q7m5ZiqWuS+YA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QxsuSvlpbagB; Fri, 6 Mar 2020 15:22:46 -0500 (EST) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 719D5268AD8; Fri, 6 Mar 2020 15:22:46 -0500 (EST) Date: Fri, 6 Mar 2020 15:22:46 -0500 (EST) From: Mathieu Desnoyers To: rostedt Cc: Alexei Starovoitov , Peter Zijlstra , linux-kernel , linux-arch , Ingo Molnar , "Joel Fernandes, Google" , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Thomas Gleixner , paulmck , Josh Triplett , Lai Jiangshan , Andy Lutomirski , Tony Luck , Frederic Weisbecker , dan carpenter , Masami Hiramatsu Message-ID: <609624365.20355.1583526166349.JavaMail.zimbra@efficios.com> In-Reply-To: <20200306125500.6aa75c0d@gandalf.local.home> 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> Subject: Re: [PATCH v4 16/27] tracing: Remove regular RCU context for _rcuidle tracepoints (again) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3901 (ZimbraWebClient - FF73 (Linux)/8.8.15_GA_3895) Thread-Topic: tracing: Remove regular RCU context for _rcuidle tracepoints (again) Thread-Index: bZNNWmRnIZd0OYh0THVv3pcm6i1KDw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Mar 6, 2020, at 12:55 PM, rostedt rostedt@goodmis.org 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. > > -- Steve > [...] > diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c > index 73956eaff8a9..1797e20fd471 100644 > --- a/kernel/tracepoint.c > +++ b/kernel/tracepoint.c > @@ -295,6 +295,7 @@ static int tracepoint_remove_func(struct tracepoint *tp, > * @probe: probe handler > * @data: tracepoint data > * @prio: priority of this function over other registered functions > + * @rcu: set to non zero if the callback requires RCU protection > * > * Returns 0 if ok, error value on error. > * Note: if @tp is within a module, the caller is responsible for > @@ -302,8 +303,8 @@ static int tracepoint_remove_func(struct tracepoint *tp, > * performed either with a tracepoint module going notifier, or from > * within module exit functions. > */ > -int tracepoint_probe_register_prio(struct tracepoint *tp, void *probe, > - void *data, int prio) > +int tracepoint_probe_register_prio_rcu(struct tracepoint *tp, void *probe, > + void *data, int prio, int rcu) I agree with the overall approach. Just a bit of nitpicking on the API: I understand that the "prio" argument is a separate argument because it can take many values. However, "rcu" is just a boolean, so I wonder if we should not rather introduce a "int flags" with a bitmask enum, e.g. int tracepoint_probe_register_prio_flags(struct tracepoint *tp, void *probe, void *data, int prio, int flags) where flags would be populated through OR between labels of this enum: enum tracepoint_flags { TRACEPOINT_FLAG_RCU = (1U << 0), }; We can then be future-proof for additional flags without ending up calling e.g. tracepoint_probe_register_featurea_featureb_featurec(tp, probe, data, 0, 1, 0, 1) which seems rather error-prone and less readable than a set of flags. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com