Skip to contentSkip to conversation

ftrace: deprecate the ftrace_enabled disable switch

RFC PATCH In review Andrey Grodzovsky 6 participants 18 messages Aug 6 – Aug 25

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v3 cover ftrace: deprecate the ftrace_enabled disable switch

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/[email protected]/

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(-)
Signature · 1 line
2.34.1
#1 lore raw

RFC PATCH v3 1/2 ftrace: deprecate disabling via ftrace_enabled sysctl

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.

---
 Documentation/trace/ftrace.rst |  5 ++++
 kernel/trace/ftrace.c          | 43 +++++-----------------------------
 2 files changed, 11 insertions(+), 37 deletions(-)
Documentation/trace/ftrace.rst +5 -0
index 84f06bf0da9b..7261f25f8b4b 100644
@@ -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
kernel/trace/ftrace.c +6 -37

59 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

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…

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 <[email protected]>
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.

Quoted 12 lines
kernel/trace/ftrace.c +0 -5
@@ -9357,38 +9357,10 @@ static void ftrace_startup_sysctl(void)
 	}
 }
 
-static void ftrace_shutdown_sysctl(void)
-{
-	int command;
-
-	if (unlikely(ftrace_disabled))

kernel/trace/ftrace.c static void ftrace_startup_sysctl(void) · line 9374

Quoted 10 lines
kernel/trace/ftrace.c +0 -10
-		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?

[ ... ]

Quoted 10 lines
kernel/trace/ftrace.c +0 -6
@@ -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) */

