Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4039213ybv; Mon, 10 Feb 2020 11:06:49 -0800 (PST) X-Google-Smtp-Source: APXvYqy3cWJn+gtQMSbjkmg+sgVeJ08GgkBIrN5hQtOHkgNelWDE7Fzbo1vSlkPvCEoFoyyG8+4g X-Received: by 2002:aca:3d7:: with SMTP id 206mr362926oid.98.1581361608884; Mon, 10 Feb 2020 11:06:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581361608; cv=none; d=google.com; s=arc-20160816; b=JEcZJS0RZG4LYFGj6GjAfIGGCSf641JhjBTFtOCNEUfT4eXbboG4r620aD2bCbfNkU 2MKBw7Ar9VHp6QciAZ6CxTbX8rTu0iTORG3PQw08hM8HKJ7AOGS10UAiKl4FAUkMnvqu AOoIIzCQlRP0Ns4WBIyl3cYziyaotIrqj5DDtkhWTwZEsyA5uaigb+5dX/caEy96nDj8 n6Byaq0fz8OEknY6dt1txAM53nnmRJxLsaJIiC3bOVPJr+RuYjhC/cMqSAaRviXEdn+I djLLb0ca2+Y47BGtXdcjch6tbspkQKbEacb6q/viQlxGKFoSva8EJ9S7UKZN3V885EkW wB1A== 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=+kipQ5NlQVbRyfLk6PdhFdo0Uekn5i8O7ECNRsEs1ZQ=; b=qhz+Yqe1v6R2seLGnK6krvfJudZAGXpawRYc5cH1wtATFTPsmB/Ii6TQ2wrLioATVq mOiPhIuHdyCsj0ZdE1sBGwRzHzTBYmk+2PPCSMS6Pq3lcIm0M0O2VDMehtYplu3jSgap 4KTBClQ0JO2VI/vATc3qP3oowoOryQ6WlTnhD7mtAZ6zfoWwC68E3M5KJ8h5RkPgvboy n+y67yFOlJzLRQvwTW2CVbLp+syNEbk68Gzt7V4f5wQNK/deZU8CIvEJ/l+9tPDKkDuI kwSPAMIQd1STjTusJMVK5DdY825blCORQbqhl5auKR658WEUssqPYjNph8noNsEcC5NW buwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=MMnC+c7G; 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 m19si608976otq.40.2020.02.10.11.06.36; Mon, 10 Feb 2020 11:06:48 -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=MMnC+c7G; 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 S1727540AbgBJTFV (ORCPT + 99 others); Mon, 10 Feb 2020 14:05:21 -0500 Received: from mail.efficios.com ([167.114.26.124]:60056 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgBJTFU (ORCPT ); Mon, 10 Feb 2020 14:05:20 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 26E66245BDF; Mon, 10 Feb 2020 14:05:19 -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 2cc5F7qO5Tv4; Mon, 10 Feb 2020 14:05:18 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id B5F19245F9A; Mon, 10 Feb 2020 14:05:18 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com B5F19245F9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1581361518; bh=+kipQ5NlQVbRyfLk6PdhFdo0Uekn5i8O7ECNRsEs1ZQ=; h=Date:From:To:Message-ID:MIME-Version; b=MMnC+c7GSHhb4w1fq8fo0FOE4jIwRZwZzmgaU2DzLIMZMwZLXiNCA+oytB+N4DMoB wT9TbPeWNrKbAWFhGQE8+m6wBMzQ2XNthPl4PS6qbrGrbU204Gies//KaURKD75+ib pEs1BxwynJ1NScBWXpOwvcArhcssdil/8JRraEfR9HFk9jXqeXghWI6nsykMkS6LKD I0dS9v1TMUfbw3gG1Xd6kaAjQraJ07gjBmy7XO10IG+WQ6ng0Gj56fSt2Mo2zM+Xab ZLQmicJbyfuVH19qq2w6yPFRuv9OqdtlzyRBRJ30KIVZtO3Yi2kjbDCY4POWKbJkCh kMrAweZWaVeyQ== 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 krdPLfvrB7Cq; Mon, 10 Feb 2020 14:05:18 -0500 (EST) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 9DD80245BD6; Mon, 10 Feb 2020 14:05:18 -0500 (EST) Date: Mon, 10 Feb 2020 14:05:18 -0500 (EST) From: Mathieu Desnoyers To: rostedt Cc: Peter Zijlstra , "Joel Fernandes, Google" , linux-kernel , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Ingo Molnar , Richard Fontana , Thomas Gleixner , paulmck , Josh Triplett , Lai Jiangshan , Arnaldo Carvalho de Melo Message-ID: <1076842217.616862.1581361518556.JavaMail.zimbra@efficios.com> In-Reply-To: <20200210133045.3beb774e@gandalf.local.home> References: <20200207205656.61938-1-joel@joelfernandes.org> <1997032737.615438.1581179485507.JavaMail.zimbra@efficios.com> <20200210094616.GC14879@hirez.programming.kicks-ass.net> <20200210120552.1a06a7aa@gandalf.local.home> <1966694237.616758.1581355984287.JavaMail.zimbra@efficios.com> <20200210133045.3beb774e@gandalf.local.home> Subject: Re: [RFC 0/3] Revert SRCU from tracepoint infrastructure 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_3895 (ZimbraWebClient - FF72 (Linux)/8.8.15_GA_3895) Thread-Topic: Revert SRCU from tracepoint infrastructure Thread-Index: czBPNBUds6fkjawJvJ27CuslWNq0Gg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Feb 10, 2020, at 1:30 PM, rostedt rostedt@goodmis.org wrote: > On Mon, 10 Feb 2020 12:33:04 -0500 (EST) > Mathieu Desnoyers wrote: > >> The rcu_irq_enter/exit_irqson() does atomic_add_return(), which is even worse >> than a memory barrier. > > As we discussed on IRC, would something like this work (not even > compiled tested). Yes, it's very close to what I have prototyped locally. With one very minor detail below: > > -- Steve > > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h > index 1fb11daa5c53..a83fd076a312 100644 > --- a/include/linux/tracepoint.h > +++ b/include/linux/tracepoint.h > @@ -179,10 +179,8 @@ 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);\ > - rcu_irq_enter_irqson(); \ > - } \ > \ > it_func_ptr = rcu_dereference_raw((tp)->funcs); \ > \ > @@ -194,10 +192,8 @@ static inline struct tracepoint > *tracepoint_ptr_deref(tracepoint_ptr_t *p) > } while ((++it_func_ptr)->func); \ > } \ > \ > - if (rcuidle) { \ > - rcu_irq_exit_irqson(); \ > + if (rcuidle) \ > srcu_read_unlock_notrace(&tracepoint_srcu, __idx);\ > - } \ > \ > preempt_enable_notrace(); \ > } while (0) > diff --git a/include/trace/perf.h b/include/trace/perf.h > index dbc6c74defc3..86d3b2eb00cd 100644 > --- a/include/trace/perf.h > +++ b/include/trace/perf.h > @@ -39,17 +39,27 @@ perf_trace_##call(void *__data, proto) \ > u64 __count = 1; \ > struct task_struct *__task = NULL; \ > struct hlist_head *head; \ > + bool rcu_watching; \ > int __entry_size; \ > int __data_size; \ > int rctx; \ > \ > + rcu_watching = rcu_is_watching(); \ > + \ > + /* Can not use RCU if rcu is not watching and in NMI */ \ > + if (!rcu_watching && in_nmi()) \ > + return; \ > + \ > __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \ > \ > + if (!rcu_watching) \ > + rcu_irq_enter_irqson(); \ You might want to fold the line above into the first check like this, considering that doing the rcu_irq_enter_irqson() earlier should not matter, and I expect it to remove a branch from the probe: rcu_watching = rcu_is_watching(); if (!rcu_watching) { if (in_nmi()) return; rcu_irq_enter_irqson(); } Thanks! Mathieu > + \ > head = this_cpu_ptr(event_call->perf_events); \ > if (!bpf_prog_array_valid(event_call) && \ > __builtin_constant_p(!__task) && !__task && \ > hlist_empty(head)) \ > - return; \ > + goto out; \ > \ > __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\ > sizeof(u64)); \ > @@ -57,7 +67,7 @@ perf_trace_##call(void *__data, proto) \ > \ > entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \ > if (!entry) \ > - return; \ > + goto out; \ > \ > perf_fetch_caller_regs(__regs); \ > \ > @@ -68,6 +78,9 @@ perf_trace_##call(void *__data, proto) \ > perf_trace_run_bpf_submit(entry, __entry_size, rctx, \ > event_call, __count, __regs, \ > head, __task); \ > +out: \ > + if (!rcu_watching) \ > + rcu_irq_exit_irqson(); \ > } > > /* -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com