Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp903329pxu; Fri, 23 Oct 2020 16:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQF/+Oyor+H3fQrvCtLJIZsfEcFtP5QjEVPhJk5tw105n3Xlkttwvp5wyRQfapQxj10end X-Received: by 2002:a17:906:2e08:: with SMTP id n8mr4425561eji.476.1603497128510; Fri, 23 Oct 2020 16:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603497128; cv=none; d=google.com; s=arc-20160816; b=oPVraVG1yeFBaK6lk/bnUnfTgtffntuTSwZ/3FR+DGbhacIP/OkNaoA6qTftzq0WA9 w2IdWRWPqOTssjjbWL1C68wQSzCJ7n9bSdS8fXwa1x15gXCI4mmdcyR8guUk87iG4TZs z/aQ5CO7AZMPmJ1uOcQCrAKPG8OpohsQ+FVzYR8S+6+puRv7NypsGxzCkTZBcjVqCtjq 2MHKiAmkXyFh9Rvob9ex1jEKA8IaygtxFo0V/vL0r9ni4ctSMxr5QWBUd3BQqh5ZnMKe GYJgOA7NLQZLD4U1jTjCeHjLcjSq4ZZnldoFO/TVgY2oPj7G5zGQC5F2qoe9wtdWPznU no5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=j9UnACLjaWXUFo/av68UOdzNoWRf/HE9TVrjkJrsWRU=; b=oqKpNNreAGRJN0YkINonig9Rs1qBQ5xy4P4cHQJjTUTqwXC2gL2Qd+25GMXUDWhqx4 +YllBbckWWxBF1+FZqGc/jpCr1r99FzIpkCUnXbz6Sa42aOerSEjAPXMUNYXS2+mYhe6 k8i5YNgnW8RLxNzEmp3ofuAWJQx6P1dHzWorzXU465zSDX+EhRBDvKLCDKCAhSCf1Z+X 2C1MI0hwihGa1Nh3pvQP31VbFVEjaXWMfl2JLhCi1ivT+L6Xsn1Ry3I9N8iDEYwEs0eV /qjMTz/PZCCLB8Y8MWLy/fJFAOMD0em8CVauH+7GfWi8dYvLrspfjSvhIuk+AmMngiyZ yvtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="FER/C7w2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a9si1795816edv.66.2020.10.23.16.51.46; Fri, 23 Oct 2020 16:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="FER/C7w2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1755111AbgJWTyd (ORCPT + 99 others); Fri, 23 Oct 2020 15:54:33 -0400 Received: from mail.efficios.com ([167.114.26.124]:45766 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755006AbgJWTyV (ORCPT ); Fri, 23 Oct 2020 15:54:21 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 6EDFC27969A; Fri, 23 Oct 2020 15:54:20 -0400 (EDT) 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 jXavxSd7PtMQ; Fri, 23 Oct 2020 15:54:20 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0072727979E; Fri, 23 Oct 2020 15:54:20 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 0072727979E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1603482860; bh=j9UnACLjaWXUFo/av68UOdzNoWRf/HE9TVrjkJrsWRU=; h=From:To:Date:Message-Id:MIME-Version; b=FER/C7w270ug+KSJHcCBfyo3oaJ8nz40XK6yMAvydFSXmhZk5/rKseIWmdYqcExqc j0FPC4yoUENNueuIIPRaSKl61V7H1aSFVuWaWNaXC20VEDQtW7UBJzbAYHNoiJtg2p buuRbfMOpL9HwiBdPiLYmgifvfzyrAx/8uSXEhm72vNIQ2lWQkSpPf7DQP0/SWSUDZ lq5wzhJQua3SZliRAyxnsueizOM5GJk7HZbjAfLAPkHZkswgJS+IkD9BjLMuceQI6K 9gIZbbLKji17dvAgR2jdGW6cc9AzHIPuW+UMvg7+aSuGG6Z40mW0yj2ODkkGluBWHL 09PZcurWVIBtQ== 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 oNOK1vXrZYpn; Fri, 23 Oct 2020 15:54:19 -0400 (EDT) Received: from localhost.localdomain (96-127-212-112.qc.cable.ebox.net [96.127.212.112]) by mail.efficios.com (Postfix) with ESMTPSA id 618C027971A; Fri, 23 Oct 2020 15:54:19 -0400 (EDT) From: Michael Jeanson To: linux-kernel@vger.kernel.org Cc: mathieu.desnoyers@efficios.com, Michael Jeanson , Steven Rostedt , Peter Zijlstra , Alexei Starovoitov , Yonghong Song , "Paul E . McKenney" , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Joel Fernandes , bpf@vger.kernel.org Subject: [RFC PATCH 6/6] tracing: use sched-RCU instead of SRCU for rcuidle tracepoints Date: Fri, 23 Oct 2020 15:53:52 -0400 Message-Id: <20201023195352.26269-7-mjeanson@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023195352.26269-1-mjeanson@efficios.com> References: <20201023195352.26269-1-mjeanson@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Desnoyers Considering that tracer callbacks expect RCU to be watching (for instance, perf uses rcu_read_lock), we need rcuidle tracepoints to issue rcu_irq_{enter,exit}_irqson around calls to the callbacks. So there is no point in using SRCU anymore given that rcuidle tracepoints need to ensure RCU is watching. Therefore, simply use sched-RCU like normal tracepoints for rcuidle tracepoints. Signed-off-by: Mathieu Desnoyers Cc: Michael Jeanson Cc: Steven Rostedt (VMware) Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Joel Fernandes (Google) Cc: bpf@vger.kernel.org --- include/linux/tracepoint.h | 33 +++++++-------------------------- kernel/tracepoint.c | 25 +++++++++---------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 0386b54cbcbb..1414b11f864b 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -13,7 +13,6 @@ */ =20 #include -#include #include #include #include @@ -33,8 +32,6 @@ struct trace_eval_map { =20 #define TRACEPOINT_DEFAULT_PRIO 10 =20 -extern struct srcu_struct tracepoint_srcu; - extern int tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data= ); extern int @@ -86,7 +83,6 @@ int unregister_tracepoint_module_notifier(struct notifi= er_block *nb) static inline void tracepoint_synchronize_unregister(void) { synchronize_rcu_tasks_trace(); - synchronize_srcu(&tracepoint_srcu); synchronize_rcu(); } #else @@ -175,25 +171,13 @@ static inline struct tracepoint *tracepoint_ptr_der= ef(tracepoint_ptr_t *p) if (!(cond)) \ return; \ \ - /* srcu can't be used from NMI */ \ - WARN_ON_ONCE(rcuidle && in_nmi()); \ - \ - if (maysleep) { \ - might_sleep(); \ + might_sleep_if(maysleep); \ + if (rcuidle) \ + rcu_irq_enter_irqson(); \ + if (maysleep) \ rcu_read_lock_trace(); \ - } else { \ - /* keep srcu and sched-rcu usage consistent */ \ + else \ preempt_disable_notrace(); \ - } \ - \ - /* \ - * For rcuidle callers, use srcu since sched-rcu \ - * doesn't work from the idle path. \ - */ \ - if (rcuidle) { \ - __idx =3D srcu_read_lock_notrace(&tracepoint_srcu);\ - rcu_irq_enter_irqson(); \ - } \ \ it_func_ptr =3D rcu_dereference_raw((tp)->funcs); \ \ @@ -205,15 +189,12 @@ static inline struct tracepoint *tracepoint_ptr_der= ef(tracepoint_ptr_t *p) } while ((++it_func_ptr)->func); \ } \ \ - if (rcuidle) { \ - rcu_irq_exit_irqson(); \ - srcu_read_unlock_notrace(&tracepoint_srcu, __idx);\ - } \ - \ if (maysleep) \ rcu_read_unlock_trace(); \ else \ preempt_enable_notrace(); \ + if (rcuidle) \ + rcu_irq_exit_irqson(); \ } while (0) =20 #ifndef MODULE diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 8d8e41c5d8a5..68b4e50798b1 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c @@ -18,9 +18,6 @@ extern tracepoint_ptr_t __start___tracepoints_ptrs[]; extern tracepoint_ptr_t __stop___tracepoints_ptrs[]; =20 -DEFINE_SRCU(tracepoint_srcu); -EXPORT_SYMBOL_GPL(tracepoint_srcu); - /* Set to 1 to enable tracepoint debug output */ static const int tracepoint_debug; =20 @@ -65,14 +62,9 @@ static void rcu_tasks_trace_free_old_probes(struct rcu= _head *head) kfree(container_of(head, struct tp_probes, rcu)); } =20 -static void srcu_free_old_probes(struct rcu_head *head) -{ - call_rcu_tasks_trace(head, rcu_tasks_trace_free_old_probes); -} - static void rcu_free_old_probes(struct rcu_head *head) { - call_srcu(&tracepoint_srcu, head, srcu_free_old_probes); + call_rcu_tasks_trace(head, rcu_tasks_trace_free_old_probes); } =20 static __init int release_early_probes(void) @@ -90,7 +82,7 @@ static __init int release_early_probes(void) return 0; } =20 -/* SRCU and Tasks Trace RCU are initialized at core_initcall */ +/* Tasks Trace RCU is initialized at core_initcall */ postcore_initcall(release_early_probes); =20 static inline void release_probes(struct tracepoint_func *old) @@ -100,9 +92,8 @@ static inline void release_probes(struct tracepoint_fu= nc *old) struct tp_probes, probes[0]); =20 /* - * We can't free probes if SRCU and Tasks Trace RCU are not - * initialized yet. Postpone the freeing till after both are - * initialized. + * We can't free probes if Tasks Trace RCU is not initialized yet. + * Postpone the freeing till after Tasks Trace RCU is initialized. */ if (unlikely(!ok_to_free_tracepoints)) { tp_probes->rcu.next =3D early_probes; @@ -111,9 +102,11 @@ static inline void release_probes(struct tracepoint_= func *old) } =20 /* - * Tracepoint probes are protected by sched RCU, SRCU and - * Tasks Trace RCU by chaining the callbacks we cover all three - * cases and wait for all three grace periods. + * Tracepoint probes are protected by both sched RCU and + * Tasks Trace RCU, by calling the Tasks Trace RCU callback in + * the sched RCU callback we cover both cases. So let us chain + * the Tasks Trace RCU and sched RCU callbacks to wait for both + * grace periods. */ call_rcu(&tp_probes->rcu, rcu_free_old_probes); } --=20 2.25.1