Skip to contentSkip to conversation

Remove redhat'ism from ftrace selftests.

PATCH In review Dave Jones 5 participants 13 messages Feb 24, 2015 – Mar 5, 2015

Subsystems (2)
lore
Share & tools
lore

Dave Jones

author
#0 lore raw

PATCH 1/1 Remove redhat'ism from ftrace selftests.

usleep(1) is a Red Hat'ism (bizarrely provided by initscripts), that isn't available on other distributions.
To make this work elsewhere, convert to using fractional shell sleeps.

tools/testing/selftests/ftrace/test.d/event/event-enable.tc +3 -3
index 668616d9bb03..ecc74d801b97 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +3 -3
index 655c415b6e7f..019766c59db2 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
maintainer Acked-by on v1 1/1
#1 lore raw

Shuah,

Can you take this in your tree?

Quoted 7 lines · On Tue, 24 Feb 2015 11:19:27 -0500 Dave Jones <[email protected]> wrote:

usleep(1) is a Red Hat'ism (bizarrely provided by initscripts), that isn't available on other distributions.
To make this work elsewhere, convert to using fractional shell sleeps.

-- Steve

Quoted 62 lines
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +3 -3
index 668616d9bb03..ecc74d801b97 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +3 -3
index 655c415b6e7f..019766c59db2 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
#2 lore raw
Quoted 4 lines · Steven Rostedt

Shuah,

Can you take this in your tree?

Yes I can do that. This must be the original patch email:
https://lkml.org/lkml/2015/2/24/435

-- Shuah

Quoted 79 lines
Quoted 7 lines · On Tue, 24 Feb 2015 11:19:27 -0500 Dave Jones <[email protected]> wrote:

usleep(1) is a Red Hat'ism (bizarrely provided by initscripts), that isn't available on other distributions.
To make this work elsewhere, convert to using fractional shell sleeps.

-- Steve

Quoted 62 lines
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +3 -3
index 668616d9bb03..ecc74d801b97 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +3 -3
index 655c415b6e7f..019766c59db2 100644
@@ -21,7 +21,7 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +31,7 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +41,7 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+sleep 0.1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#5 lore raw
Quoted 13 lines · Namhyung Kim

Hi,

Quoted 9 lines · Dave Jones
Quoted 8 lines · Shuah Khan
Quoted 4 lines · Steven Rostedt

Shuah,

Can you take this in your tree?

Yes I can do that. This must be the original patch email:
https://lkml.org/lkml/2015/2/24/435

Quoted 8 lines

Please see below links:

https://lkml.org/lkml/2014/12/10/52
https://lkml.org/lkml/2014/12/22/556

I think we can get rid of the (u)sleeps entirely since 'cat trace' itself should trigger scheduler events.

Steve/Dave,

Still good to take it through. The discussion in the threads Namhyung Kim pointed to seem to be inconclusive.

The only difference between the original patch
https://lkml.org/lkml/2014/12/9/780
and
https://lkml.org/lkml/2015/2/24/435

is sleep duration change. I can take through my tree
https://lkml.org/lkml/2015/2/24/435

just confirming.

-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#6 lore raw
Quoted 30 lines · Shuah Khan
Quoted 11 lines · Namhyung Kim
Quoted 9 lines · Dave Jones
Quoted 8 lines · Shuah Khan
Quoted 4 lines · Steven Rostedt

Shuah,

Can you take this in your tree?

Yes I can do that. This must be the original patch email:
https://lkml.org/lkml/2015/2/24/435

Quoted 7 lines

Please see below links:

https://lkml.org/lkml/2014/12/10/52
https://lkml.org/lkml/2014/12/22/556

I think we can get rid of the (u)sleeps entirely since 'cat trace' itself should trigger scheduler events.

Steve/Dave,

Still good to take it through. The discussion in the threads Namhyung Kim pointed to seem to be inconclusive.

