From patchwork Thu Mar 9 21:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 67123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp539888wrd; Thu, 9 Mar 2023 13:58:42 -0800 (PST) X-Google-Smtp-Source: AK7set9swOV17IP6m7qp1b6BbPCm5IiGQLVnP/Hsw38BTOnWlxdslRIZa4NbxBRGBmmTxRCUEyJD X-Received: by 2002:a17:90a:191c:b0:237:50b6:7835 with SMTP id 28-20020a17090a191c00b0023750b67835mr23923398pjg.20.1678399122113; Thu, 09 Mar 2023 13:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678399122; cv=none; d=google.com; s=arc-20160816; b=dMe2qEwNEA+YmJrZ7Cb3PMyvv/Iu9vZ0dKiENMbEsd+9GR8Un7lHY+JZAMpHggqY6Q uIlEGriY7+P2rSL3n9fBCGESOI0zNl080HFT2QFfx1pSAWHAX/gWKD+IBJjWEMgRiv+4 gBuYw8kvvDdFTE84VI3Ki1tRP51yc/RA7YdcQ60CI8M1vp2nmGRHl0o54Vpp/T70B/wr wa53vXsMx9VIiNfOrubXxYsSdATEGtOmyVqWO8QUvU1iJyVN9a5tokzJqhrPuz9HHxOK BIaiZ1NSagZ20TO0YgHOIlpBQCuMtpJbk7SVD86Hym72QXvJ93Dchfp3koyYaLJ96Qfh p5zg== 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 :message-id:subject:cc:to:from:date; bh=iVsxxYPKLywHqPuSqU/IIPO0v7MyiogS3mr8aqVveS8=; b=Sy4UlZL84EgnFpnLlowfQvRghSHt9rU31oAVejQRjBf0ZDMvepAN1Fx0S7+zgwJKvI yg5i55XF9+eUewFRlLHNtleAROtGl76ArAufGIbrpgdH1wf6sMjThlmXr1tob8gp3uQj seqWTLMKqOFA2U9qKQ3Cc1cHnCT/uO4xVtPf2WaD+rE20s6sayNWNY8N+LmECvgUN6Am ppWbjx/GFAlRG4aTQ93t8+BZpQhFKm0evPDgrxA2H88JDhpGEzi89bGsG4bKvmzrcpNf wnDjC/1ZFZxMsORtFdj/42wfTroUdA16vf93UwYEEjRq4nEzccHiRYOQd6+kqehRLQ7w 938A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a17090a430800b002366a535553si778025pjg.107.2023.03.09.13.58.29; Thu, 09 Mar 2023 13:58:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjCIV6J (ORCPT + 99 others); Thu, 9 Mar 2023 16:58:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjCIV5B (ORCPT ); Thu, 9 Mar 2023 16:57:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508DCFB26B; Thu, 9 Mar 2023 13:56:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DF71061D12; Thu, 9 Mar 2023 21:56:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77C46C433D2; Thu, 9 Mar 2023 21:56:05 +0000 (UTC) Date: Thu, 9 Mar 2023 16:56:03 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Peter Zijlstra , Masami Hiramatsu , Dave Hansen , "Paul E. McKenney" , Mathieu Desnoyers , Joel Fernandes Subject: [PATCH] tracing: Make tracepoint lockdep check actually test something Message-ID: <20230309165603.6967197d@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759929037880879572?= X-GMAIL-MSGID: =?utf-8?q?1759929037880879572?= From: "Steven Rostedt (Google)" A while ago where the trace events had the following: rcu_read_lock_sched_notrace(); rcu_dereference_sched(...); rcu_read_unlock_sched_notrace(); If the tracepoint is enabled, it could trigger RCU issues if called in the wrong place. And this warning was only triggered if lockdep was enabled. If the tracepoint was never enabled with lockdep, the bug would not be caught. To handle this, the above sequence was done when lockdep was enabled regardless if the tracepoint was enabled or not (although the always enabled code really didn't do anything, it would still trigger a warning). But a lot has changed since that lockdep code was added. One is, that sequence no longer triggers any warning. Another is, the tracepoint when enabled doesn't even do that sequence anymore. The main check we care about today is whether RCU is "watching" or not. So if lockdep is enabled, always check if rcu_is_watching() which will trigger a warning if it is not (tracepoints require RCU to be watching). Note, that old sequence did add a bit of overhead when lockdep was enabled, and with the latest kernel updates, would cause the system to slow down enough to trigger kernel "stalled" warnings. Link: http://lore.kernel.org/lkml/20140806181801.GA4605@redhat.com Link: http://lore.kernel.org/lkml/20140807175204.C257CAC5@viggo.jf.intel.com Link: https://lore.kernel.org/lkml/20230307184645.521db5c9@gandalf.local.home/ Cc: stable@vger.kernel.org Fixes: e6753f23d961 ("tracepoint: Make rcuidle tracepoint callers use SRCU") Signed-off-by: Steven Rostedt (Google) --- include/linux/tracepoint.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index e299f29375bb..d3a221158ab1 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -260,9 +260,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) TP_ARGS(args), \ TP_CONDITION(cond), 0); \ if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ - rcu_read_lock_sched_notrace(); \ - rcu_dereference_sched(__tracepoint_##name.funcs);\ - rcu_read_unlock_sched_notrace(); \ + WARN_ON_ONCE(!rcu_is_watching()); \ } \ } \ __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \