ftracetest: Do not use usleep
PATCH 1/1 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
@@ -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
@@ -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.3
Quoted 8 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. 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 6 lines
Reported-by Michael Ellerman <[email protected]>Reported-by Dave Jones <[email protected]>Reported-by Luis Henriques <[email protected]>Tested-by Michael Ellerman <[email protected]>Signed-off-by Namhyung Kim <[email protected]>---
Hi Steve,
I will pull this in for 4.1. Assume that is ok. Just confirming.
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
Steven Rostedt
maintainerQuoted 7 lines · On Thu, 26 Mar 2015 09:32:23 +0900 Namhyung Kim <[email protected]> wrote:
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.
Note, opening "trace" via cat stops tracing. There is a possible race where the cat will not produce events. My worry is that if the shell implements its own "cat" command, it may not fork, and open the trace file. Which would not have any events in it, and opening it will disable the rest of the command from having events.
What about using:
ping localhost -c 1
?
-- Steve
Hi Steve,
Quoted 11 lines · Steven Rostedt
Quoted 7 lines · On Thu, 26 Mar 2015 09:32:23 +0900 Namhyung Kim <[email protected]> wrote:
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 5 lines
Note, opening "trace" via cat stops tracing. There is a possible race where the cat will not produce events. My worry is that if the shell implements its own "cat" command, it may not fork, and open the trace file. Which would not have any events in it, and opening it will disable the rest of the command from having events.
I understand your point. But this is not just cat, it needs grep and wc also. So I think there should be scheduler event(s).
Quoted 6 lines
What about using:
ping localhost -c 1
?
I'm okay with ping though but worried if some tiny system might lack the ping command..
Thanks,
Namhyung
Steven Rostedt
maintainerQuoted 3 lines · On Tue, 31 Mar 2015 09:48:55 +0900 Namhyung Kim <[email protected]> wrote:
I understand your point. But this is not just cat, it needs grep and wc also. So I think there should be scheduler event(s).
Yes, and cat opens 'trace', which will disable tracing, and if that happens before grep and wc, then those events will not show up.
There was a time when these tests use to fail without adding something to force a schedule, that's why I feel it's safe to add something.
-- Steve
Quoted 24 lines · Namhyung Kim
Hi Steve,
Quoted 11 lines · Steven Rostedt
Quoted 7 lines · On Thu, 26 Mar 2015 09:32:23 +0900 Namhyung Kim <[email protected]> wrote:
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 5 lines
Note, opening "trace" via cat stops tracing. There is a possible race where the cat will not produce events. My worry is that if the shell implements its own "cat" command, it may not fork, and open the trace file. Which would not have any events in it, and opening it will disable the rest of the command from having events.
I understand your point. But this is not just cat, it needs grep and wc also. So I think there should be scheduler event(s).
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
What about using:
ping localhost -c 1
?
I'm okay with ping though but worried if some tiny system might lack the ping command..
I'd use a fallback method like:
yield() { sleep .001 || usleep 1 || sleep 1; }Then just s/usleep 1/yield/
cheers,
Pádraig.
Steven Rostedt
maintainerQuoted 8 lines · On Tue, 31 Mar 2015 02:08:06 +0100 Pádraig Brady <[email protected]> wrote:
Quoted 2 lines
I'm okay with ping though but worried if some tiny system might lack the ping command..
I'd use a fallback method like:
yield() { sleep .001 || usleep 1 || sleep 1; }Then just s/usleep 1/yield/
yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; } ;-)
-- Steve