The only difference between the original patch
https://lkml.org/lkml/2014/12/9/780
and
https://lkml.org/lkml/2015/2/24/435

Quoted 4 lines

is sleep duration change. I can take through my tree
https://lkml.org/lkml/2015/2/24/435

just confirming.

No, the resoultion was that busybox doesn't support fractional sleeps and so using them is not a solution.

I thought /bin/true would work, but never got around to testing it. The other option was to use (echo "forked"):

https://lkml.org/lkml/2014/12/23/447

cheers

#7 lore raw

Hello,

Quoted 36 lines · Michael Ellerman
Quoted 30 lines · Shuah Khan
Quoted 11 lines · Namhyung Kim
Quoted 9 lines · Dave Jones
Quoted 8 lines · Shuah Khan
Quoted 4 lines · Steven Rostedt

Shuah,

Can you take this in your tree?

Yes I can do that. This must be the original patch email:
https://lkml.org/lkml/2015/2/24/435

Quoted 7 lines

Please see below links:

https://lkml.org/lkml/2014/12/10/52
https://lkml.org/lkml/2014/12/22/556

I think we can get rid of the (u)sleeps entirely since 'cat trace' itself should trigger scheduler events.

Steve/Dave,

Still good to take it through. The discussion in the threads Namhyung Kim pointed to seem to be inconclusive.

The only difference between the original patch
https://lkml.org/lkml/2014/12/9/780
and
https://lkml.org/lkml/2015/2/24/435

Quoted 4 lines

is sleep duration change. I can take through my tree
https://lkml.org/lkml/2015/2/24/435

just confirming.

Quoted 7 lines

No, the resoultion was that busybox doesn't support fractional sleeps and so using them is not a solution.

I thought /bin/true would work, but never got around to testing it. The other option was to use (echo "forked"):

https://lkml.org/lkml/2014/12/23/447

I think that there's no need to even call true or echo..

Quoted 1 line

From 0549544e8e982df6478f11e2b4fe419f94c22434 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Wed, 4 Mar 2015 21:26:38 +0900
Subject: [PATCH] ftracetest: Do not use usleep

The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.

The reason of using [u]sleep in the test was to generate (scheduler) events. But as we use 'cat trace | grep | wc -l' to read the events, the command themselves already generate some events before reading the trace file so no need to call [u]sleep explicitly.

---
 tools/testing/selftests/ftrace/test.d/event/event-enable.tc     | 3 ---
 tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | 3 ---
 2 files changed, 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +0 -3
index 668616d9bb03..7c7b4ce383a3 100644
@@ -21,7 +21,6 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +30,6 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +39,6 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +0 -3
index 655c415b6e7f..08a9459224b0 100644
@@ -21,7 +21,6 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +30,6 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +39,6 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
Signature · 1 line
2.3.1
#8 lore raw
Quoted 11 lines · Namhyung Kim

I think that there's no need to even call true or echo..

From 0549544e8e982df6478f11e2b4fe419f94c22434 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Wed, 4 Mar 2015 21:26:38 +0900
Subject: [PATCH] ftracetest: Do not use usleep

The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.

Quoted 8 lines

The reason of using [u]sleep in the test was to generate (scheduler) events. But as we use 'cat trace | grep | wc -l' to read the events, the command themselves already generate some events before reading the trace file so no need to call [u]sleep explicitly.

Thanks, this is working for me.

