2014-12-10 04:38:43

by Michael Ellerman

[permalink] [raw]
Subject: [PATCH] ftracetest: Replace usleep with sleep 0.000001

usleep is a Fedoraism, it's not generally available on Debian based
systems AFAICS.

GNU sleep accepts a floating point argument, so use that instead.

Signed-off-by: Michael Ellerman <[email protected]>
---
tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 6 +++---
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
index 668616d9bb03..c5343add3407 100644
--- a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
+++ b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
@@ -21,7 +21,7 @@ reset_tracer
do_reset

echo 'sched:sched_switch' > set_event
-usleep 1
+sleep 0.000001

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.000001

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.000001

count=`cat trace | grep sched_switch | wc -l`
if [ $count -ne 0 ]; then
diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
index 655c415b6e7f..84a2020d4e7b 100644
--- a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
+++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
@@ -21,7 +21,7 @@ reset_tracer
do_reset

echo 'sched:*' > set_event
-usleep 1
+sleep 0.000001

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.000001

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.000001

count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -ne 0 ]; then
--
1.9.1


2014-12-10 08:19:58

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

Hi Michael,

On Wed, Dec 10, 2014 at 1:38 PM, Michael Ellerman <[email protected]> wrote:
> usleep is a Fedoraism, it's not generally available on Debian based
> systems AFAICS.
>
> GNU sleep accepts a floating point argument, so use that instead.

I tested it on busybox not Debian, sorry. But it seems busybox's
sleep doesn't support floating point argument..

/ # ls -l `which sleep`
lrwxrwxrwx 1 root rooot 7 May 22 2014 /bin/sleep -> busybox

/ # sleep 0.1
sleep: invalid number '0.1'


Thanks,
Namhyung

Subject: Re: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

Hi,

(2014/12/10 17:19), Namhyung Kim wrote:
> Hi Michael,
>
> On Wed, Dec 10, 2014 at 1:38 PM, Michael Ellerman <[email protected]> wrote:
>> usleep is a Fedoraism, it's not generally available on Debian based
>> systems AFAICS.
>>
>> GNU sleep accepts a floating point argument, so use that instead.
>
> I tested it on busybox not Debian, sorry. But it seems busybox's
> sleep doesn't support floating point argument..
>
> / # ls -l `which sleep`
> lrwxrwxrwx 1 root rooot 7 May 22 2014 /bin/sleep -> busybox
>
> / # sleep 0.1
> sleep: invalid number '0.1'

I also have same result. Basically, ftracetest should be able to run on busybox.
So, I think we'd better check whether usleep is available, and if not, fallback
to sleep like as below.

if which usleep &> /dev/null; then
usleep 1
else
sleep 0.000001
fi

Thank you,


--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]

2014-12-11 23:39:39

by Michael Ellerman

[permalink] [raw]
Subject: Re: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Thu, 2014-12-11 at 14:12 +0900, Masami Hiramatsu wrote:
> Hi,
>
> (2014/12/10 17:19), Namhyung Kim wrote:
> > Hi Michael,
> >
> > On Wed, Dec 10, 2014 at 1:38 PM, Michael Ellerman <[email protected]> wrote:
> >> usleep is a Fedoraism, it's not generally available on Debian based
> >> systems AFAICS.
> >>
> >> GNU sleep accepts a floating point argument, so use that instead.
> >
> > I tested it on busybox not Debian, sorry. But it seems busybox's
> > sleep doesn't support floating point argument..
> >
> > / # ls -l `which sleep`
> > lrwxrwxrwx 1 root rooot 7 May 22 2014 /bin/sleep -> busybox
> >
> > / # sleep 0.1
> > sleep: invalid number '0.1'
>
> I also have same result. Basically, ftracetest should be able to run on busybox.

Yeah OK.

> So, I think we'd better check whether usleep is available, and if not, fallback
> to sleep like as below.
>
> if which usleep &> /dev/null; then
> usleep 1
> else
> sleep 0.000001
> fi

Why do we need to call (u)sleep anyway? It's generally a bad sign when tests
use sleep as it's asking for random timing related failures to creep in.

cheers

2014-12-20 20:42:18

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
> usleep is a Fedoraism, it's not generally available on Debian based
> systems AFAICS.
>
> GNU sleep accepts a floating point argument, so use that instead.
>
> Signed-off-by: Michael Ellerman <[email protected]>

Could ftrace user interface be enhanced not to need random delays?

Pavel

> ---
> tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 6 +++---
> tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
> index 668616d9bb03..c5343add3407 100644
> --- a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
> +++ b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
> @@ -21,7 +21,7 @@ reset_tracer
> do_reset
>
> echo 'sched:sched_switch' > set_event
> -usleep 1
> +sleep 0.000001
>
> 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.000001
>
> 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.000001
>
> count=`cat trace | grep sched_switch | wc -l`
> if [ $count -ne 0 ]; then
> diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> index 655c415b6e7f..84a2020d4e7b 100644
> --- a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> +++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> @@ -21,7 +21,7 @@ reset_tracer
> do_reset
>
> echo 'sched:*' > set_event
> -usleep 1
> +sleep 0.000001
>
> 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.000001
>
> 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.000001
>
> count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
> if [ $count -ne 0 ]; then

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2014-12-20 22:07:29

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Sat, 20 Dec 2014 21:42:13 +0100
Pavel Machek <[email protected]> wrote:

