* [RFC PATCH bpf-next v3 0/2] ftrace: deprecate the ftrace_enabled disable switch
@ 2026-08-06 15:29 Andrey Grodzovsky
2026-08-06 15:29 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl 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
0 siblings, 2 replies; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 15:29 UTC (permalink / raw)
To: bpf, linux-trace-kernel, live-patching, rostedt, mbenes
Cc: jolsa, mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet,
stable, linux-open-source
This addresses a long-standing issue: kernel.ftrace_enabled=0 silently
disables BPF trampolines (fentry/fexit) and ftrace-based
kprobes/kretprobes. The write succeeds, the hook stops firing with no
error, and re-enabling silently restores it.
The solution chosen is to deny setting this knob to 0 from userspace,
thus preventing this case in the first place. Steven mentioned that the
switch became effectively useless and doesn't serve any meaningful
purpose anymore, and only creates problems for systems that rely on
ftrace, such as Livepatching and eBPF. Any attempt to set it to 0 will
fail with -EOPNOTSUPP. Reading and writing 1 remain unchanged.
Patch 1: the sysctl change plus a doc note.
Patch 2: updates the one selftest that relied on the old disable
behavior.
The original patch-set was a fix to commit 00963a2e75a8 ("bpf: Support
bpf_trampoline on functions with IPMODIFY (e.g. livepatch)"), and so we
would want to see this backported at least to LTS branches starting
with 6.1. But since this is effectively a new behavior and not a bug
fix, I am not sure what the policy is in this case.
Changes since v2:
- Remove unused ftrace_shutdown_sysctl() and
is_permanent_ops_registered() functions entirely instead of keeping
them with __maybe_unused. (Steven)
- Fix ftrace_disable_supported() to save and restore the original
kernel.ftrace_enabled value instead of unconditionally forcing it to
1. (Joe)
[1] https://lore.kernel.org/bpf/20260731175358.3542156-1-andrey.grodzovsky@crowdstrike.com/
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 +++---------------
.../testing/selftests/livepatch/functions.sh | 14 ++++++
.../selftests/livepatch/test-ftrace.sh | 45 ++++++++++++-------
4 files changed, 53 insertions(+), 54 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
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
2026-08-06 15:41 ` sashiko-bot
2026-08-06 21:21 ` Song Liu
2026-08-06 15:30 ` [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Andrey Grodzovsky
1 sibling, 2 replies; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 15:29 UTC (permalink / raw)
To: bpf, linux-trace-kernel, live-patching, rostedt, mbenes
Cc: jolsa, mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet,
stable, linux-open-source
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
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 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
@ 2026-08-06 15:30 ` Andrey Grodzovsky
2026-08-06 21:18 ` Song Liu
1 sibling, 1 reply; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 15:30 UTC (permalink / raw)
To: bpf, linux-trace-kernel, live-patching, rostedt, mbenes
Cc: jolsa, mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet,
stable, linux-open-source
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.
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>
---
.../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.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
2026-08-06 15:29 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
@ 2026-08-06 15:41 ` sashiko-bot
2026-08-06 21:21 ` Song Liu
1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-08-06 15:41 UTC (permalink / raw)
To: Andrey Grodzovsky; +Cc: bpf
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The `kernel.ftrace_enabled` sysctl now returns `-EOPNOTSUPP` on writes of 0, but the livepatch kselftest was not updated to reflect this, causing the test suite to unconditionally abort.
- [Low] The `FTRACE_DISABLE_CALLS` macro and its handling branch are now dead code due to the removal of `ftrace_shutdown_sysctl()`.
--
--- Patch [1]: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl ---
commit 97db09d0e1892d04fd743e6e22b088914ffd3dd6
Author: Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com>
Subject: ftrace: deprecate disabling via ftrace_enabled sysctl
Writing 0 to kernel.ftrace_enabled is now deprecated and returns -EOPNOTSUPP,
as it has not reliably disabled ftrace for years. The patch updates the
sysctl handler to refuse the write, log a warning, and leaves reads and
enabling unaffected.
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> --- 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);
> - }
> -}
[Severity: Low]
Is FTRACE_DISABLE_CALLS now unused dead code?
The removed ftrace_shutdown_sysctl() function appears to be the only caller
that passes FTRACE_DISABLE_CALLS to ftrace_run_update_code().
Without it, the FTRACE_DISABLE_CALLS macro in include/linux/ftrace.h and
its corresponding handling branch in kernel/trace/ftrace.c might never be
executed:
kernel/trace/ftrace.c:ftrace_modify_all_code() {
...
else if (command & FTRACE_DISABLE_CALLS)
ftrace_replace_code(mod_flags);
...
}
Could we also clean up this macro and the dead branch?
[ ... ]
> @@ -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;
> }
[Severity: Medium]
Will this cause the livepatch kselftests to unconditionally fail?
The test script tools/testing/selftests/livepatch/test-ftrace.sh calls
set_ftrace_enabled() to disable ftrace:
tools/testing/selftests/livepatch/test-ftrace.sh:
set_ftrace_enabled 0
Since writing 0 now returns -EOPNOTSUPP, the helper in functions.sh catches
the failure and aborts the entire test script:
tools/testing/selftests/livepatch/functions.sh:set_ftrace_enabled() {
...
if ! echo "$1" > /proc/sys/kernel/ftrace_enabled; then
skip "failed to set kernel.ftrace_enabled = $1"
fi
...
}
Does the kselftest suite need to be updated alongside this change to avoid
breaking the tests?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806153000.4184871-1-andrey.grodzovsky@crowdstrike.com?part=1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
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
0 siblings, 1 reply; 10+ messages in thread
From: Song Liu @ 2026-08-06 21:18 UTC (permalink / raw)
To: Andrey Grodzovsky
Cc: bpf, linux-trace-kernel, live-patching, rostedt, mbenes, jolsa,
mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet, stable,
linux-open-source
On Thu, Aug 6, 2026 at 8:30 AM Andrey Grodzovsky
<andrey.grodzovsky@crowdstrike.com> wrote:
>
> 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.
>
> 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>
> ---
> .../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" ]]
> +}
Since the selftests are shipped with the kernel code, I think
we don't need to handle backward compatibility here. Instead,
we can just assume disabling ftrace is no longer supported.
Thanks,
Song
[...]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
2026-08-06 15:29 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
2026-08-06 15:41 ` sashiko-bot
@ 2026-08-06 21:21 ` Song Liu
2026-08-06 21:52 ` Andrey Grodzovsky
1 sibling, 1 reply; 10+ messages in thread
From: Song Liu @ 2026-08-06 21:21 UTC (permalink / raw)
To: Andrey Grodzovsky
Cc: bpf, linux-trace-kernel, live-patching, rostedt, mbenes, jolsa,
mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet, stable,
linux-open-source
On Thu, Aug 6, 2026 at 8:30 AM Andrey Grodzovsky
<andrey.grodzovsky@crowdstrike.com> wrote:
>
> 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>
Sashiko's comments make sense. Other than those:
Acked-by: Song Liu <song@kernel.org>
> ---
> Documentation/trace/ftrace.rst | 5 ++++
> kernel/trace/ftrace.c | 43 +++++-----------------------------
> 2 files changed, 11 insertions(+), 37 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
2026-08-06 21:18 ` Song Liu
@ 2026-08-06 21:45 ` Andrey Grodzovsky
2026-08-07 0:51 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 21:45 UTC (permalink / raw)
To: Song Liu
Cc: bpf, linux-trace-kernel, live-patching, rostedt, mbenes, jolsa,
mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet, stable,
linux-open-source
On Thu, Aug 6, 2026 at 5:18 PM Song Liu <song@kernel.org> wrote:
>
> On Thu, Aug 6, 2026 at 8:30 AM Andrey Grodzovsky
> <andrey.grodzovsky@crowdstrike.com> wrote:
> >
> > 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.
> >
> > 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>
> > ---
> > .../testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$ | 14 ++++++
> > .../selftests/livepatch/https://urldefense.com/v3/__http://test-ftrace.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj6oTNhr1$ | 45 ++++++++++++-------
> > 2 files changed, 42 insertions(+), 17 deletions(-)
> >
> > diff --git a/tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$ b/tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$
> > index 30dc677b2f45..a65b7b1ac8ad 100644
> > --- a/tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$
> > +++ b/tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$
> > @@ -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" ]]
> > +}
>
> Since the selftests are shipped with the kernel code, I think
> we don't need to handle backward compatibility here. Instead,
> we can just assume disabling ftrace is no longer supported.
>
> Thanks,
> Song
I tend to agree but I think here[1] Steve and Miroslav asked for
backward compatability. V1 was actually the way you prefer.
Andrey
[1] - https://lore.kernel.org/bpf/alpine.LSU.2.21.2607311104390.25165@pobox.suse.cz/
>
> [...]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl
2026-08-06 21:21 ` Song Liu
@ 2026-08-06 21:52 ` Andrey Grodzovsky
0 siblings, 0 replies; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 21:52 UTC (permalink / raw)
To: Song Liu, Steven Rostedt
Cc: bpf, linux-trace-kernel, live-patching, mbenes, jolsa, mhiramat,
jpoimboe, joe.lawrence, mark.rutland, corbet, stable,
linux-open-source
On Thu, Aug 6, 2026 at 5:22 PM Song Liu <song@kernel.org> wrote:
>
> On Thu, Aug 6, 2026 at 8:30 AM Andrey Grodzovsky
> <andrey.grodzovsky@crowdstrike.com> wrote:
> >
> > 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>
>
> Sashiko's comments make sense. Other than those:
>
The bot has 2 comments.
In my opinion, the test-breaking comment is wrong as he looked
strictly at this patch w/o reviewing the follow-up live patch testing
changes which update the tests to avoid breaks.
The cleanup comment is valid but since we aren't sure if we'll need to
revert this change later if it breaks userspace in some unseen way, I
wonder how extensive the cleanup should be? Steven, can you advise
please ?
Andrey
> Acked-by: Song Liu <song@kernel.org>
>
> > ---
> > Documentation/trace/ftrace.rst | 5 ++++
> > kernel/trace/ftrace.c | 43 +++++-----------------------------
> > 2 files changed, 11 insertions(+), 37 deletions(-)
> >
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
2026-08-06 21:45 ` Andrey Grodzovsky
@ 2026-08-07 0:51 ` Steven Rostedt
2026-08-07 7:17 ` Song Liu
0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2026-08-07 0:51 UTC (permalink / raw)
To: Andrey Grodzovsky
Cc: Song Liu, bpf, linux-trace-kernel, live-patching, mbenes, jolsa,
mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet, stable,
linux-open-source
On Thu, 6 Aug 2026 17:45:00 -0400
Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com> wrote:
> > Since the selftests are shipped with the kernel code, I think
> > we don't need to handle backward compatibility here. Instead,
> > we can just assume disabling ftrace is no longer supported.
Incorrect.
> >
> > Thanks,
> > Song
>
> I tend to agree but I think here[1] Steve and Miroslav asked for
> backward compatability. V1 was actually the way you prefer.
Right. We test older kernels (think LTS) with newer testing environments.
We need them to be backward compatible.
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled
2026-08-07 0:51 ` Steven Rostedt
@ 2026-08-07 7:17 ` Song Liu
0 siblings, 0 replies; 10+ messages in thread
From: Song Liu @ 2026-08-07 7:17 UTC (permalink / raw)
To: Steven Rostedt
Cc: Andrey Grodzovsky, bpf, linux-trace-kernel, live-patching, mbenes,
jolsa, mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet,
stable, linux-open-source
On Thu, Aug 6, 2026 at 5:51 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Thu, 6 Aug 2026 17:45:00 -0400
> Andrey Grodzovsky <andrey.grodzovsky@crowdstrike.com> wrote:
>
> > > Since the selftests are shipped with the kernel code, I think
> > > we don't need to handle backward compatibility here. Instead,
> > > we can just assume disabling ftrace is no longer supported.
>
> Incorrect.
>
> > >
> > > Thanks,
> > > Song
> >
> > I tend to agree but I think here[1] Steve and Miroslav asked for
> > backward compatability. V1 was actually the way you prefer.
>
> Right. We test older kernels (think LTS) with newer testing environments.
> We need them to be backward compatible.
Alternatively, we can test the LTS kernel with the selftests in the LTS tree.
I guess this alternative is not preferred because the selftests in the LTS
tree didn't have as good coverage as the newer selftests.
However, requiring compatibility in selftests has its own issues:
1) It makes writing and/or maintaining selftests harder. For example,
shall the selftest for a new feature fail or skip on older kernels.
Either way, some extra work is required to handle this, e.g.,
someone need to remember that this kernel-test combination is
expected to fail, and it is OK.
2) It delays the actual deprecation of a feature. IOW, the feature will
somehow stays in the selftests for much longer time.
Overall, I think requiring backward compatibility appears to be
attractive when we go from "having very little selftests" to
"having some selftest coverage". However, not requiring backward
compatibility will help us achieve better test coverage in the long run.
I hope this makes sense.
Thanks,
Song
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-08-07 7:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
2026-08-06 15:41 ` sashiko-bot
2026-08-06 21:21 ` Song Liu
2026-08-06 21:52 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox