From: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
To: <bpf@vger.kernel.org>, <linux-trace-kernel@vger.kernel.org>,
<live-patching@vger.kernel.org>, <rostedt@goodmis.org>,
<mbenes@suse.cz>
Cc: <jolsa@kernel.org>, <mhiramat@kernel.org>, <jpoimboe@kernel.org>,
<joe.lawrence@redhat.com>, <mark.rutland@arm.com>,
<corbet@lwn.net>, <stable@vger.kernel.org>,
<linux-open-source@crowdstrike.com>
Subject: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
Date: Thu, 6 Aug 2026 11:29:59 -0400 [thread overview]
Message-ID: <20260806153000.4184871-2-andrey.grodzovsky@crowdstrike.com> (raw)
In-Reply-To: <20260806153000.4184871-1-andrey.grodzovsky@crowdstrike.com>
Writing 0 to kernel.ftrace_enabled has not reliably disabled ftrace
for years (FTRACE_OPS_FL_PERMANENT users already block it, and more
callers rely on ftrace always being on). Refuse the write instead of
leaving it in an inconsistent "disables some, not all" state: return
-EOPNOTSUPP and log a message. Reads and enabling (writing 1) are
unaffected.
Update the docs to note the deprecation up front.
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
---
Documentation/trace/ftrace.rst | 5 ++++
kernel/trace/ftrace.c | 43 +++++-----------------------------
2 files changed, 11 insertions(+), 37 deletions(-)
diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst
index 84f06bf0da9b..7261f25f8b4b 100644
--- a/Documentation/trace/ftrace.rst
+++ b/Documentation/trace/ftrace.rst
@@ -3313,6 +3313,11 @@ this special filter via::
ftrace_enabled
--------------
+.. note::
+ Disabling ftrace via this switch is deprecated. Writing 0 is refused
+ with -EOPNOTSUPP and logs a warning; writing 1 and reading the value
+ are unaffected.
+
Note, the proc sysctl ftrace_enable is a big on/off switch for the
function tracer. By default it is enabled (when function tracing is
enabled in the kernel). If it is disabled, all function tracing is
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f93e34dd2328..3c0231ad6473 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -9357,38 +9357,10 @@ static void ftrace_startup_sysctl(void)
}
}
-static void ftrace_shutdown_sysctl(void)
-{
- int command;
-
- if (unlikely(ftrace_disabled))
- return;
-
- /* ftrace_start_up is true if ftrace is running */
- if (ftrace_start_up) {
- command = FTRACE_DISABLE_CALLS;
- if (ftrace_graph_active)
- command |= FTRACE_STOP_FUNC_RET;
- ftrace_run_update_code(command);
- }
-}
#else
# define ftrace_startup_sysctl() do { } while (0)
-# define ftrace_shutdown_sysctl() do { } while (0)
#endif /* CONFIG_DYNAMIC_FTRACE */
-static bool is_permanent_ops_registered(void)
-{
- struct ftrace_ops *op;
-
- do_for_each_ftrace_op(op, ftrace_ops_list) {
- if (op->flags & FTRACE_OPS_FL_PERMANENT)
- return true;
- } while_for_each_ftrace_op(op);
-
- return false;
-}
-
static int
ftrace_enable_sysctl(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
@@ -9415,15 +9387,12 @@ ftrace_enable_sysctl(const struct ctl_table *table, int write,
ftrace_startup_sysctl();
} else {
- if (is_permanent_ops_registered()) {
- ftrace_enabled = true;
- return -EBUSY;
- }
-
- /* stopping ftrace calls (just send to ftrace_stub) */
- ftrace_trace_function = ftrace_stub;
-
- ftrace_shutdown_sysctl();
+ /*
+ * Disabling ftrace at runtime via this knob is deprecated.
+ */
+ ftrace_enabled = true;
+ pr_warn_once("The ftrace_enabled file is deprecated and no longer disables ftrace\n");
+ return -EOPNOTSUPP;
}
last_ftrace_enabled = !!ftrace_enabled;
--
2.34.1
next prev parent reply other threads:[~2026-08-06 15:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 15:29 [RFC PATCH bpf-next v3 0/2] ftrace: deprecate the ftrace_enabled disable switch Andrey Grodzovsky
2026-08-06 15:29 ` Andrey Grodzovsky [this message]
2026-08-06 21:21 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Song Liu
2026-08-06 21:52 ` Andrey Grodzovsky
2026-08-09 18:32 ` Andrey Grodzovsky
2026-08-06 15:30 ` [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Andrey Grodzovsky
2026-08-06 21:18 ` Song Liu
2026-08-06 21:45 ` Andrey Grodzovsky
2026-08-07 0:51 ` Steven Rostedt
2026-08-07 7:17 ` Song Liu
2026-08-07 12:42 ` Steven Rostedt
2026-08-07 16:16 ` Song Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806153000.4184871-2-andrey.grodzovsky@crowdstrike.com \
--to=andrey.grodzovsky@crowdstrike.com \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=joe.lawrence@redhat.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=linux-open-source@crowdstrike.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox