2008-11-27 15:21:41

by walimis

[permalink] [raw]
Subject: about use wild cards for set_ftrace_filter and so on

Hi Steven and Ingo,

I encountered an issue when using ftrace.
We know that we can use wild cards to set set_ftrace_filter, but there's
problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
If there are files named with "h" prefix in current directory, echo "h*"
will echo these files' name to set_ftrace_filter, not "h*".
For example:

#cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
23
#ls
#touch hraa hrdd
#ls
hraa hrdd
#echo hr* > /debug/tracing/set_ftrace_filter
#cat /debug/tracing/set_ftrace_filter

No output in /debug/tracing/set_ftrace_filter!
If we use "" to enclose wild cards, it works:

#ls
hraa hrdd
#echo "hr*" > /debug/tracing/set_ftrace_filter
#cat /debug/tracing/set_ftrace_filter |wc -l
23

This problem can lead to unexpected result if current directory has a
lot of files.
I suppose that we can add some notes to document, so a patch attached.


Attachments:
(No filename) (911.00 B)
0001-Impact-imporve-document.patch (626.00 B)
Download all attachments

2008-11-27 15:34:30

by Steven Rostedt

[permalink] [raw]
Subject: Re: about use wild cards for set_ftrace_filter and so on


On Thu, 27 Nov 2008, walimis wrote:

>
> I encountered an issue when using ftrace.
> We know that we can use wild cards to set set_ftrace_filter, but there's
> problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
> If there are files named with "h" prefix in current directory, echo "h*"
> will echo these files' name to set_ftrace_filter, not "h*".
> For example:
>
> #cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
> 23
> #ls
> #touch hraa hrdd
> #ls
> hraa hrdd
> #echo hr* > /debug/tracing/set_ftrace_filter
> #cat /debug/tracing/set_ftrace_filter
>
> No output in /debug/tracing/set_ftrace_filter!
> If we use "" to enclose wild cards, it works:
>
> #ls
> hraa hrdd
> #echo "hr*" > /debug/tracing/set_ftrace_filter
> #cat /debug/tracing/set_ftrace_filter |wc -l
> 23
>
> This problem can lead to unexpected result if current directory has a
> lot of files.
> I suppose that we can add some notes to document, so a patch attached.

Using TB? It's best to inline the patch, that way I can comment on it
better.

Anyway, you should fix the example. I also recommend a single quote over
double, to prevent any other translation that bash might do.

The example in ftrace.txt should be:

# echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter


Thanks,

-- Steve

/me goes back to eating turkeys.

2008-11-27 15:51:08

by walimis

[permalink] [raw]
Subject: Re: about use wild cards for set_ftrace_filter and so on

On Thu, Nov 27, 2008 at 10:34:19AM -0500, Steven Rostedt wrote:
>
>On Thu, 27 Nov 2008, walimis wrote:
>
>>
>> I encountered an issue when using ftrace.
>> We know that we can use wild cards to set set_ftrace_filter, but there's
>> problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
>> If there are files named with "h" prefix in current directory, echo "h*"
>> will echo these files' name to set_ftrace_filter, not "h*".
>> For example:
>>
>> #cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
>> 23
>> #ls
>> #touch hraa hrdd
>> #ls
>> hraa hrdd
>> #echo hr* > /debug/tracing/set_ftrace_filter
>> #cat /debug/tracing/set_ftrace_filter
>>
>> No output in /debug/tracing/set_ftrace_filter!
>> If we use "" to enclose wild cards, it works:
>>
>> #ls
>> hraa hrdd
>> #echo "hr*" > /debug/tracing/set_ftrace_filter
>> #cat /debug/tracing/set_ftrace_filter |wc -l
>> 23
>>
>> This problem can lead to unexpected result if current directory has a
>> lot of files.
>> I suppose that we can add some notes to document, so a patch attached.
>
>Using TB? It's best to inline the patch, that way I can comment on it
>better.
Using mutt, but I don't know how to inline the patch now.

>
>Anyway, you should fix the example. I also recommend a single quote over
>double, to prevent any other translation that bash might do.
>
>The example in ftrace.txt should be:
>
> # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter
>
>
>Thanks,
>
>-- Steve
>
>/me goes back to eating turkeys.
I only add a note, but I wonder whether enough.
If needed, I can add a example to this document.

Impact: imporve document

Signed-off-by: walimis <[email protected]>
---
Documentation/ftrace.txt | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index de05042..9735434 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -1251,6 +1251,9 @@ These are the only wild cards which are supported.