$ cat /etc/issue
Ubuntu 14.10 \n \l
$ git log -2 --pretty=oneline
385a914624fc9fb6d0ccc3d2fd3a12ebd1ece7dd ftracetest: Do not use usleep
a6c5170d1edea97c538c81e377e56c7b5c5b7e63 Merge branch 'for-4.0' of git://linux-nfs.org/~bfields/linux
$ sudo ./ftracetest 
=== Ftrace unit tests ===
[1] Basic trace file check	[PASS]
[2] Basic test for tracers	[PASS]
[3] Basic trace clock test	[PASS]
[4] Basic event tracing check	[PASS]
[5] event tracing - enable/disable with event level files	[PASS]
[6] event tracing - enable/disable with subsystem level files	[PASS]
[7] event tracing - enable/disable with top level files	[PASS]
[8] ftrace - function graph filters with stack tracer	[PASS]
[9] ftrace - function graph filters	[PASS]
[10] ftrace - function profiler with function tracing	[PASS]
[11] Kprobe dynamic event - adding and removing	[PASS]
[12] Kprobe dynamic event - busy event check	[PASS]
[13] Kprobe dynamic event with arguments	[PASS]
[14] Kprobe dynamic event with function tracer	[PASS]
[15] Kretprobe dynamic event with arguments	[PASS]
# of passed:  15
# of failed:  0
# of unresolved:  0
# of untested:  0
# of unsupported:  0
# of xfailed:  0
# of undefined(test bug):  0

cheers

#9 lore raw
Quoted 17 lines · Michael Ellerman
Quoted 16 lines · Namhyung Kim

I think that there's no need to even call true or echo..

From 0549544e8e982df6478f11e2b4fe419f94c22434 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Wed, 4 Mar 2015 21:26:38 +0900
Subject: [PATCH] ftracetest: Do not use usleep

The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.

The reason of using [u]sleep in the test was to generate (scheduler) events. But as we use 'cat trace | grep | wc -l' to read the events, the command themselves already generate some events before reading the trace file so no need to call [u]sleep explicitly.

Quoted 8 lines
Quoted 3 lines

Thanks, this is working for me.

Steve,

Do you want to make a call on which one you want me to take it through between these two patches - one from Dave and the other from Namhyung Kim.

Please send me the patch I have to pull in. Namhyung Kim's patch isn't in the format I can apply and I don't have Dave's patch in my inbox.

thanks,
-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
author
#10 lore raw
Quoted 29 lines · Shuah Khan
Quoted 17 lines · Michael Ellerman
Quoted 16 lines · Namhyung Kim

I think that there's no need to even call true or echo..

From 0549544e8e982df6478f11e2b4fe419f94c22434 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Wed, 4 Mar 2015 21:26:38 +0900
Subject: [PATCH] ftracetest: Do not use usleep

The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.

The reason of using [u]sleep in the test was to generate (scheduler) events. But as we use 'cat trace | grep | wc -l' to read the events, the command themselves already generate some events before reading the trace file so no need to call [u]sleep explicitly.

Quoted 8 lines
Quoted 3 lines

Thanks, this is working for me.

Steve,

Quoted 7 lines

Do you want to make a call on which one you want me to take it through between these two patches - one from Dave and the other from Namhyung Kim.

Please send me the patch I have to pull in. Namhyung Kim's patch isn't in the format I can apply and I don't have Dave's patch in my inbox.

Removing it entirely sounds like a much better choice, so I'd wait for Namhyung to resend.

Dave

maintainer
#11 lore raw
Quoted 2 lines · On Thu, 5 Mar 2015 10:17:04 -0500 Dave Jones <[email protected]> wrote:

Removing it entirely sounds like a much better choice, so I'd wait for Namhyung to resend.

Removing or just doing something small may be better. Those sleeps were added to my original tests because it sometimes had false failures.

But that was a long time ago. Maybe they are not needed. It really doesn't matter much to me, as long as there's no false failures. I'm still running my original tests.

-- Steve

maintainer
#12 lore raw
In reply to Namhyung Kim
Quoted 1 line · On Wed, 4 Mar 2015 21:44:57 +0900 Namhyung Kim <[email protected]> wrote:

I think that there's no need to even call true or echo..

Ideally it shouldn't. But I if you noticed it expects 3 or more events in some cases. I believe without the sleep it would sometimes fail that.

Is there a small command we can run just to do something? I rather have that then nothing at all. I added those sleeps a while ago (in my original tests), because every so often it would fail a test due to not enough going on.

-- Steve