Skip to contentSkip to conversation

ftracetest: Do not use usleep directly

PATCH Superseded Namhyung Kim 4 participants 10 messages Apr 2, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ftracetest: Do not use usleep directly

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. It can be done various ways like this:

yield() { pinc localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }

---
 tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/subsystem-enable.tc       | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/toplevel-enable.tc        | 13 +++++++++++++
 3 files changed, 33 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +10 -3
index 668616d9bb03..c40c139aaf2b 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +10 -3
index 655c415b6e7f..cbd98b71ee8a 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +13 -0
index 480845774007..65e2ab666611 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,6 +25,9 @@ reset_tracer
 do_reset
 
 echo '*:*' > set_event
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -29,6 +36,9 @@ fi
 do_reset
 
 echo 1 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -37,6 +47,9 @@ fi
 do_reset
 
 echo 0 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -ne 0 ]; then
     fail "any of events should not be recorded"
Signature · 1 line
2.3.4
#1 lore raw

PATCH 1/1 ftracetest: Do not use usleep directly

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. It can be done various ways like this:

yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }

---
fix a typo of pinc

 tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/subsystem-enable.tc       | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/toplevel-enable.tc        | 13 +++++++++++++
 3 files changed, 33 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +10 -3
index 668616d9bb03..c40c139aaf2b 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +10 -3
index 655c415b6e7f..cbd98b71ee8a 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +13 -0
index 480845774007..65e2ab666611 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,6 +25,9 @@ reset_tracer
 do_reset
 
 echo '*:*' > set_event
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -29,6 +36,9 @@ fi
 do_reset
 
 echo 1 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -37,6 +47,9 @@ fi
 do_reset
 
 echo 0 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -ne 0 ]; then
     fail "any of events should not be recorded"
Signature · 1 line
2.3.4
Acked-by on v1 1/1
#2 lore raw
Quoted 7 lines · Namhyung Kim

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. It can be done various ways like this:

yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }

Nice hack! :)

Quoted 151 lines

---
fix a typo of pinc

 tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/subsystem-enable.tc       | 13 ++++++++++---
 .../selftests/ftrace/test.d/event/toplevel-enable.tc        | 13 +++++++++++++
 3 files changed, 33 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +10 -3
index 668616d9bb03..c40c139aaf2b 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:sched_switch' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -eq 0 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/sched_switch/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep sched_switch | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +10 -3
index 655c415b6e7f..cbd98b71ee8a 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f set_event -o ! -d events/sched ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer
 do_reset
 
 echo 'sched:*' > set_event
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -31,7 +36,8 @@ fi
 do_reset
 
 echo 1 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -lt 3 ]; then
@@ -41,7 +47,8 @@ fi
 do_reset
 
 echo 0 > events/sched/enable
-usleep 1
+
+yield
 
 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
 if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +13 -0
index 480845774007..65e2ab666611 100644
@@ -12,6 +12,10 @@ fail() { #msg
     exit -1
 }
 
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
 if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
     echo "event tracing is not supported"
     exit_unsupported
@@ -21,6 +25,9 @@ reset_tracer
 do_reset
 
 echo '*:*' > set_event
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -29,6 +36,9 @@ fi
 do_reset
 
 echo 1 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -eq 0 ]; then
     fail "none of events are recorded"
@@ -37,6 +47,9 @@ fi
 do_reset
 
 echo 0 > events/enable
+
+yield
+
 count=`cat trace | grep -v ^# | wc -l`
 if [ $count -ne 0 ]; then
     fail "any of events should not be recorded"
Signature · 5 lines
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: [email protected]
maintainer Acked-by
#3 lore raw
Quoted 10 lines · On Thu, 02 Apr 2015 14:58:04 +0900 Masami Hiramatsu…
Quoted 7 lines · Namhyung Kim

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. It can be done various ways like this:

yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }

Nice hack! :)

Yep, it was Pádraig Brady's idea.

Quoted 2 lines

-- Steve

Quoted 9 lines
Quoted 9 lines

---

#4 lore raw
Quoted 14 lines · Steven Rostedt
Quoted 10 lines · On Thu, 02 Apr 2015 14:58:04 +0900 Masami Hiramatsu…
Quoted 7 lines · Namhyung Kim

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. It can be done various ways like this:

yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }

Nice hack! :)

Quoted 15 lines

Yep, it was Pádraig Brady's idea.

Quoted 2 lines

-- Steve

Quoted 6 lines
Quoted 6 lines

Is this standard? checkpatch complained as non-standard. I am seeing some patches posted with Based-on-patch-by