kernel/trace/ftrace.c ftrace_enable_sysctl(const struct ctl_table *table, int write, · line 9396

Quoted 10 lines
kernel/trace/ftrace.c +6 -3
-		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?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Acked-by on v3 1/2
#3 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

In reply to Andrey Grodzovsky
Quoted 8 lines · Andrey Grodzovsky

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.

Quoted 4 lines

Update the docs to note the deprecation up front.

Sashiko's comments make sense. Other than those:

Quoted 5 lines
---
 Documentation/trace/ftrace.rst |  5 ++++
 kernel/trace/ftrace.c          | 43 +++++-----------------------------
 2 files changed, 11 insertions(+), 37 deletions(-)
#4 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

Quoted 11 lines · Song Liu
Quoted 8 lines · Andrey Grodzovsky

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.

Quoted 7 lines
Quoted 4 lines

Update the docs to note the deprecation up front.

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

Quoted 7 lines
Quoted 5 lines
---
 Documentation/trace/ftrace.rst |  5 ++++
 kernel/trace/ftrace.c          | 43 +++++-----------------------------
 2 files changed, 11 insertions(+), 37 deletions(-)
#5 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

Quoted 27 lines · Andrey Grodzovsky
Quoted 11 lines · Song Liu
Quoted 8 lines · Andrey Grodzovsky

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.

Quoted 7 lines
Quoted 4 lines

Update the docs to note the deprecation up front.

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.

Quoted 6 lines

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

Gentle ping on this question above Steven.

Andrey

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
---
 Documentation/trace/ftrace.rst |  5 ++++
 kernel/trace/ftrace.c          | 43 +++++-----------------------------
 2 files changed, 11 insertions(+), 37 deletions(-)
maintainer
#6 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

Quoted 11 lines · Andrey Grodzovsky
Quoted 8 lines · Andrey Grodzovsky

On Thu, Aug 6, 2026 at 5:22 PM Song Liu <[email protected]> wrote:

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.

Quoted 8 lines
Quoted 6 lines

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

Gentle ping on this question above Steven.

I am not Steven but I think we should wait with the cleanup exactly due to a possible revert. The same as for PERMANENT flag we talked about elsewhere.

maintainer Reviewed-by on v3 1/2
#7 lore raw

Re: [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl

In reply to Andrey Grodzovsky
Quoted 8 lines · Andrey Grodzovsky

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.

[...]

Signature · 1 line
Miroslav
#8 lore raw

RFC PATCH v3 2/2 selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

In reply to Andrey Grodzovsky

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.

Assisted-by Claude:claude-sonnet-5
---
 .../testing/selftests/livepatch/functions.sh  | 14 ++++++
 .../selftests/livepatch/test-ftrace.sh        | 45 ++++++++++++-------
 2 files changed, 42 insertions(+), 17 deletions(-)
tools/testing/selftests/livepatch/functions.sh +14 -0
index 30dc677b2f45..a65b7b1ac8ad 100644
@@ -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
 }
tools/testing/selftests/livepatch/test-ftrace.sh +28 -17

63 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#9 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 28 lines · Andrey Grodzovsky

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.

Assisted-by Claude:claude-sonnet-5
---
 .../testing/selftests/livepatch/functions.sh  | 14 ++++++
 .../selftests/livepatch/test-ftrace.sh        | 45 ++++++++++++-------
 2 files changed, 42 insertions(+), 17 deletions(-)
tools/testing/selftests/livepatch/functions.sh +3 -0
index 30dc677b2f45..a65b7b1ac8ad 100644
@@ -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.

tools/testing/selftests/livepatch/functions.sh function set_ftrace_enabled() { · line 141

Quoted 10 lines
tools/testing/selftests/livepatch/functions.sh +10 -0
+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

[...]

#10 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 46 lines · Song Liu
Quoted 28 lines · Andrey Grodzovsky

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.

Assisted-by Claude:claude-sonnet-5
---
 .../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(-)
tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$ +3 -0
index 30dc677b2f45..a65b7b1ac8ad 100644
@@ -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.

tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$ function set_ftrace_enabled() { · line 141

Quoted 10 lines
tools/testing/selftests/livepatch/https://urldefense.com/v3/__http://functions.sh__;!!BmdzS3_lV9HdKG8!0iHqKyQrLfspbt4sQvekjrQjWLuiSTtsCXR9obFozOCSUhPg1KCQGTvfgZ9oTwgBkdB3nKZA1RCYtwwYj2qtEXgW$ +10 -0
+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.

Quoted 2 lines

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/[email protected]/

Quoted 2 lines

[...]

maintainer
#11 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 3 lines · On Thu, 6 Aug 2026 17:45:00 -0400 Andrey Grodzovsky…
Quoted 3 lines

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.

Quoted 6 lines
Quoted 3 lines

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

maintainer
#12 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 11 lines · Steven Rostedt
Quoted 3 lines · On Thu, 6 Aug 2026 17:45:00 -0400 Andrey Grodzovsky…
Quoted 3 lines

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.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

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

maintainer
#13 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 5 lines · On Fri, 7 Aug 2026 00:17:27 -0700 Song Liu <[email protected]> wrote:

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.

Skip. It's a feature of our test suite.

Quoted 3 lines

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.

We explicitly require that new features are detectable (sometimes by just updating /sys/kernel/tracing/README). The ftracetests has a way to see the dependencies to know if a test should be run or not.

We have a "requires:" field at the top of every test case. For example, in test.d/filter/event-filter-function.tc:

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event filter function - test event filtering on functions # requires: set_event events/kmem/kmem_cache_free/filter
# flags: instance

If "set_event" or "events/kmem/kmem_cache_free/filter" does not exist, the test will be skipped.

Quoted 2 lines

2) It delays the actual deprecation of a feature. IOW, the feature will somehow stays in the selftests for much longer time.

We do not deprecate features. tracefs code is user API. We do not break user space. The ftrace_enabled is something that is being removed because it is broken to begin with. In fact, if we find out that anything depends on ftrace_enabled, we need to revert the change that disabled it.

The removal of ftrace_enabled is the exception and not the rule.

Quoted 5 lines

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.

The ftrace selftest requirements are different than the BPF requirements. We have been supporting this since 2014 without issue. And have actually found making things backward compatible helpful. We are not going to change that.

I hope that makes sense.

-- Steve

maintainer
#14 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Hi Steven,

Thanks for sharing your experience!

Quoted 3 lines · Steven Rostedt

On Fri, 7 Aug 2026 00:17:27 -0700
Song Liu <[email protected]> wrote:

[...]

Quoted 8 lines

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event filter function - test event filtering on functions # requires: set_event events/kmem/kmem_cache_free/filter
# flags: instance

If "set_event" or "events/kmem/kmem_cache_free/filter" does not exist, the test will be skipped.

Hmm.. If a bug somehow causes set_event to disappear, this test will be skipped by accident, no? These types of bugs are not common though.

Quoted 10 lines
Quoted 3 lines

2) It delays the actual deprecation of a feature. IOW, the feature will somehow stays in the selftests for much longer time.

We do not deprecate features. tracefs code is user API. We do not break user space. The ftrace_enabled is something that is being removed because it is broken to begin with. In fact, if we find out that anything depends on ftrace_enabled, we need to revert the change that disabled it.

The removal of ftrace_enabled is the exception and not the rule.

Agreed that ftrace APIs need to be very stable, as there are many out of tree users. OTOH, I think livepatch can afford breaking some compatibility.

Quoted 9 lines
Quoted 4 lines

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.

The ftrace selftest requirements are different than the BPF requirements. We have been supporting this since 2014 without issue. And have actually found making things backward compatible helpful. We are not going to change that.

With mature selftests, I guess testing LTS kernels with the selftests shipped with them is still a valid option? I guess this is up to the folks who run these tests.

In this specific case, given the logic is not that complex, I agree we can maintain the compatibility,

Thanks,
Song

maintainer
#15 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

Quoted 10 lines
Quoted 6 lines

We do not deprecate features. tracefs code is user API. We do not break user space. The ftrace_enabled is something that is being removed because it is broken to begin with. In fact, if we find out that anything depends on ftrace_enabled, we need to revert the change that disabled it.

The removal of ftrace_enabled is the exception and not the rule.

Agreed that ftrace APIs need to be very stable, as there are many out of tree users. OTOH, I think livepatch can afford breaking some compatibility.

We discussed that a bit in the context of this patch set [1]. I think it is valuable to have the kselftests backward compatibility but there is of course some limit to it. We can talk about it at Plumbers during the backward compatibility session as well [2].

Miroslav

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lpc.events/event/20/contributions/2530/

maintainer Acked-by on v3 2/2
#16 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

In reply to Andrey Grodzovsky
Quoted 8 lines · Andrey Grodzovsky

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.

[...]

Signature · 1 line
Miroslav
maintainer Reviewed-by Tested-by on v3 2/2
#17 lore raw

Re: [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled

In reply to Andrey Grodzovsky
Quoted 11 lines · Andrey Grodzovsky

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.

Assisted-by Claude:claude-sonnet-5

It seems that this has already reached mainline. Anyway, for record, it looks good and seems to work as expected:

Best Regards,
Petr