Skip to contentSkip to conversation

ftrace_stress_test: check if tracing_enabled is supported

PATCH New Chuyu Hu 3 participants 6 messages Dec 24, 2015 – Feb 5, 2016

lore
Share & tools
lore

Chuyu Hu

author
#0 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

When running the tests on RHEL7, got message as below:
---------
/mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 25: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied /mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 26: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied
---------

The reason is that the tracing_enabled file has been removed since kernel v3.8 by commits:

02404ba tracing: Remove deprecated tracing_enabled file 0fb9656 tracing: Make tracing_enabled be equal to tracing_on 6752ab4 tracing: Deprecate tracing_enabled for tracing_on

This workaround fix just uses a similar way of the original author:
1. check if the tracing_enabled is supported when save/restore the value of the file.
2. check if the tracing_enabled is supported in the trace_tracing_enabled.sh

---
 .../ftrace_stress/ftrace_tracing_enabled.sh                   | 11 +++++++++++
 .../kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh   | 10 ++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh +11 -0
index 69f2ae6..af83b19 100755
@@ -16,8 +16,19 @@
 MAX_LOOP=1500
 count=0
 
+if [ ! -e $TRACING_PATH/tracing_enabled ]; then
+	should_skip=1
+else
+	should_skip=0
+fi
+
 for ((; ;))
 {
+	if [ $should_skip -eq 1 ]; then
+		sleep 2
+		continue
+	fi
+
 	count=$(( $count + 1 ))
 
 	for ((i = 0; i < $MAX_LOOP; i++))
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh +8 -2
index 6a111e9..f36c835 100755
@@ -42,13 +42,16 @@ save_old_setting()
 
 	old_trace_options=( `cat trace_options` )
 	old_tracing_on=`cat tracing_on`
-	old_tracing_enabled=`cat tracing_enabled`
 	old_buffer_size=`cat buffer_size_kb`
 
 	if [ -e stack_max_size ]; then
 		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
 	fi
 
+	if [ -e tracing_enabled ]; then
+		old_tracing_enabled=`cat tracing_enabled`
+	fi
+
 	if [ -e "/proc/sys/kernel/ftrace_enabled" ]; then
 		old_ftrace_enabled=`cat /proc/sys/kernel/ftrace_enabled`
 	fi
@@ -85,9 +88,12 @@ restore_old_setting()
 		echo 0 > stack_max_size
 	fi
 
+	if [ -e tracing_enabled ]; then
+		echo $old_tracing_enabled > tracing_enabled
+	fi
+
 	echo $old_buffer_size > buffer_size_kb
 	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
 
 	for option in $old_trace_options
 	do
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

Hi!

Quoted 6 lines

When running the tests on RHEL7, got message as below:
---------
/mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 25: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied /mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 26: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied
---------

Quoted 6 lines

The reason is that the tracing_enabled file has been removed since kernel v3.8 by commits:

02404ba tracing: Remove deprecated tracing_enabled file 0fb9656 tracing: Make tracing_enabled be equal to tracing_on 6752ab4 tracing: Deprecate tracing_enabled for tracing_on

Looking at the commits shouldn't we use tracing_on instead of tracing_enabled on newer kernels?

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 9 lines

When running the tests on RHEL7, got message as below:
---------
/mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 25: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied /mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh: line 26: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled: Permission denied
---------

The reason is that the tracing_enabled file has been removed since kernel v3.8 by commits:

Quoted 7 lines
Quoted 3 lines

02404ba tracing: Remove deprecated tracing_enabled file 0fb9656 tracing: Make tracing_enabled be equal to tracing_on 6752ab4 tracing: Deprecate tracing_enabled for tracing_on

Looking at the commits shouldn't we use tracing_on instead of tracing_enabled on newer kernels?

Yes, and you should be using tracing_on even in older kernels. tracing_enabled has been deprecated for a long time now.

-- Steve

#3 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

Hi!

Quoted 6 lines
Quoted 3 lines

Looking at the commits shouldn't we use tracing_on instead of tracing_enabled on newer kernels?

Yes, and you should be using tracing_on even in older kernels. tracing_enabled has been deprecated for a long time now.

Also looking at the stress test all it does is writing to various files (in several background loops) that store tracing parameters. Is that even reasonable test? I guess that it can find out race conditions between functions that handle the write for the options...

And it uses the tracing_on file as well. So we can just skip starting the loop writes to the ftrace_enabled file if it's not present.

Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

Quoted 4 lines · Cyril Hrubis

Also looking at the stress test all it does is writing to various files (in several background loops) that store tracing parameters. Is that even reasonable test? I guess that it can find out race conditions between functions that handle the write for the options...

I don't use the LTP tests for ftrace, so I wouldn't know.

Quoted 4 lines

And it uses the tracing_on file as well. So we can just skip starting the loop writes to the ftrace_enabled file if it's not present.

ftrace_enabled is completely different. It disables function tracing capabilities (and should be avoided
if /sys/kernel/debug/tracing/options/function-trace is present. As that will only disable function hooks for tracing,
where /proc/sys/kernel/ftrace_enabled disables *all* hooks (including those for live kernel patching). Which I need to make a patch to prevent that :-/

-- Steve

author
#5 lore raw

PATCH 1/1 ftrace_stress_test: check if tracing_enabled is supported

In reply to Cyril Hrubis

Thanks & Regards
Name: Chunyu Hu (???)
Team: kernel QE --general
Phon: 8388193 , 861062608193
IRC : chunyu
Mail: [email protected]
Red Hat China R&D Branch (Raycom)

----- Original Message -----

Quoted 20 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chuyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Thursday, February 4, 2016 10:28:30 PM
Subject: Re: [LTP] [PATCH] ftrace_stress_test: check if tracing_enabled is supported

Hi!

Quoted 13 lines

When running the tests on RHEL7, got message as below:
---------
/mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh:
line 25: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled:
Permission denied /mnt/testarea/ltp/testcases/bin/ftrace_stress/ftrace_tracing_enabled.sh:
line 26: /mnt/testarea/ltp/testcases/bin/debugfs/tracing/tracing_enabled:
Permission denied
---------

The reason is that the tracing_enabled file has been removed since kernel v3.8 by commits:

Quoted 6 lines
Quoted 3 lines

02404ba tracing: Remove deprecated tracing_enabled file 0fb9656 tracing: Make tracing_enabled be equal to tracing_on 6752ab4 tracing: Deprecate tracing_enabled for tracing_on

Looking at the commits shouldn't we use tracing_on instead of tracing_enabled on newer kernels?

Hi,

Thanks for review.Each script in this case is just responsible for one trace file, In order to make this script aligned with the file name and other scripts in this case,I didn't switch the tracing_enabled to tracing_on in this script.It is just a light fix for avoiding the 'permission denied' warning log during testing.

There was a period that both the tracing_on and tracing_enabled exist in the tracing directory.So remain the ftrace_tracing_enabled.sh there just for testing the tracing_enabled file(through read/write parameter from/to the file) for old kernels that supported this.And let it check if its target test file is there before reading/writing against the file, if it's not there in new kernels,it will just keep sleeping in the loop. And we have another script to test the 'tracing_on'.

Quoted 4 lines

--
Cyril Hrubis
[email protected]