Skip to contentSkip to conversation

selftests: tracing: Fix to unmount tracefs for recovering environment

PATCH In review Masami Hiramatsu (Google) 4 participants 5 messages Sep 12, 2023 – Sep 13, 2023

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

PATCH v2 1/1 selftests: tracing: Fix to unmount tracefs for recovering environment

From: Masami Hiramatsu (Google) <[email protected]>

Fix to unmount the tracefs if the ftracetest mounted it for recovering system environment. If the tracefs is already mounted, this does nothing.

Fixes cbd965bde74c ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel")

---
Changes in v2:
- use -n option explictly for testing the string is non-zero.

---
 tools/testing/selftests/ftrace/ftracetest |    8 ++++++++
 1 file changed, 8 insertions(+)
tools/testing/selftests/ftrace/ftracetest +8 -0
index cb5f18c06593..d68264a5f3f0 100755
@@ -31,6 +31,9 @@ err_ret=1
 # kselftest skip code is 4
 err_skip=4
 
+# umount required
+UMOUNT_DIR=""
+
 # cgroup RT scheduling prevents chrt commands from succeeding, which
 # induces failures in test wakeup tests.  Disable for the duration of
 # the tests.
@@ -45,6 +48,9 @@ setup() {
 
 cleanup() {
   echo $sched_rt_runtime_orig > $sched_rt_runtime
+  if [ -n "${UMOUNT_DIR}" ]; then
+    umount ${UMOUNT_DIR} ||:
+  fi
 }
 
 errexit() { # message
@@ -160,11 +166,13 @@ if [ -z "$TRACING_DIR" ]; then
 	    mount -t tracefs nodev /sys/kernel/tracing ||
 	      errexit "Failed to mount /sys/kernel/tracing"
 	    TRACING_DIR="/sys/kernel/tracing"
+	    UMOUNT_DIR=${TRACING_DIR}
 	# If debugfs exists, then so does /sys/kernel/debug
 	elif [ -d "/sys/kernel/debug" ]; then
 	    mount -t debugfs nodev /sys/kernel/debug ||
 	      errexit "Failed to mount /sys/kernel/debug"
 	    TRACING_DIR="/sys/kernel/debug/tracing"
+	    UMOUNT_DIR=${TRACING_DIR}
 	else
 	    err_ret=$err_skip
 	    errexit "debugfs and tracefs are not configured in this kernel"
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · On Tue, 12 Sep 2023 10:10:39 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

Fix to unmount the tracefs if the ftracetest mounted it for recovering system environment. If the tracefs is already mounted, this does nothing.

Fixes cbd965bde74c ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel")
Quoted 5 lines

---
Changes in v2:
- use -n option explictly for testing the string is non-zero.
---
tool

-- Steve

maintainer
#2 lore raw
In reply to Steven Rostedt
Quoted 18 lines · Steven Rostedt
Quoted 9 lines · On Tue, 12 Sep 2023 10:10:39 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

Fix to unmount the tracefs if the ftracetest mounted it for recovering system environment. If the tracefs is already mounted, this does nothing.

Fixes cbd965bde74c ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel")
Quoted 5 lines

---
Changes in v2:
- use -n option explictly for testing the string is non-zero.
---
tool

Quoted 3 lines

-- Steve

Thank you all. Applied to linux-kselftest fixes branch for next rc

thanks,
-- Shuah

author maintainer
#3 lore raw
Quoted 19 lines · On Tue, 12 Sep 2023 09:35:58 -0600 Shuah Khan <[email protected]> wrote:
Quoted 18 lines · Steven Rostedt
Quoted 14 lines · On Tue, 12 Sep 2023 10:10:39 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

Fix to unmount the tracefs if the ftracetest mounted it for recovering system environment. If the tracefs is already mounted, this does nothing.

Fixes cbd965bde74c ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel")

---
Changes in v2:
- use -n option explictly for testing the string is non-zero.
---
tool

Quoted 6 lines
Quoted 3 lines

-- Steve

Thank you all. Applied to linux-kselftest fixes branch for next rc

Thanks Shuah!

Quoted 2 lines

thanks,
-- Shuah

Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>