> On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
> > usleep is a Fedoraism, it's not generally available on Debian based
> > systems AFAICS.
> >
> > GNU sleep accepts a floating point argument, so use that instead.
> >
> > Signed-off-by: Michael Ellerman <[email protected]>
>
> Could ftrace user interface be enhanced not to need random delays?
>

Not sure what you are talking about. These "random delays" are not for
the interface, but instead to force some events to happen and to make
sure they did.

As the subject states, this is for "ftracetest" which is the selftests
for ftrace.

The usleep is basically a "do something to trigger events", and we
don't want to wait long in doing it.

-- Steve

2014-12-23 04:20:40

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Sat, Dec 20, 2014 at 05:07:25PM -0500, Steven Rostedt wrote:
> On Sat, 20 Dec 2014 21:42:13 +0100
> Pavel Machek <[email protected]> wrote:
>
> > On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
> > > usleep is a Fedoraism, it's not generally available on Debian based
> > > systems AFAICS.
> > >
> > > GNU sleep accepts a floating point argument, so use that instead.
> > >
> > > Signed-off-by: Michael Ellerman <[email protected]>
> >
> > Could ftrace user interface be enhanced not to need random delays?
> >
>
> Not sure what you are talking about. These "random delays" are not for
> the interface, but instead to force some events to happen and to make
> sure they did.
>
> As the subject states, this is for "ftracetest" which is the selftests
> for ftrace.
>
> The usleep is basically a "do something to trigger events", and we
> don't want to wait long in doing it.

Right. AFAIK what ftracetest expects is a scheduler event so it
doesn't need to be the [u]sleep.

Thanks,
Namhyung

2014-12-23 07:08:38

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Tue, 2014-12-23 at 13:21 +0900, Namhyung Kim wrote:
> On Sat, Dec 20, 2014 at 05:07:25PM -0500, Steven Rostedt wrote:
> > On Sat, 20 Dec 2014 21:42:13 +0100
> > Pavel Machek <[email protected]> wrote:
> >
> > > On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
> > > > usleep is a Fedoraism, it's not generally available on Debian based
> > > > systems AFAICS.
> > > >
> > > > GNU sleep accepts a floating point argument, so use that instead.
> > > >
> > > > Signed-off-by: Michael Ellerman <[email protected]>
> > >
> > > Could ftrace user interface be enhanced not to need random delays?
> > >
> >
> > Not sure what you are talking about. These "random delays" are not for
> > the interface, but instead to force some events to happen and to make
> > sure they did.
> >
> > As the subject states, this is for "ftracetest" which is the selftests
> > for ftrace.
> >
> > The usleep is basically a "do something to trigger events", and we
> > don't want to wait long in doing it.
>
> Right. AFAIK what ftracetest expects is a scheduler event so it
> doesn't need to be the [u]sleep.

Would /bin/true work in that case?

cheers

Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

(2014/12/23 16:08), Michael Ellerman wrote:
> On Tue, 2014-12-23 at 13:21 +0900, Namhyung Kim wrote:
>> On Sat, Dec 20, 2014 at 05:07:25PM -0500, Steven Rostedt wrote:
>>> On Sat, 20 Dec 2014 21:42:13 +0100
>>> Pavel Machek <[email protected]> wrote:
>>>
>>>> On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
>>>>> usleep is a Fedoraism, it's not generally available on Debian based
>>>>> systems AFAICS.
>>>>>
>>>>> GNU sleep accepts a floating point argument, so use that instead.
>>>>>
>>>>> Signed-off-by: Michael Ellerman <[email protected]>
>>>>
>>>> Could ftrace user interface be enhanced not to need random delays?
>>>>
>>>
>>> Not sure what you are talking about. These "random delays" are not for
>>> the interface, but instead to force some events to happen and to make
>>> sure they did.
>>>
>>> As the subject states, this is for "ftracetest" which is the selftests
>>> for ftrace.
>>>
>>> The usleep is basically a "do something to trigger events", and we
>>> don't want to wait long in doing it.
>>
>> Right. AFAIK what ftracetest expects is a scheduler event so it
>> doesn't need to be the [u]sleep.
>
> Would /bin/true work in that case?

As other scripts doing, just (echo "forked") would be enough. It forks
sub shell and wait for that.
Please check test.d/kprobe/kprobe_args.tc

Thanks!


--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]

2014-12-25 23:17:35

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] ftracetest: Replace usleep with sleep 0.000001

On Sat 2014-12-20 17:07:25, Steven Rostedt wrote:
> On Sat, 20 Dec 2014 21:42:13 +0100
> Pavel Machek <[email protected]> wrote:
>
> > On Wed 2014-12-10 15:38:27, Michael Ellerman wrote:
> > > usleep is a Fedoraism, it's not generally available on Debian based
> > > systems AFAICS.
> > >
> > > GNU sleep accepts a floating point argument, so use that instead.
> > >
> > > Signed-off-by: Michael Ellerman <[email protected]>
> >
> > Could ftrace user interface be enhanced not to need random delays?
> >
>
> Not sure what you are talking about. These "random delays" are not for
> the interface, but instead to force some events to happen and to make
> sure they did.
>
> As the subject states, this is for "ftracetest" which is the selftests
> for ftrace.
>
> The usleep is basically a "do something to trigger events", and we
> don't want to wait long in doing it.

Yep, I misunderstood, sorry.

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html