Received: by 10.192.165.148 with SMTP id m20csp4424495imm; Mon, 30 Apr 2018 18:56:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpX5VRhV8AnJU+pcnDOx1LjxtGNC3m1WPas/oIv8OV4ydtjQzYP0FROy/FeP7QeEMUs8G8q X-Received: by 2002:a17:902:3265:: with SMTP id y92-v6mr14573121plb.352.1525139799095; Mon, 30 Apr 2018 18:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525139799; cv=none; d=google.com; s=arc-20160816; b=kqjFJpcXXPrBD+S6zX4vEyUJBeTU6eiEJZf16AZdMP+F7MP84AMIMkUATfna5oT+HK J4g/H+hK2KaKaXpqoQkXGJ8aZl0eyr+JDbhXSlqLRNl7pdpOfbzMbhejg1LEBhIP4mal bKWaxmGj2yMErgnxJUpTIaXv9q55Kgr0fcXQURQZ49QqML95qIapG1pH2aGRaEavuH8h YQccfcj72hDIPO0jTjaoWuodT+Mer8Vl4mCgUEEl0baW38shwSWnYay5Z9A6ZaKY5jOK wyX8VptEGnKZyEjpDrLe675n1ej3t3k5Rq5h5v7NtzM0oD/vPlXDWWQ1lVCwP8ccmFRY hC4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=EIoNrTJR0ZICVoDv/cya71PnYPlBEJPQAX9kJML2LEc=; b=dF8KvUepsLe9OJ2PQLJrM6TinEhrel2Pf4kK3EzlKzwBTb3B8OQS+Xxlvn1A26qA+n 4Ub5V6EgdKifePUH28Vba4Wh3q1V1qtmdimy9pE8DKc4epllTzzladWxwAxduZKSYT3u NS1Mwq6oM/JHfyxif6R8rgJxs8tCc7S1B47xE0NJcRQavZOD/syEYeb6O/glhe6OZuEE 3iiQD3fBTj/a3zJN3h54TR/0a/tT5uWtzPRbhsvQc2WwzuFPzqkQggdlhOM7f0ja6oU8 lCWIciYOlmnBwsIyB9iGs68qLHy8qIqz6GIony1Oi1fcx82Xj9nZU7RulLkZzqkR53mt AkSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oeQti8GD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71-v6si8612142plb.511.2018.04.30.18.56.24; Mon, 30 Apr 2018 18:56:39 -0700 (PDT) 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=@google.com header.s=20161025 header.b=oeQti8GD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752056AbeEAB4P (ORCPT + 99 others); Mon, 30 Apr 2018 21:56:15 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:32804 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbeEAB4N (ORCPT ); Mon, 30 Apr 2018 21:56:13 -0400 Received: by mail-it0-f68.google.com with SMTP id t7-v6so4527299itf.0 for ; Mon, 30 Apr 2018 18:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EIoNrTJR0ZICVoDv/cya71PnYPlBEJPQAX9kJML2LEc=; b=oeQti8GDJD9OM/NeBYCQgRIgk84L4ZyVw0wGk59vVtkceFcd9sCEtBduAAD3YE5q4x wgxXuzJ1N7yUJfETujyECuMv9/3u/V7yT35tw11OFr5Ld3GNhij5McZtqRjMd/6mK3ZR SNuqZRXRTinkXlWzVc008h/wRo18Md15jeMIyJfY39Xb/FqaS9AFVK28bKxVjnBdAtre Dd53abZvnQrhV0dLKNmbgKOcxECDC1KGuuyynnSGMs8uCUarGC/JwUT12N2LhH1bb07j NnzHwsul5mmrK+rsfAFVDwx61lX5cVRAF3fp64lNa4N7qzfeop+mTfttpfN3nikg9D32 jIQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EIoNrTJR0ZICVoDv/cya71PnYPlBEJPQAX9kJML2LEc=; b=K2qrKGRNwOW1dmrx14ngU6U2Pcr/B0HqxUNf98HL/bxQQJorV5dPrEAvM7sXvnyA55 39gErm8EQdto94SI+lnmu5A+As3NWKx7CxTFeEARi9vn3Jpj3t6RjVFhZzsq0uT6fco4 32SI7O3z1cNxGEN6/bHbJOcehxKwYCWOa37HzDjmf/2aGoSwx5U9CHxC0vQ0Osjh12ZS 66Fhv6elmvo1vWRmotXu8D6r9FhPHS45yz9imwWAVrJPshQ2B0Ae0l60QzXxli1bkUzD mmX1UpD6HkChXrZRyhY7EU8/VPqaLOtjEHhU5jzq86Y+I++egCVQf49LG8bwYAbv9Bwj p8ZQ== X-Gm-Message-State: ALQs6tARZ6GpacTyIjUPmv98WVBwBPyBzIxtpsIg+QseG5a8thQAh5Zp aEzeK5qgIcYzYMOdA5rf2lgMTHvgvNpV5/7EFgPiuHBC X-Received: by 2002:a24:438f:: with SMTP id s137-v6mr12371250itb.28.1525139772403; Mon, 30 Apr 2018 18:56:12 -0700 (PDT) MIME-Version: 1.0 References: <20180501014204.67548-1-joelaf@google.com> <20180501014204.67548-6-joelaf@google.com> In-Reply-To: <20180501014204.67548-6-joelaf@google.com> From: Joel Fernandes Date: Tue, 01 May 2018 01:56:01 +0000 Message-ID: Subject: Re: [PATCH RFC v5 5/6] tracepoint: Make rcuidle tracepoint callers use SRCU To: LKML Cc: Steven Rostedt , Peter Zijlstra , Ingo Molnar , Mathieu Desnoyers , Tom Zanussi , Namhyung Kim , Thomas Gleixner , Boqun Feng , Paul McKenney , "Cc: Frederic Weisbecker" , Randy Dunlap , Masami Hiramatsu , Fenguang Wu , Baohong Liu , Vedang Patel , "Cc: Android Kernel" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 30, 2018 at 6:42 PM Joel Fernandes wrote: > In recent tests with IRQ on/off tracepoints, a large performance > overhead ~10% is noticed when running hackbench. This is root caused to > calls to rcu_irq_enter_irqson and rcu_irq_exit_irqson from the > tracepoint code. Following a long discussion on the list [1] about this, > we concluded that srcu is a better alternative for use during rcu idle. > Although it does involve extra barriers, its lighter than the sched-rcu > version which has to do additional RCU calls to notify RCU idle about > entry into RCU sections. > In this patch, we change the underlying implementation of the > trace_*_rcuidle API to use SRCU. This has shown to improve performance > alot for the high frequency irq enable/disable tracepoints. > Test: Tested idle and preempt/irq tracepoints. > [1] https://patchwork.kernel.org/patch/10344297/ > Cc: Steven Rostedt > Cc: Peter Zilstra > Cc: Ingo Molnar > Cc: Mathieu Desnoyers > Cc: Tom Zanussi > Cc: Namhyung Kim > Cc: Thomas Glexiner > Cc: Boqun Feng > Cc: Paul McKenney > Cc: Frederic Weisbecker > Cc: Randy Dunlap > Cc: Masami Hiramatsu > Cc: Fenguang Wu > Cc: Baohong Liu > Cc: Vedang Patel > Cc: kernel-team@android.com > Signed-off-by: Joel Fernandes > --- > include/linux/tracepoint.h | 46 +++++++++++++++++++++++++++++++------- > kernel/tracepoint.c | 10 ++++++++- > 2 files changed, 47 insertions(+), 9 deletions(-) > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h > index c94f466d57ef..4135e08fb5f1 100644 > --- a/include/linux/tracepoint.h > +++ b/include/linux/tracepoint.h > @@ -15,6 +15,7 @@ > */ > #include > +#include > #include > #include > #include > @@ -33,6 +34,8 @@ struct trace_eval_map { > #define TRACEPOINT_DEFAULT_PRIO 10 > +extern struct srcu_struct tracepoint_srcu; > + > extern int > tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data); > extern int > @@ -77,6 +80,9 @@ int unregister_tracepoint_module_notifier(struct notifier_block *nb) > */ > static inline void tracepoint_synchronize_unregister(void) > { > +#ifdef CONFIG_TRACEPOINTS > + synchronize_srcu(&tracepoint_srcu); > +#endif > synchronize_sched(); > } > @@ -129,18 +135,38 @@ extern void syscall_unregfunc(void); > * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just > * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". > */ > -#define __DO_TRACE(tp, proto, args, cond, rcucheck) \ > +#define __DO_TRACE(tp, proto, args, cond, rcuidle) \ > do { \ > struct tracepoint_func *it_func_ptr; \ > void *it_func; \ > void *__data; \ > + int __maybe_unused idx = 0; \ > \ > if (!(cond)) \ > return; \ > - if (rcucheck) \ > - rcu_irq_enter_irqson(); \ > - rcu_read_lock_sched_notrace(); \ > - it_func_ptr = rcu_dereference_sched((tp)->funcs); \ > + \ > + /* \ > + * For rcuidle callers, use srcu since sched-rcu \ > + * doesn't work from the idle path. \ > + */ \ > + if (rcuidle) { \ > + if (in_nmi()) { \ > + WARN_ON_ONCE(1); \ > + return; /* no srcu from nmi */ \ > + } \ > + \ > + /* To keep it consistent with !rcuidle path */ \ > + preempt_disable_notrace(); \ > + \ > + idx = srcu_read_lock_notrace(&tracepoint_srcu); \ > + it_func_ptr = srcu_dereference((tp)->funcs, \ > + &tracepoint_srcu); \ This last bit is supposed to be srcu_dereference_notrace. The hunk to use that is actually in patch 6/6 , sorry about that. I've fixed it in my tree and it means patches 5/6 and 6/6 need an update. Steve, if you want me to repost it right away I can do that, or can wait for additional comments and then repost. thanks, - Joel