<match>*<match> will not work.

+Note: you'd better to use '' to enclose wild cards, otherwise in some
+case you can't get the correct result.
+
# echo hrtimer_* > /debug/tracing/set_ftrace_filter

Produces:
--
1.6.0.3

2008-11-27 15:58:20

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: about use wild cards for set_ftrace_filter and so on

2008/11/27 walimis <[email protected]>:
> On Thu, Nov 27, 2008 at 10:34:19AM -0500, Steven Rostedt wrote:
>>
>>On Thu, 27 Nov 2008, walimis wrote:
>>
>>>
>>> I encountered an issue when using ftrace.
>>> We know that we can use wild cards to set set_ftrace_filter, but there's
>>> problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
>>> If there are files named with "h" prefix in current directory, echo "h*"
>>> will echo these files' name to set_ftrace_filter, not "h*".
>>> For example:
>>>
>>> #cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
>>> 23
>>> #ls
>>> #touch hraa hrdd
>>> #ls
>>> hraa hrdd
>>> #echo hr* > /debug/tracing/set_ftrace_filter
>>> #cat /debug/tracing/set_ftrace_filter
>>>
>>> No output in /debug/tracing/set_ftrace_filter!
>>> If we use "" to enclose wild cards, it works:
>>>
>>> #ls
>>> hraa hrdd
>>> #echo "hr*" > /debug/tracing/set_ftrace_filter
>>> #cat /debug/tracing/set_ftrace_filter |wc -l
>>> 23
>>>
>>> This problem can lead to unexpected result if current directory has a
>>> lot of files.
>>> I suppose that we can add some notes to document, so a patch attached.
>>
>>Using TB? It's best to inline the patch, that way I can comment on it
>>better.
> Using mutt, but I don't know how to inline the patch now.
>
>>
>>Anyway, you should fix the example. I also recommend a single quote over
>>double, to prevent any other translation that bash might do.
>>
>>The example in ftrace.txt should be:
>>
>> # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter
>>
>>
>>Thanks,
>>
>>-- Steve
>>
>>/me goes back to eating turkeys.
> I only add a note, but I wonder whether enough.
> If needed, I can add a example to this document.
>
> Impact: imporve document
>
> Signed-off-by: walimis <[email protected]>
> ---
> Documentation/ftrace.txt | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
> index de05042..9735434 100644
> --- a/Documentation/ftrace.txt
> +++ b/Documentation/ftrace.txt
> @@ -1251,6 +1251,9 @@ These are the only wild cards which are supported.
>
> <match>*<match> will not work.
>
> +Note: you'd better to use '' to enclose wild cards, otherwise in some
> +case you can't get the correct result.
> +
> # echo hrtimer_* > /debug/tracing/set_ftrace_filter
>
> Produces:
> --
> 1.6.0.3


Cc'ed Ingo.

2008-11-27 16:21:45

by Ingo Molnar

[permalink] [raw]
Subject: Re: about use wild cards for set_ftrace_filter and so on


* walimis <[email protected]> wrote:

> I only add a note, but I wonder whether enough.
> If needed, I can add a example to this document.
>
> Impact: imporve document

[ You need to slightly improve the commit log as well ;-) ]

> +Note: you'd better to use '' to enclose wild cards, otherwise in some
> +case you can't get the correct result.
> +
> # echo hrtimer_* > /debug/tracing/set_ftrace_filter

Why not fix the example too? Something like:

> +Note: you'd better to use '' to enclose wild cards, otherwise in some
> +case you can't get the correct result due to shell wildcard
> +extension:.
> +
> # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter

looks good otherwise.

Ingo

2008-11-28 02:32:58

by walimis

[permalink] [raw]
Subject: [PATCH 1/1] ftrace: improve document

Impact: add notice of using wild cards correctly

We know that we can use wild cards to set set_ftrace_filter, but there's
problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
If there are files named with "h" prefix in current directory, echo "h*"
will echo these files' name to set_ftrace_filter, not "h*".
For example:
$cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
23
$ls
$touch hraa hrdd
$ls
hraa hrdd
$echo hr* > /debug/tracing/set_ftrace_filter
$cat /debug/tracing/set_ftrace_filter

No output in /debug/tracing/set_ftrace_filter!
If we use '' to enclose wild cards, it works:

$ls
hraa hrdd
$echo "hr*" > /debug/tracing/set_ftrace_filter
$cat /debug/tracing/set_ftrace_filter |wc -l
23

This problem can lead to unexpected result if current directory has a
lot of files.

