2017-06-01 09:08:07

by Du, Changbin

[permalink] [raw]
Subject: [PATCH] perf sort: only insert overhead && overhead_children when no overhead* field given

From: Changbin Du <[email protected]>

If we always insert 'overhead' and 'overhead_children' as sort keys,
this make it impossible to sort as overhead (which displayed as Self)
first.Ths will be a problem if the data is collected with call-graph
enabled. Then we never can sort the result as self-overhead on this
data. And sometimes the data is hard to collect.

This patch fix this by only insert overhead && overhead_children
when no overhead* field given.

Signed-off-by: Changbin Du <[email protected]>
---
tools/perf/util/sort.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 5762ae4..69eea3a 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
if (sort__mode == SORT_MODE__DIFF)
return keys;

+ if (strstr(keys, "overhead"))
+ return keys;
+
keys = prefix_if_not_in("overhead", keys);

if (symbol_conf.cumulate_callchain)
--
2.7.4


2017-06-01 10:21:59

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH] perf sort: only insert overhead && overhead_children when no overhead* field given

On Thu, Jun 01, 2017 at 05:03:21PM +0800, [email protected] wrote:
> From: Changbin Du <[email protected]>
>
> If we always insert 'overhead' and 'overhead_children' as sort keys,
> this make it impossible to sort as overhead (which displayed as Self)
> first.Ths will be a problem if the data is collected with call-graph
> enabled. Then we never can sort the result as self-overhead on this
> data. And sometimes the data is hard to collect.
>
> This patch fix this by only insert overhead && overhead_children
> when no overhead* field given.
>
> Signed-off-by: Changbin Du <[email protected]>
> ---
> tools/perf/util/sort.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 5762ae4..69eea3a 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> if (sort__mode == SORT_MODE__DIFF)
> return keys;
>
> + if (strstr(keys, "overhead"))
> + return keys;
> +
> keys = prefix_if_not_in("overhead", keys);

hum, you basicaly do what's at begining of prefix_if_not_in function:

static char *prefix_if_not_in(const char *pre, char *str)
{
char *n;

if (!str || strstr(str, pre))
return str;
...


could you please provide the example described in changelog?

jirka

2017-06-02 02:56:29

by Du, Changbin

[permalink] [raw]
Subject: Re: [PATCH] perf sort: only insert overhead && overhead_children when no overhead* field given

On Thu, Jun 01, 2017 at 12:21:39PM +0200, Jiri Olsa wrote:
> On Thu, Jun 01, 2017 at 05:03:21PM +0800, [email protected] wrote:
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index 5762ae4..69eea3a 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> > if (sort__mode == SORT_MODE__DIFF)
> > return keys;
> >
> > + if (strstr(keys, "overhead"))
> > + return keys;
> > +
> > keys = prefix_if_not_in("overhead", keys);
>
> hum, you basicaly do what's at begining of prefix_if_not_in function:
>
> static char *prefix_if_not_in(const char *pre, char *str)
> {
> char *n;
>
> if (!str || strstr(str, pre))
> return str;
> ...
>
Thanks, will change it.

>
> could you please provide the example described in changelog?
>
Will add example cmdline there, Thanks.

> jirka

--
Thanks,
Changbin Du


Attachments:
(No filename) (960.00 B)
signature.asc (473.00 B)
Download all attachments

2017-06-02 03:27:03

by Du, Changbin

[permalink] [raw]
Subject: Re: [PATCH] perf sort: only insert overhead && overhead_children when no overhead* field given

On Fri, Jun 02, 2017 at 10:52:24AM +0800, Du, Changbin wrote:
> On Thu, Jun 01, 2017 at 12:21:39PM +0200, Jiri Olsa wrote:
> > On Thu, Jun 01, 2017 at 05:03:21PM +0800, [email protected] wrote:
> > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > > index 5762ae4..69eea3a 100644
> > > --- a/tools/perf/util/sort.c
> > > +++ b/tools/perf/util/sort.c
> > > @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> > > if (sort__mode == SORT_MODE__DIFF)
> > > return keys;
> > >
> > > + if (strstr(keys, "overhead"))
> > > + return keys;
> > > +
> > > keys = prefix_if_not_in("overhead", keys);
> >
> > hum, you basicaly do what's at begining of prefix_if_not_in function:
> >
> > static char *prefix_if_not_in(const char *pre, char *str)
> > {
> > char *n;
> >
> > if (!str || strstr(str, pre))
> > return str;
> > ...
> >
> Thanks, will change it.
>
Misunderstood your words. This is not equal to prefix_if_not_in.
# perf record -ag
# perf report -s overhead,sym

Samples: 7K of event 'cycles', Event count (approx.): 865138253
Children Self Symbol
+ 26.41% 0.00% [k] verify_cpu
+ 26.37% 0.04% [k] cpu_startup_entry
+ 25.93% 0.27% [k] do_idle
+ 19.88% 0.00% [k] start_secondary
....

'Children' should not be here.

> >
> > could you please provide the example described in changelog?
> >
> Will add example cmdline there, Thanks.
>
> > jirka
>
> --
> Thanks,
> Changbin Du



--
Thanks,
Changbin Du


Attachments:
(No filename) (1.50 kB)
signature.asc (473.00 B)
Download all attachments

2017-06-02 04:26:09

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v2] perf sort: only insert overhead && overhead_children when no overhead* field given

From: Changbin Du <[email protected]>

If we always insert 'overhead' and 'overhead_children' as sort keys,
this make it impossible to sort as overhead (which displayed as Self)
first.Ths will be a problem if the data is collected with call-graph
enabled. Then we never can sort the result as self-overhead on this
data. And sometimes the data is hard to collect.

> perf record -ag
> perf report -s overhead,sym

Samples: 7K of event 'cycles', Event count (approx.): 865138253
Children Self Symbol
+ 26.41% 0.00% [k] verify_cpu
+ 26.37% 0.04% [k] cpu_startup_entry
+ 25.93% 0.27% [k] do_idle
+ 19.88% 0.00% [k] start_secondary
....

I intend to sort as 'Self', but actually it sort as 'Children'.

This patch fix this by only insert overhead && overhead_children
when no overhead* field given.

Signed-off-by: Changbin Du <[email protected]>
---
v2: Add the example in commit message.

---
tools/perf/util/sort.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 5762ae4..69eea3a 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
if (sort__mode == SORT_MODE__DIFF)
return keys;

+ if (strstr(keys, "overhead"))
+ return keys;
+
keys = prefix_if_not_in("overhead", keys);

if (symbol_conf.cumulate_callchain)
--
2.7.4

2017-06-26 08:11:09

by Du, Changbin

[permalink] [raw]
Subject: Re: [PATCH v2] perf sort: only insert overhead && overhead_children when no overhead* field given


Hi, Jiri,
what is the status of this one? I didn't get a response of v2. thanks.

On Fri, Jun 02, 2017 at 12:22:00PM +0800, [email protected] wrote:
> From: Changbin Du <[email protected]>
>
> If we always insert 'overhead' and 'overhead_children' as sort keys,
> this make it impossible to sort as overhead (which displayed as Self)
> first.Ths will be a problem if the data is collected with call-graph
> enabled. Then we never can sort the result as self-overhead on this
> data. And sometimes the data is hard to collect.
>
> > perf record -ag
> > perf report -s overhead,sym
>
> Samples: 7K of event 'cycles', Event count (approx.): 865138253
> Children Self Symbol
> + 26.41% 0.00% [k] verify_cpu
> + 26.37% 0.04% [k] cpu_startup_entry
> + 25.93% 0.27% [k] do_idle
> + 19.88% 0.00% [k] start_secondary
> ....
>
> I intend to sort as 'Self', but actually it sort as 'Children'.
>
> This patch fix this by only insert overhead && overhead_children
> when no overhead* field given.
>
> Signed-off-by: Changbin Du <[email protected]>
> ---
> v2: Add the example in commit message.
>
> ---
> tools/perf/util/sort.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 5762ae4..69eea3a 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> if (sort__mode == SORT_MODE__DIFF)
> return keys;
>
> + if (strstr(keys, "overhead"))
> + return keys;
> +
> keys = prefix_if_not_in("overhead", keys);
>
> if (symbol_conf.cumulate_callchain)
> --
> 2.7.4
>

--
Thanks,
Changbin Du


Attachments:
(No filename) (1.66 kB)
signature.asc (473.00 B)
Download all attachments

2017-06-29 15:23:10

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2] perf sort: only insert overhead && overhead_children when no overhead* field given

On Mon, Jun 26, 2017 at 04:06:26PM +0800, Du, Changbin wrote:
>
> Hi, Jiri,
> what is the status of this one? I didn't get a response of v2. thanks.
>
> On Fri, Jun 02, 2017 at 12:22:00PM +0800, [email protected] wrote:
> > From: Changbin Du <[email protected]>
> >
> > If we always insert 'overhead' and 'overhead_children' as sort keys,
> > this make it impossible to sort as overhead (which displayed as Self)
> > first.Ths will be a problem if the data is collected with call-graph
> > enabled. Then we never can sort the result as self-overhead on this
> > data. And sometimes the data is hard to collect.
> >
> > > perf record -ag
> > > perf report -s overhead,sym
> >
> > Samples: 7K of event 'cycles', Event count (approx.): 865138253
> > Children Self Symbol
> > + 26.41% 0.00% [k] verify_cpu
> > + 26.37% 0.04% [k] cpu_startup_entry
> > + 25.93% 0.27% [k] do_idle
> > + 19.88% 0.00% [k] start_secondary
> > ....
> >
> > I intend to sort as 'Self', but actually it sort as 'Children'.
> >
> > This patch fix this by only insert overhead && overhead_children
> > when no overhead* field given.
> >
> > Signed-off-by: Changbin Du <[email protected]>
> > ---
> > v2: Add the example in commit message.
> >
> > ---
> > tools/perf/util/sort.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index 5762ae4..69eea3a 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> > if (sort__mode == SORT_MODE__DIFF)
> > return keys;
> >
> > + if (strstr(keys, "overhead"))
> > + return keys;
> > +

ah ok, I think it's right.. basically you're forcing
precedence of the -s option over the --children option

you could have your example working by running:
$ perf report -s overhead,sym --no-children

please state something like:

/*
* User already stated overhead within -s option,
* do not mangle with that.
*/

thanks,
jirka

2017-07-05 03:07:38

by Du, Changbin

[permalink] [raw]
Subject: Re: [PATCH v2] perf sort: only insert overhead && overhead_children when no overhead* field given

On Thu, Jun 29, 2017 at 05:22:52PM +0200, Jiri Olsa wrote:
> > > --- a/tools/perf/util/sort.c
> > > +++ b/tools/perf/util/sort.c
> > > @@ -2635,6 +2635,9 @@ static char *setup_overhead(char *keys)
> > > if (sort__mode == SORT_MODE__DIFF)
> > > return keys;
> > >
> > > + if (strstr(keys, "overhead"))
> > > + return keys;
> > > +
>
> ah ok, I think it's right.. basically you're forcing
> precedence of the -s option over the --children option
>
> you could have your example working by running:
> $ perf report -s overhead,sym --no-children
>
Thanks for the knowledge.

> please state something like:
>
> /*
> * User already stated overhead within -s option,
> * do not mangle with that.
> */
>
I'll add this as comment around the change for v3.

> thanks,
> jirka

--
Thanks,
Changbin Du


Attachments:
(No filename) (809.00 B)
signature.asc (473.00 B)
Download all attachments

2017-07-05 03:40:57

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v3] perf sort: only insert overhead && overhead_children when no overhead* field given

From: Changbin Du <[email protected]>

If we always insert 'overhead' and 'overhead_children' as sort keys,
this make it impossible to sort as overhead (which displayed as Self)
first.Ths will be a problem if the data is collected with call-graph
enabled. Then we never can sort the result as self-overhead on this
data. And sometimes the data is hard to collect.

> perf record -ag
> perf report -s overhead,sym

Samples: 7K of event 'cycles', Event count (approx.): 865138253
Children Self Symbol
+ 26.41% 0.00% [k] verify_cpu
+ 26.37% 0.04% [k] cpu_startup_entry
+ 25.93% 0.27% [k] do_idle
+ 19.88% 0.00% [k] start_secondary
....

I intend to sort as 'Self', but actually it sort as 'Children'.

This patch fix this by only insert overhead && overhead_children
when no overhead* field given.

Signed-off-by: Changbin Du <[email protected]>
---
v3: Add comment in code from Jiri
v2: Add the example in commit message.

---
tools/perf/util/sort.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b327c9..9e087fb 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2635,6 +2635,13 @@ static char *setup_overhead(char *keys)
if (sort__mode == SORT_MODE__DIFF)
return keys;

+ /**
+ * User already stated overhead within -s option,
+ * do not mangle with that.
+ */
+ if (strstr(keys, "overhead"))
+ return keys;
+
keys = prefix_if_not_in("overhead", keys);

if (symbol_conf.cumulate_callchain)
--
2.7.4

2017-07-06 16:04:14

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v3] perf sort: only insert overhead && overhead_children when no overhead* field given

On Wed, Jul 05, 2017 at 11:35:52AM +0800, [email protected] wrote:
> From: Changbin Du <[email protected]>
>
> If we always insert 'overhead' and 'overhead_children' as sort keys,
> this make it impossible to sort as overhead (which displayed as Self)
> first.Ths will be a problem if the data is collected with call-graph
> enabled. Then we never can sort the result as self-overhead on this
> data. And sometimes the data is hard to collect.
>
> > perf record -ag
> > perf report -s overhead,sym
>
> Samples: 7K of event 'cycles', Event count (approx.): 865138253
> Children Self Symbol
> + 26.41% 0.00% [k] verify_cpu
> + 26.37% 0.04% [k] cpu_startup_entry
> + 25.93% 0.27% [k] do_idle
> + 19.88% 0.00% [k] start_secondary
> ....
>
> I intend to sort as 'Self', but actually it sort as 'Children'.
>
> This patch fix this by only insert overhead && overhead_children
> when no overhead* field given.
>
> Signed-off-by: Changbin Du <[email protected]>

Acked-by: Jiri Olsa <[email protected]>

thanks,
jirka

> ---
> v3: Add comment in code from Jiri
> v2: Add the example in commit message.
>
> ---
> tools/perf/util/sort.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 8b327c9..9e087fb 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2635,6 +2635,13 @@ static char *setup_overhead(char *keys)
> if (sort__mode == SORT_MODE__DIFF)
> return keys;
>
> + /**
> + * User already stated overhead within -s option,
> + * do not mangle with that.
> + */
> + if (strstr(keys, "overhead"))
> + return keys;
> +
> keys = prefix_if_not_in("overhead", keys);
>
> if (symbol_conf.cumulate_callchain)
> --
> 2.7.4
>