From nobody Wed Feb 11 05:41:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A6B2D131A for ; Mon, 9 Feb 2026 02:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770603607; cv=none; b=MJQHLzHX8zVOxifEBnGUnmKxvqxxm74TrQssC1AVGui4390u2aEXyFR7hj405S5wTVIZClBLtK3ZD5ma0WuStPmGxp9EZiWL+ZZtoug3nHC+oUaI3ZwwKk+8fBsr8IDJcgrl6/qMaFdzyLNwCFxg80NHTVBojTGFBtfXNOPlWVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770603607; c=relaxed/simple; bh=G5l2nINDy7C/S1ObXYbobZa/juMWBtTnmfcabjwLGdI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JFEe+Y8g5q7ls19SpXMdG1+y/I4yhNVNd8Q9/jSZR+51Fw/Wsnr90wAAnH21wGt27Y3Vy5QYBSY609W4okBUs7s/0HCFJO2+zGiJeP3E0Pc4cFriUpR+k0kVI1oVsmr4pB2CasdVDNruh0JfRvT6EepAqtj3jjCa7pbxB7km9Yk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R2lCglqj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R2lCglqj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9405C4CEF7; Mon, 9 Feb 2026 02:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770603607; bh=G5l2nINDy7C/S1ObXYbobZa/juMWBtTnmfcabjwLGdI=; h=Date:From:To:Cc:Subject:References:From; b=R2lCglqjPRW9tCyrFyg/sfaHJLwDeNTfcsvYcYZU9X/MPZXcDfRJYKXb61qN8tzVG aTttlPmHywga8Y1Z1z4SZoSWcZBDajHYr+zjikhXX2iQ21zf8Q44Bj/WHN5j+cJISR Uchv/luV3CphBtuXrnWO+SylKypxHf6b7sQogqRZlRy1UJF/Q5HWZIFTEMLkV58BEs qw/aTSFU5N5qqO2tkY586K4V5uSSjI8AJjosVwoF8ePTdi4hY8+o4No5V/KVseNqY1 ciby57zCB/B7X34lV+fOfa/PTsxxhlpKcDfDZvnddqugNolvR8gYNOl/4b83Vq89Y6 s1c1PEx86jc/A== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1vpGtR-0000000Aa3r-29Bc; Sun, 08 Feb 2026 21:20:53 -0500 Message-ID: <20260209022053.368331001@kernel.org> User-Agent: quilt/0.68 Date: Sun, 08 Feb 2026 21:20:34 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 08/20] tracing: Make tracing_disabled global for tracing system References: <20260209022026.627895421@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt The tracing_disabled variable is set to one on boot up to prevent some parts of tracing to access the tracing infrastructure before it is set up. It also can be set after boot if an anomaly is discovered. It is currently a static variable in trace.c and can be accessed via a function call trace_is_disabled(). There's really no reason to use a function call as the tracing subsystem should be able to access it directly. By making the variable accessed directly, code can be moved out of trace.c without adding overhead of a function call to see if tracing is disabled or not. Make tracing_disabled global and remove the tracing_is_disabled() helper function. Also add some "unlikely()"s around tracing_disabled where it's checked in hot paths. Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Link: https://patch.msgid.link/20260208032449.483690153@kernel.org Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 13 ++++--------- kernel/trace/trace.h | 3 ++- kernel/trace/trace_events.c | 2 +- kernel/trace/trace_kprobe.c | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index d02c4004c718..1ff40c88e75c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -114,7 +114,7 @@ DEFINE_PER_CPU(bool, trace_taskinfo_save); * of the tracer is successful. But that is the only place that sets * this back to zero. */ -static int tracing_disabled =3D 1; +int tracing_disabled =3D 1; =20 cpumask_var_t __read_mostly tracing_buffer_mask; =20 @@ -3423,7 +3423,7 @@ int __trace_array_vprintk(struct trace_buffer *buffer, unsigned int trace_ctx; char *tbuffer; =20 - if (tracing_disabled) + if (unlikely(tracing_disabled)) return 0; =20 /* Don't pollute graph traces with trace_vprintk internals */ @@ -4765,11 +4765,6 @@ int tracing_open_generic(struct inode *inode, struct= file *filp) return 0; } =20 -bool tracing_is_disabled(void) -{ - return (tracing_disabled) ? true: false; -} - /* * Open and update trace_array ref count. * Must have the current trace_array passed to it. @@ -7609,7 +7604,7 @@ tracing_mark_write(struct file *filp, const char __us= er *ubuf, unsigned long ip; char *buf; =20 - if (tracing_disabled) + if (unlikely(tracing_disabled)) return -EINVAL; =20 if (!(tr->trace_flags & TRACE_ITER(MARKERS))) @@ -7689,7 +7684,7 @@ tracing_mark_raw_write(struct file *filp, const char = __user *ubuf, ssize_t written =3D -ENODEV; char *buf; =20 - if (tracing_disabled) + if (unlikely(tracing_disabled)) return -EINVAL; =20 if (!(tr->trace_flags & TRACE_ITER(MARKERS))) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 31fb137e1c66..433705bef480 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -657,6 +657,8 @@ trace_buffer_iter(struct trace_iterator *iter, int cpu) return iter->buffer_iter ? iter->buffer_iter[cpu] : NULL; } =20 +extern int tracing_disabled; + int tracer_init(struct tracer *t, struct trace_array *tr); int tracing_is_enabled(void); void tracing_reset_online_cpus(struct array_buffer *buf); @@ -668,7 +670,6 @@ int tracing_release_generic_tr(struct inode *inode, str= uct file *file); int tracing_open_file_tr(struct inode *inode, struct file *filp); int tracing_release_file_tr(struct inode *inode, struct file *filp); int tracing_single_release_file_tr(struct inode *inode, struct file *filp); -bool tracing_is_disabled(void); bool tracer_tracing_is_on(struct trace_array *tr); void tracer_tracing_on(struct trace_array *tr); void tracer_tracing_off(struct trace_array *tr); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index af6d1fe5cab7..61fe01dce7a6 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2268,7 +2268,7 @@ static int subsystem_open(struct inode *inode, struct= file *filp) struct event_subsystem *system =3D NULL; int ret; =20 - if (tracing_is_disabled()) + if (unlikely(tracing_disabled)) return -ENODEV; =20 /* Make sure the system still exists */ diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 89d2740f7bb5..061658518605 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -2083,7 +2083,7 @@ static __init int kprobe_trace_self_tests_init(void) struct trace_kprobe *tk; struct trace_event_file *file; =20 - if (tracing_is_disabled()) + if (unlikely(tracing_disabled)) return -ENODEV; =20 if (tracing_selftest_disabled) --=20 2.51.0