From patchwork Sun May 28 05:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 99877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp777975vqr; Sat, 27 May 2023 23:28:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6C+jo7J5yRoIn15mS/QNRmME0uDCNwvZpVOKSBL4P+NEZjM0KxbNq3C7JP5rcnkCEgE7gE X-Received: by 2002:a05:6a21:788d:b0:10b:e39a:b50e with SMTP id bf13-20020a056a21788d00b0010be39ab50emr6356128pzc.36.1685255284890; Sat, 27 May 2023 23:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685255284; cv=none; d=google.com; s=arc-20160816; b=y9g0Gm6/JOvD+GtXuxyJk75foKQVaomo7ISnNKS7q+8fedfOWtlmbKfC8esDJxLOor rjmzNwutmAg7BbuXsOFgTvXuf30kiG8yQHYJFI60qrqnzsuiKBJKxElIGH4SWHZcbd+N W1TuTR0pnRBznnRZMsN8e0c3KLcg+5gAkoltPWPn+9gK8EMv0uzu6Wa8cAK42t5z03c7 JZx8yXtzfLGa4reihvOHjI2udnonSTQqSYNdVwWUiLTkDrpDjkLOpqbKklKp7TtK0eUs S7nutNWKa6qsqqxcFa6/0bpwKYQZjitdr80rYqiy7xXQaLeUM7iSf/E8Xuj3DG63wwe+ Rtqw== 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; bh=wfIp4vZibdiqN0LlC8WvobcWfbZsJbufbPEYT0u76HA=; b=tGh0/jcuHfV0+puCXyTxvoWiaXtZCPJmg4Gcu6U30XMjLvJbj8d5rLr7k+wD0sNIoO 2eh78cfIgVyap/6kq1cVaVT+a6dr6Vcr9ZodSMGKt7MOsReBY8pwFJUbyQ3RzD13X0+c y2OKUNQrMUT0umfDrNILePMA6uqiZY7WjXE5XnlQnXhQbgeRRH8UWMDGJRbHw5cOmp0u GJn8AgEAYxizWid6G57V+OeJkcOzXfSI06U98BKMAo8/u/OTODT2AV6XiP54txyerja1 fWC0Oe8nZkPa6ajeJ/SZQc2/vXZh465k0pR1T1SCDHYUBldIAXH/+gDErFu75iDgagnE ahWA== 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 w8-20020a63f508000000b0053424040bb7si7332563pgh.298.2023.05.27.23.27.51; Sat, 27 May 2023 23:28:04 -0700 (PDT) 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 S229543AbjE1F1G (ORCPT + 99 others); Sun, 28 May 2023 01:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjE1F0s (ORCPT ); Sun, 28 May 2023 01:26:48 -0400 Received: from mammoth.local.home (cpe-172-100-189-27.stny.res.rr.com [172.100.189.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4235E4; Sat, 27 May 2023 22:26:45 -0700 (PDT) Received: by mammoth.local.home (Postfix, from userid 5657) id B95EB300A58; Sun, 28 May 2023 01:17:53 -0400 (EDT) From: Steven Rostedt To: LKML , Linux trace kernel Cc: Masami Hiramatsu , Mark Rutland , "Steven Rostedt (Google)" Subject: [PATCH 1/5] tracing: Move setting of tracing_selftest_running out of register_tracer() Date: Sun, 28 May 2023 01:17:38 -0400 Message-Id: <20230528051742.1325503-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230528051742.1325503-1-rostedt@goodmis.org> References: <20230528051742.1325503-1-rostedt@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, PDS_RDNS_DYNAMIC_FP,RCVD_IN_PBL,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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?1767118245724639483?= X-GMAIL-MSGID: =?utf-8?q?1767118245724639483?= From: "Steven Rostedt (Google)" The variables tracing_selftest_running and tracing_selftest_disabled are only used for when CONFIG_FTRACE_STARTUP_TEST is enabled. Make them only visible within the selftest code. The setting of those variables are in the register_tracer() call, and set in a location where they do not need to be. Create a wrapper around run_tracer_selftest() called do_run_tracer_selftest() which sets those variables, and have register_tracer() call that instead. Having those variables only set within the CONFIG_FTRACE_STARTUP_TEST scope gets rid of them (and also the ability to remove testing against them) when the startup tests are not enabled (most cases). Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 81801dc31784..87e5920b141f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2041,6 +2041,17 @@ static int run_tracer_selftest(struct tracer *type) return 0; } +static int do_run_tracer_selftest(struct tracer *type) +{ + int ret; + + tracing_selftest_running = true; + ret = run_tracer_selftest(type); + tracing_selftest_running = false; + + return ret; +} + static __init int init_trace_selftests(void) { struct trace_selftests *p, *n; @@ -2092,6 +2103,10 @@ static inline int run_tracer_selftest(struct tracer *type) { return 0; } +static inline int do_run_tracer_selftest(struct tracer *type) +{ + return 0; +} #endif /* CONFIG_FTRACE_STARTUP_TEST */ static void add_tracer_options(struct trace_array *tr, struct tracer *t); @@ -2127,8 +2142,6 @@ int __init register_tracer(struct tracer *type) mutex_lock(&trace_types_lock); - tracing_selftest_running = true; - for (t = trace_types; t; t = t->next) { if (strcmp(type->name, t->name) == 0) { /* already found */ @@ -2157,7 +2170,7 @@ int __init register_tracer(struct tracer *type) /* store the tracer for __set_tracer_option */ type->flags->trace = type; - ret = run_tracer_selftest(type); + ret = do_run_tracer_selftest(type); if (ret < 0) goto out; @@ -2166,7 +2179,6 @@ int __init register_tracer(struct tracer *type) add_tracer_options(&global_trace, type); out: - tracing_selftest_running = false; mutex_unlock(&trace_types_lock); if (ret || !default_bootup_tracer)