Signed-off-by: walimis <[email protected]>
Reviewed-by: Ingo Molnar <[email protected]>
---
Documentation/ftrace.txt | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index de05042..0012a4a 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -1251,7 +1251,10 @@ These are the only wild cards which are supported.

<match>*<match> will not work.

- # echo hrtimer_* > /debug/tracing/set_ftrace_filter
+Note: you'd better to use '' to enclose wild cards, otherwise in some
+cases you can't get the correct result.
+
+ # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter

Produces:

@@ -1306,7 +1309,7 @@ Again, now we want to append.
# echo sys_nanosleep > /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
sys_nanosleep
- # echo hrtimer_* >> /debug/tracing/set_ftrace_filter
+ # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
hrtimer_run_queues
hrtimer_run_pending
--
1.6.0.3

2008-11-28 03:53:16

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 1/1] ftrace: improve document


On Fri, 28 Nov 2008, walimis wrote:

> Impact: add notice of using wild cards correctly
>
> We know that we can use wild cards to set set_ftrace_filter, but there's
> problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
> If there are files named with "h" prefix in current directory, echo "h*"
> will echo these files' name to set_ftrace_filter, not "h*".
> For example:
> $cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
> 23
> $ls
> $touch hraa hrdd
> $ls
> hraa hrdd
> $echo hr* > /debug/tracing/set_ftrace_filter
> $cat /debug/tracing/set_ftrace_filter
>
> No output in /debug/tracing/set_ftrace_filter!
> If we use '' to enclose wild cards, it works:
>
> $ls
> hraa hrdd
> $echo "hr*" > /debug/tracing/set_ftrace_filter
> $cat /debug/tracing/set_ftrace_filter |wc -l
> 23
>
> This problem can lead to unexpected result if current directory has a
> lot of files.
>
> Signed-off-by: walimis <[email protected]>
> Reviewed-by: Ingo Molnar <[email protected]>
> ---
> Documentation/ftrace.txt | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
> index de05042..0012a4a 100644
> --- a/Documentation/ftrace.txt
> +++ b/Documentation/ftrace.txt
> @@ -1251,7 +1251,10 @@ These are the only wild cards which are supported.
>
> <match>*<match> will not work.
>
> - # echo hrtimer_* > /debug/tracing/set_ftrace_filter
> +Note: you'd better to use '' to enclose wild cards, otherwise in some
> +cases you can't get the correct result.

The above sounds awkward, perhaps something like:

Note: It is better to use quotes to enclose the wild cards, otherwise
the shell may expand the parameters into names of files in the local
directory.

-- Steve



> +
> + # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter
>
> Produces:
>
> @@ -1306,7 +1309,7 @@ Again, now we want to append.
> # echo sys_nanosleep > /debug/tracing/set_ftrace_filter
> # cat /debug/tracing/set_ftrace_filter
> sys_nanosleep
> - # echo hrtimer_* >> /debug/tracing/set_ftrace_filter
> + # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter
> # cat /debug/tracing/set_ftrace_filter
> hrtimer_run_queues
> hrtimer_run_pending
> --
> 1.6.0.3
>
>
>

2008-11-28 04:21:37

by walimis

[permalink] [raw]
Subject: [PATCH 1/1] ftrace: improve document

Impact: add notice of using wild cards correctly

We know that we can use wild cards to set set_ftrace_filter, but there's
problem when using such as "echo h* > /debug/tracing/set_ftrace_filter".
If there are files named with "h" prefix in current directory, echo "h*"
will echo these files' name to set_ftrace_filter, not "h*".
For example:
$cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
23
$ls
$touch hraa hrdd
$ls
hraa hrdd
$echo hr* > /debug/tracing/set_ftrace_filter
$cat /debug/tracing/set_ftrace_filter

No output in /debug/tracing/set_ftrace_filter!
If we use '' to enclose wild cards, it works:

$ls
hraa hrdd
$echo "hr*" > /debug/tracing/set_ftrace_filter
$cat /debug/tracing/set_ftrace_filter |wc -l
23

This problem can lead to unexpected result if current directory has a
lot of files.

Signed-off-by: walimis <[email protected]>
Reviewed-by: Ingo Molnar <[email protected]>
Reviewed-by: Steven Rostedt <[email protected]>
---
Documentation/ftrace.txt | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index de05042..803b131 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -1251,7 +1251,11 @@ These are the only wild cards which are supported.

<match>*<match> will not work.

- # echo hrtimer_* > /debug/tracing/set_ftrace_filter
+Note: It is better to use quotes to enclose the wild cards, otherwise
+ the shell may expand the parameters into names of files in the local
+ directory.
+
+ # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter

Produces:

@@ -1306,7 +1310,7 @@ Again, now we want to append.
# echo sys_nanosleep > /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
sys_nanosleep
- # echo hrtimer_* >> /debug/tracing/set_ftrace_filter
+ # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
hrtimer_run_queues
hrtimer_run_pending
--
1.6.0.3

2008-11-28 06:56:20

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 1/1] ftrace: improve document


On Fri, 28 Nov 2008, walimis wrote:
>
> Signed-off-by: walimis <[email protected]>
> Reviewed-by: Ingo Molnar <[email protected]>
> Reviewed-by: Steven Rostedt <[email protected]>

Acked-by: Steven Rostedt <[email protected]>

-- Steve

> ---
> Documentation/ftrace.txt | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
> index de05042..803b131 100644
> --- a/Documentation/ftrace.txt
> +++ b/Documentation/ftrace.txt
> @@ -1251,7 +1251,11 @@ These are the only wild cards which are supported.
>
> <match>*<match> will not work.
>
> - # echo hrtimer_* > /debug/tracing/set_ftrace_filter
> +Note: It is better to use quotes to enclose the wild cards, otherwise
> + the shell may expand the parameters into names of files in the local
> + directory.
> +
> + # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter
>
> Produces:
>
> @@ -1306,7 +1310,7 @@ Again, now we want to append.
> # echo sys_nanosleep > /debug/tracing/set_ftrace_filter
> # cat /debug/tracing/set_ftrace_filter
> sys_nanosleep
> - # echo hrtimer_* >> /debug/tracing/set_ftrace_filter
> + # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter
> # cat /debug/tracing/set_ftrace_filter
> hrtimer_run_queues
> hrtimer_run_pending
> --
> 1.6.0.3
>
>
>

2008-11-28 12:16:56

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 1/1] ftrace: improve document


* Steven Rostedt <[email protected]> wrote:

>
> On Fri, 28 Nov 2008, walimis wrote:
> >
> > Signed-off-by: walimis <[email protected]>
> > Reviewed-by: Ingo Molnar <[email protected]>
> > Reviewed-by: Steven Rostedt <[email protected]>
>
> Acked-by: Steven Rostedt <[email protected]>

applied it to tip/tracing/ftrace, thanks guys! (Changed the commit log a
bit, see the final commit below.)

Ingo

-------------->
>From c072c24975ec4f0ccfcb6f5c8a8040b6eb75ef8f Mon Sep 17 00:00:00 2001
From: walimis <[email protected]>
Date: Fri, 28 Nov 2008 12:21:19 +0800
Subject: [PATCH] ftrace: improve documentation

Impact: extend documentation with notice of using wild cards correctly

We know that we can use wild cards to set set_ftrace_filter, but there's
problem when using them naively such as:

echo h* > /debug/tracing/set_ftrace_filter

If there are files named with "h" prefix in current directory,
echo "h*" will echo these filenames to set_ftrace_filter, not the
intended "h*".

For example:

$ cat /debug/tracing/available_filter_functions |grep ^hr |wc -l
23
$ ls
$ touch hraa hrdd
$ ls
hraa hrdd
$ echo hr* > /debug/tracing/set_ftrace_filter
$ cat /debug/tracing/set_ftrace_filter

No output in /debug/tracing/set_ftrace_filter!

If we use '' to escape wild cards, it works:

$ ls
hraa hrdd
$ echo "hr*" > /debug/tracing/set_ftrace_filter
$ cat /debug/tracing/set_ftrace_filter |wc -l
23

This problem can lead to unexpected result if current directory has a
lot of files.

Signed-off-by: walimis <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
Documentation/ftrace.txt | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index de05042..803b131 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -1251,7 +1251,11 @@ These are the only wild cards which are supported.

<match>*<match> will not work.

- # echo hrtimer_* > /debug/tracing/set_ftrace_filter
+Note: It is better to use quotes to enclose the wild cards, otherwise
+ the shell may expand the parameters into names of files in the local
+ directory.
+
+ # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter

Produces:

@@ -1306,7 +1310,7 @@ Again, now we want to append.
# echo sys_nanosleep > /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
sys_nanosleep
- # echo hrtimer_* >> /debug/tracing/set_ftrace_filter
+ # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter
# cat /debug/tracing/set_ftrace_filter
hrtimer_run_queues
hrtimer_run_pending