Anyway, I have this patch tagged for 4.1-rc2

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
maintainer
#5 lore raw
Quoted 7 lines · On Thu, 02 Apr 2015 08:20:09 -0600 Shuah Khan <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Is this standard? checkpatch complained as non-standard. I am seeing some patches posted with Based-on-patch-by

I ignore checkpatch for things like this. It doesn't have a foggiest clue to what is standard. The only standard we truly have that counts is "Signed-off-by", as that's partially a legal thing. Everything else is info only.

This patch was based on a idea by Pádraig Brady and Namhyung is giving him credit.

Hmm, since I do not believe that Pádraig sent a patch, but only suggested the idea, the more "standard" tag, and actually more appropriate tag would be:

Also, we probably should add:

Which has more of a history for this patch.

Quoted 2 lines

Anyway, I have this patch tagged for 4.1-rc2

Why rc2?

-- Steve

#6 lore raw
Quoted 24 lines · Steven Rostedt
Quoted 7 lines · On Thu, 02 Apr 2015 08:20:09 -0600 Shuah Khan <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Is this standard? checkpatch complained as non-standard. I am seeing some patches posted with Based-on-patch-by

I ignore checkpatch for things like this. It doesn't have a foggiest clue to what is standard. The only standard we truly have that counts is "Signed-off-by", as that's partially a legal thing. Everything else is info only.

This patch was based on a idea by Pádraig Brady and Namhyung is giving him credit.

Hmm, since I do not believe that Pádraig sent a patch, but only suggested the idea, the more "standard" tag, and actually more appropriate tag would be:

Quoted 7 lines

Also, we probably should add:

Which has more of a history for this patch.

I added the following to the commit log:

For more information on the history of this patch, please refer to:

http://lkml.kernel.org/r/[email protected]

Quoted 5 lines
Quoted 3 lines

Anyway, I have this patch tagged for 4.1-rc2

Why rc2?

I usually let the patches stay in next for a few days before I send pull request. It is getting close to that, so decided on rc2 as a better choice.

We are at rc-6 at the moment, maybe there is enough time for this to get into rc-1

This patch has been in the works for a while now. Might as well get it in.

Bummer. Now this patch conflicts with the following commits:

ftracetest: Convert exit -1 to exit $FAIL
ftracetest: Add basic event tracing test cases

Applying: ftracetest: Do not use usleep directly
error: patch failed:
tools/testing/selftests/ftrace/test.d/event/event-enable.tc:12
error: tools/testing/selftests/ftrace/test.d/event/event-enable.tc:
patch does not apply
error: patch failed:
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc:12
error: tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc:
patch does not apply
error: patch failed:
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc:12
error: tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc:
patch does not apply

I could attempt to fix the conflicts, however prefer if you can rebase it on linux-kselftest next.

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
maintainer
#7 lore raw
Quoted 11 lines · On Thu, 02 Apr 2015 10:30:05 -0600 Shuah Khan <[email protected]> wrote:
Quoted 3 lines
Quoted 1 line

Anyway, I have this patch tagged for 4.1-rc2

Why rc2?

I usually let the patches stay in next for a few days before I send pull request. It is getting close to that, so decided on rc2 as a better choice.

We are at rc-6 at the moment, maybe there is enough time for this to get into rc-1

But the merge window closes at the rc1 release. Is this also a "stable" thing? It should be labeled as such if that's the case.

-- Steve

#8 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · On Thu, 02 Apr 2015 10:30:05 -0600 Shuah Khan <[email protected]> wrote:
Quoted 3 lines
Quoted 1 line

Anyway, I have this patch tagged for 4.1-rc2

Why rc2?

I usually let the patches stay in next for a few days before I send pull request. It is getting close to that, so decided on rc2 as a better choice.

Quoted 7 lines
Quoted 3 lines

We are at rc-6 at the moment, maybe there is enough time for this to get into rc-1

But the merge window closes at the rc1 release. Is this also a "stable" thing? It should be labeled as such if that's the case.

I am treating this as a fix so rc2 would be fine, however, if I can get the rebased patch soon I can take it in for rc1.

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
maintainer
#9 lore raw
Quoted 6 lines · On Thu, 02 Apr 2015 10:52:38 -0600 Shuah Khan <[email protected]> wrote:
Quoted 3 lines

But the merge window closes at the rc1 release. Is this also a "stable" thing? It should be labeled as such if that's the case.

I am treating this as a fix so rc2 would be fine, however, if I can get the rebased patch soon I can take it in for rc1.

That would need to come from Namhyung, who's in South Korea, and is probably in bed right now ;-)

-- Steve