* [for-next][PATCH 0/2] ftrace: Updates for v7.3
@ 2026-08-11 14:15 Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Steven Rostedt
0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-08-11 14:15 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace/for-next
Head SHA1: 88b3e7fedc07d940c32eb5c0733a780e944b6b47
Andrey Grodzovsky (2):
ftrace: deprecate disabling via ftrace_enabled sysctl
selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
----
Documentation/trace/ftrace.rst | 5 +++
kernel/trace/ftrace.c | 43 ++++------------------
tools/testing/selftests/livepatch/functions.sh | 14 ++++++++
tools/testing/selftests/livepatch/test-ftrace.sh | 45 +++++++++++++++---------
4 files changed, 53 insertions(+), 54 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [for-next][PATCH 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
2026-08-11 14:15 [for-next][PATCH 0/2] ftrace: Updates for v7.3 Steven Rostedt
@ 2026-08-11 14:15 ` Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-08-11 14:15 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Andrey Grodzovsky, Song Liu
From: Andrey Grodzovsky <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.
Link: https://patch.msgid.link/20260806153000.4184871-2-andrey.grodzovsky@crowdstrike.com
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
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 6c47a94f5924..d1989958d6b2 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -9370,38 +9370,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)
@@ -9428,15 +9400,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.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [for-next][PATCH 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
2026-08-11 14:15 [for-next][PATCH 0/2] ftrace: Updates for v7.3 Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Steven Rostedt
@ 2026-08-11 14:15 ` Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-08-11 14:15 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Joe Lawrence, Andrey Grodzovsky
From: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
kernel.ftrace_enabled=0 is now refused on kernels that deprecate the
knob, so the old disable/reload flow no longer applies there. Probe
for this with ftrace_disable_supported() and keep the full original
scenario (disable, fail to load a livepatch, re-enable, load, confirm
disable is refused while loaded) on kernels where it still works;
otherwise just confirm the write is refused.
Link: https://patch.msgid.link/20260806153000.4184871-3-andrey.grodzovsky@crowdstrike.com
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Suggested-by: Joe Lawrence <joe.lawrence@redhat.com>
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
.../testing/selftests/livepatch/functions.sh | 14 ++++++
.../selftests/livepatch/test-ftrace.sh | 45 ++++++++++++-------
2 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 30dc677b2f45..a65b7b1ac8ad 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -126,6 +126,20 @@ function set_ftrace_enabled() {
echo "livepatch: kernel.ftrace_enabled = $result" > /dev/kmsg
}
+# ftrace_disable_supported() - probe whether kernel.ftrace_enabled=0
+# can still disable ftrace on this kernel. Newer kernels deprecate
+# the knob and always refuse the write with -EOPNOTSUPP.
+function ftrace_disable_supported() {
+ local orig result
+
+ orig=$(sysctl --values kernel.ftrace_enabled)
+ sysctl -q kernel.ftrace_enabled=0 &> /dev/null
+ result=$(sysctl --values kernel.ftrace_enabled)
+ sysctl -q "kernel.ftrace_enabled=$orig" &> /dev/null
+
+ [[ "$result" == "0" ]]
+}
+
function cleanup() {
pop_config
}
diff --git a/tools/testing/selftests/livepatch/test-ftrace.sh b/tools/testing/selftests/livepatch/test-ftrace.sh
index d2c3dea63104..cd27148510f8 100755
--- a/tools/testing/selftests/livepatch/test-ftrace.sh
+++ b/tools/testing/selftests/livepatch/test-ftrace.sh
@@ -12,29 +12,32 @@ setup_config
# - turn ftrace_enabled OFF and verify livepatches can't load
# - turn ftrace_enabled ON and verify livepatch can load
# - verify that ftrace_enabled can't be turned OFF while a livepatch is loaded
+# (skipped on kernels where the sysctl is deprecated and always refuses 0)
start_test "livepatch interaction with ftrace_enabled sysctl"
-set_ftrace_enabled 0
-load_failing_mod $MOD_LIVEPATCH
+if ftrace_disable_supported; then
-set_ftrace_enabled 1
-load_lp $MOD_LIVEPATCH
-if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
- echo -e "FAIL\n\n"
- die "livepatch kselftest(s) failed"
-fi
+ set_ftrace_enabled 0
+ load_failing_mod $MOD_LIVEPATCH
-# Check that ftrace could not get disabled when a livepatch is enabled
-set_ftrace_enabled --fail 0
-if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
- echo -e "FAIL\n\n"
- die "livepatch kselftest(s) failed"
-fi
-disable_lp $MOD_LIVEPATCH
-unload_lp $MOD_LIVEPATCH
+ set_ftrace_enabled 1
+ load_lp $MOD_LIVEPATCH
+ if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
+ echo -e "FAIL\n\n"
+ die "livepatch kselftest(s) failed"
+ fi
-check_result "livepatch: kernel.ftrace_enabled = 0
+ # Check that ftrace could not get disabled when a livepatch is enabled
+ set_ftrace_enabled --fail 0
+ if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
+ echo -e "FAIL\n\n"
+ die "livepatch kselftest(s) failed"
+ fi
+ disable_lp $MOD_LIVEPATCH
+ unload_lp $MOD_LIVEPATCH
+
+ check_result "livepatch: kernel.ftrace_enabled = 0
% insmod test_modules/$MOD_LIVEPATCH.ko
livepatch: enabling patch '$MOD_LIVEPATCH'
livepatch: '$MOD_LIVEPATCH': initializing patching transition
@@ -60,6 +63,14 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
+else
+
+ set_ftrace_enabled --fail 0
+ check_result "livepatch: sysctl: setting key \"kernel.ftrace_enabled\": \
+Operation not supported"
+
+fi
+
# - verify livepatch can load
# - check if traces have a patched function
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-11 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 14:15 [for-next][PATCH 0/2] ftrace: Updates for v7.3 Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Steven Rostedt
2026-08-11 14:15 ` [for-next][PATCH 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox