Skip to contentSkip to conversation

ftrace: Updates for v7.3

PATCH New Steven Rostedt 1 participant 3 messages Aug 11

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

cover ftrace: Updates for v7.3

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(-)
#1 lore raw

PATCH 1/2 ftrace: deprecate disabling via ftrace_enabled sysctl

From: Andrey Grodzovsky <[email protected]>

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.53.0
#2 lore raw

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

In reply to Steven Rostedt

From: Andrey Grodzovsky <[email protected]>

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.

---
 .../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.53.0