2016-11-08 13:09:28

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

Hello,

This patches fix problems in hierarchy output Markus reported some
time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
in my tree:

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Any feedbacks are welcomed.

Thanks,
Namhyung


Cc: Markus Trippelsdorf <[email protected]>

Namhyung Kim (4):
perf hist browser: Fix indentation of folded sign on --hierarchy
perf hist browser: Show folded sign properly on --hierarchy
perf hist browser: Fix column indentation on --hierarchy
perf hists: Fix column length on --hierarchy

tools/perf/ui/browsers/hists.c | 35 ++++++++++++++++++++++++-----------
tools/perf/util/hist.c | 12 ++++++------
2 files changed, 30 insertions(+), 17 deletions(-)

--
2.10.1


2016-11-08 13:09:34

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 1/4] perf hist browser: Fix indentation of folded sign on --hierarchy

It should indent 2 spaces for folded sign and a whitespace.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/browsers/hists.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 84f5dd2fb59c..fe5677ccbc22 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1337,8 +1337,8 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
}

if (first) {
- ui_browser__printf(&browser->b, "%c", folded_sign);
- width--;
+ ui_browser__printf(&browser->b, "%c ", folded_sign);
+ width -= 2;
first = false;
} else {
ui_browser__printf(&browser->b, " ");
@@ -1555,7 +1555,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
int indent = hists->nr_hpp_node - 2;
bool first_node, first_col;

- ret = scnprintf(buf, size, " ");
+ ret = scnprintf(buf, size, " ");
if (advance_hpp_check(&dummy_hpp, ret))
return ret;

--
2.10.1

2016-11-08 13:09:41

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 3/4] perf hist browser: Fix column indentation on --hierarchy

When horizontall scrolling is used in hierarchy mode, the the right most
column has unnecessary indentation. Actually it's needed only if some
of left (overhead) columns were shown.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/browsers/hists.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 7722ad311318..15b29a79a69b 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1361,8 +1361,10 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
width -= hpp.buf - s;
}

- ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
- width -= hierarchy_indent;
+ if (!first) {
+ ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
+ width -= hierarchy_indent;
+ }

if (column >= browser->b.horiz_scroll) {
char s[2048];
@@ -1565,6 +1567,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
if (advance_hpp_check(&dummy_hpp, ret))
return ret;

+ first_node = true;
/* the first hpp_list_node is for overhead columns */
fmt_node = list_first_entry(&hists->hpp_formats,
struct perf_hpp_list_node, list);
@@ -1579,12 +1582,16 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
if (advance_hpp_check(&dummy_hpp, ret))
break;
+
+ first_node = false;
}

- ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
- indent * HIERARCHY_INDENT, "");
- if (advance_hpp_check(&dummy_hpp, ret))
- return ret;
+ if (!first_node) {
+ ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
+ indent * HIERARCHY_INDENT, "");
+ if (advance_hpp_check(&dummy_hpp, ret))
+ return ret;
+ }

first_node = true;
list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
--
2.10.1

2016-11-08 13:09:49

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 4/4] perf hists: Fix column length on --hierarchy

Markus reported that there's a weird behavior on perf top --hierarch
regarding the column length. Looking at the code, I found a debious
code which affects the symtoms. When --hierarchy option is used, the
last column length might be inaccurate since it skips to update the
length on leaf entries. I cannot remember why it did and looks like a
leftover from previous version during the development. Anyway updating
the column length often is not harmful. So let's move the code out.

Reported-by: Markus Trippelsdorf <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/hist.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index e1be4132054d..6770a9645609 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1601,18 +1601,18 @@ static void hists__hierarchy_output_resort(struct hists *hists,
if (prog)
ui_progress__update(prog, 1);

+ hists->nr_entries++;
+ if (!he->filtered) {
+ hists->nr_non_filtered_entries++;
+ hists__calc_col_len(hists, he);
+ }
+
if (!he->leaf) {
hists__hierarchy_output_resort(hists, prog,
&he->hroot_in,
&he->hroot_out,
min_callchain_hits,
use_callchain);
- hists->nr_entries++;
- if (!he->filtered) {
- hists->nr_non_filtered_entries++;
- hists__calc_col_len(hists, he);
- }
-
continue;
}

--
2.10.1

2016-11-08 13:10:09

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 2/4] perf hist browser: Show folded sign properly on --hierarchy

When horizontall scrolling is used in hierarchy mode, the folded signed
disappears at the right most column.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/ui/browsers/hists.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index fe5677ccbc22..7722ad311318 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1381,8 +1381,14 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
}

perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
- ui_browser__write_nstring(&browser->b, "", 2);
- width -= 2;
+ if (first) {
+ ui_browser__printf(&browser->b, "%c ", folded_sign);
+ width -= 2;
+ first = false;
+ } else {
+ ui_browser__write_nstring(&browser->b, "", 2);
+ width -= 2;
+ }

/*
* No need to call hist_entry__snprintf_alignment()
--
2.10.1

2016-11-08 13:21:22

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> Hello,
>
> This patches fix problems in hierarchy output Markus reported some
> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> in my tree:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
> Any feedbacks are welcomed.

It looks perfect now. Many thanks for your fixes.

--
Markus

2016-11-08 13:44:03

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
>
> This patches fix problems in hierarchy output Markus reported some
> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> in my tree:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
> Any feedbacks are welcomed.

By the way, I hope that:
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=perf/core&id=8a06b0be6507f97f3aa92ca814335b8b65fd3de2
doesn't fall through the cracks.

--
Markus

2016-11-08 15:06:39

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

Hello,

On Tue, Nov 8, 2016 at 10:43 PM, Markus Trippelsdorf
<[email protected]> wrote:
> On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
>>
>> This patches fix problems in hierarchy output Markus reported some
>> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
>> in my tree:
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>>
>> Any feedbacks are welcomed.
>
> By the way, I hope that:
> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=perf/core&id=8a06b0be6507f97f3aa92ca814335b8b65fd3de2
> doesn't fall through the cracks.

What do you mean? It's already in the tip/perf/core so will be merged
to the mainline eventually.

Thanks,
Namhyung

2016-11-08 15:10:28

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

On 2016.11.09 at 00:05 +0900, Namhyung Kim wrote:
> Hello,
>
> On Tue, Nov 8, 2016 at 10:43 PM, Markus Trippelsdorf
> <[email protected]> wrote:
> > On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> >>
> >> This patches fix problems in hierarchy output Markus reported some
> >> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> >> in my tree:
> >>
> >> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> >>
> >> Any feedbacks are welcomed.
> >
> > By the way, I hope that:
> > https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=perf/core&id=8a06b0be6507f97f3aa92ca814335b8b65fd3de2
> > doesn't fall through the cracks.
>
> What do you mean? It's already in the tip/perf/core so will be merged
> to the mainline eventually.

Ok. I was just wondering, because it sits there for two weeks already...

--
Markus

2016-11-09 13:10:52

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

Em Tue, Nov 08, 2016 at 04:10:23PM +0100, Markus Trippelsdorf escreveu:
> On 2016.11.09 at 00:05 +0900, Namhyung Kim wrote:
> > On Tue, Nov 8, 2016 at 10:43 PM, Markus Trippelsdorf
> > <[email protected]> wrote:
> > > On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> > >> This patches fix problems in hierarchy output Markus reported some
> > >> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> > >> in my tree:

> > >> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

> > >> Any feedbacks are welcomed.

> > > By the way, I hope that:
> > > https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=perf/core&id=8a06b0be6507f97f3aa92ca814335b8b65fd3de2
> > > doesn't fall through the cracks.

> > What do you mean? It's already in the tip/perf/core so will be merged
> > to the mainline eventually.

> Ok. I was just wondering, because it sits there for two weeks already...

If you think something qualifies for perf/urgent, i.e. to go to a kernel
that is in -rc stage, v4.9-rc4 now, for instance, please point that out
and I'll consider it.

- Arnaldo

2016-11-09 13:12:15

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

Em Tue, Nov 08, 2016 at 02:21:17PM +0100, Markus Trippelsdorf escreveu:
> On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> > Hello,
> >
> > This patches fix problems in hierarchy output Markus reported some
> > time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> > in my tree:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> >
> > Any feedbacks are welcomed.
>
> It looks perfect now. Many thanks for your fixes.

Ok, I'll take that as a Tested-by: Markus, ok?

- Arnaldo

2016-11-09 13:15:12

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

On 2016.11.09 at 10:10 -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 08, 2016 at 04:10:23PM +0100, Markus Trippelsdorf escreveu:
> > On 2016.11.09 at 00:05 +0900, Namhyung Kim wrote:
> > > On Tue, Nov 8, 2016 at 10:43 PM, Markus Trippelsdorf
> > > <[email protected]> wrote:
> > > > On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> > > >> This patches fix problems in hierarchy output Markus reported some
> > > >> time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> > > >> in my tree:
>
> > > >> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
> > > >> Any feedbacks are welcomed.
>
> > > > By the way, I hope that:
> > > > https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=perf/core&id=8a06b0be6507f97f3aa92ca814335b8b65fd3de2
> > > > doesn't fall through the cracks.
>
> > > What do you mean? It's already in the tip/perf/core so will be merged
> > > to the mainline eventually.
>
> > Ok. I was just wondering, because it sits there for two weeks already...
>
> If you think something qualifies for perf/urgent, i.e. to go to a kernel
> that is in -rc stage, v4.9-rc4 now, for instance, please point that out
> and I'll consider it.

Because "perf top --hierarchy" is new in 4.9, I think all fixes for that
feature qualify for perf/urgent by default.

--
Markus

2016-11-09 13:15:27

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: [PATCH 0/4] perf tools: Assorted fixes for hierarchy mode

On 2016.11.09 at 10:11 -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 08, 2016 at 02:21:17PM +0100, Markus Trippelsdorf escreveu:
> > On 2016.11.08 at 22:08 +0900, Namhyung Kim wrote:
> > > Hello,
> > >
> > > This patches fix problems in hierarchy output Markus reported some
> > > time ago. The code is available on the 'perf/hierarchy-fix-v1' branch
> > > in my tree:
> > >
> > > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
> > >
> > > Any feedbacks are welcomed.
> >
> > It looks perfect now. Many thanks for your fixes.
>
> Ok, I'll take that as a Tested-by: Markus, ok?

Sure, feel free.
Thanks.

--
Markus

2016-11-09 14:28:18

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/4] perf hist browser: Show folded sign properly on --hierarchy

Em Tue, Nov 08, 2016 at 10:08:31PM +0900, Namhyung Kim escreveu:
> When horizontall scrolling is used in hierarchy mode, the folded signed
> disappears at the right most column.

Humm, this indeed shows the '+' folded signal after pressing ->, but it
moves from the first to the third column :-\

- Arnaldo

> Signed-off-by: Namhyung Kim <[email protected]>
> ---
> tools/perf/ui/browsers/hists.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index fe5677ccbc22..7722ad311318 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1381,8 +1381,14 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
> }
>
> perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
> - ui_browser__write_nstring(&browser->b, "", 2);
> - width -= 2;
> + if (first) {
> + ui_browser__printf(&browser->b, "%c ", folded_sign);
> + width -= 2;
> + first = false;
> + } else {
> + ui_browser__write_nstring(&browser->b, "", 2);
> + width -= 2;
> + }
>
> /*
> * No need to call hist_entry__snprintf_alignment()
> --
> 2.10.1

2016-11-09 14:29:45

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/4] perf hist browser: Show folded sign properly on --hierarchy

Em Wed, Nov 09, 2016 at 11:28:11AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Nov 08, 2016 at 10:08:31PM +0900, Namhyung Kim escreveu:
> > When horizontall scrolling is used in hierarchy mode, the folded signed
> > disappears at the right most column.
>
> Humm, this indeed shows the '+' folded signal after pressing ->, but it
> moves from the first to the third column :-\
>
> > +++ b/tools/perf/ui/browsers/hists.c
> > @@ -1381,8 +1381,14 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
> > }
> >
> > perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
> > - ui_browser__write_nstring(&browser->b, "", 2);
> > - width -= 2;

Also why move this invariant to both branches?

> > + if (first) {
> > + ui_browser__printf(&browser->b, "%c ", folded_sign);
> > + width -= 2;
> > + first = false;
> > + } else {
> > + ui_browser__write_nstring(&browser->b, "", 2);
> > + width -= 2;
> > + }
> >
> > /*
> > * No need to call hist_entry__snprintf_alignment()
> > --
> > 2.10.1

2016-11-09 14:46:09

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 3/4] perf hist browser: Fix column indentation on --hierarchy

Em Tue, Nov 08, 2016 at 10:08:32PM +0900, Namhyung Kim escreveu:
> When horizontall scrolling is used in hierarchy mode, the the right most
> column has unnecessary indentation. Actually it's needed only if some
> of left (overhead) columns were shown.

I see, here is the fix, thanks, testing it now...

- Arnaldo

> Signed-off-by: Namhyung Kim <[email protected]>
> ---
> tools/perf/ui/browsers/hists.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 7722ad311318..15b29a79a69b 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1361,8 +1361,10 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
> width -= hpp.buf - s;
> }
>
> - ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
> - width -= hierarchy_indent;
> + if (!first) {
> + ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
> + width -= hierarchy_indent;
> + }
>
> if (column >= browser->b.horiz_scroll) {
> char s[2048];
> @@ -1565,6 +1567,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
> if (advance_hpp_check(&dummy_hpp, ret))
> return ret;
>
> + first_node = true;
> /* the first hpp_list_node is for overhead columns */
> fmt_node = list_first_entry(&hists->hpp_formats,
> struct perf_hpp_list_node, list);
> @@ -1579,12 +1582,16 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
> ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
> if (advance_hpp_check(&dummy_hpp, ret))
> break;
> +
> + first_node = false;
> }
>
> - ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
> - indent * HIERARCHY_INDENT, "");
> - if (advance_hpp_check(&dummy_hpp, ret))
> - return ret;
> + if (!first_node) {
> + ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
> + indent * HIERARCHY_INDENT, "");
> + if (advance_hpp_check(&dummy_hpp, ret))
> + return ret;
> + }
>
> first_node = true;
> list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
> --
> 2.10.1

Subject: [tip:perf/urgent] perf hists: Fix column length on --hierarchy

Commit-ID: c72ab446cac1d6c9551fd26c4cfef1b2fc5041fd
Gitweb: http://git.kernel.org/tip/c72ab446cac1d6c9551fd26c4cfef1b2fc5041fd
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 8 Nov 2016 22:08:33 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Nov 2016 11:55:29 -0300

perf hists: Fix column length on --hierarchy

Markus reported that there's a weird behavior on perf top --hierarchy
regarding the column length.

Looking at the code, I found a dubious code which affects the symptoms.
When --hierarchy option is used, the last column length might be
inaccurate since it skips to update the length on leaf entries.

I cannot remember why it did and looks like a leftover from previous
version during the development.

Anyway, updating the column length often is not harmful. So let's move
the code out.

Reported-and-Tested-by: Markus Trippelsdorf <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Fixes: 1a3906a7e6b9 ("perf hists: Resort hist entries with hierarchy")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/hist.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992e..a69f027 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1600,18 +1600,18 @@ static void hists__hierarchy_output_resort(struct hists *hists,
if (prog)
ui_progress__update(prog, 1);

+ hists->nr_entries++;
+ if (!he->filtered) {
+ hists->nr_non_filtered_entries++;
+ hists__calc_col_len(hists, he);
+ }
+
if (!he->leaf) {
hists__hierarchy_output_resort(hists, prog,
&he->hroot_in,
&he->hroot_out,
min_callchain_hits,
use_callchain);
- hists->nr_entries++;
- if (!he->filtered) {
- hists->nr_non_filtered_entries++;
- hists__calc_col_len(hists, he);
- }
-
continue;
}


Subject: [tip:perf/urgent] perf hists browser: Fix column indentation on --hierarchy

Commit-ID: b9bf911e990a189f89147ee6b66660a153ed0125
Gitweb: http://git.kernel.org/tip/b9bf911e990a189f89147ee6b66660a153ed0125
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 8 Nov 2016 22:08:32 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Nov 2016 11:45:58 -0300

perf hists browser: Fix column indentation on --hierarchy

When horizontall scrolling is used in hierarchy mode, the the right most
column has unnecessary indentation. Actually it's needed only if some
of left (overhead) columns were shown.

Signed-off-by: Namhyung Kim <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Tested-by: Markus Trippelsdorf <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e767fbd..a53fef0 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1361,8 +1361,10 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
width -= hpp.buf - s;
}

- ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
- width -= hierarchy_indent;
+ if (!first) {
+ ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
+ width -= hierarchy_indent;
+ }

if (column >= browser->b.horiz_scroll) {
char s[2048];
@@ -1565,6 +1567,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
if (advance_hpp_check(&dummy_hpp, ret))
return ret;

+ first_node = true;
/* the first hpp_list_node is for overhead columns */
fmt_node = list_first_entry(&hists->hpp_formats,
struct perf_hpp_list_node, list);
@@ -1579,12 +1582,16 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
if (advance_hpp_check(&dummy_hpp, ret))
break;
+
+ first_node = false;
}

- ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
- indent * HIERARCHY_INDENT, "");
- if (advance_hpp_check(&dummy_hpp, ret))
- return ret;
+ if (!first_node) {
+ ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
+ indent * HIERARCHY_INDENT, "");
+ if (advance_hpp_check(&dummy_hpp, ret))
+ return ret;
+ }

first_node = true;
list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {

Subject: [tip:perf/urgent] perf hists browser: Fix indentation of folded sign on --hierarchy

Commit-ID: 3d9f4683929a968dc9b9493f4e608b109ad292a2
Gitweb: http://git.kernel.org/tip/3d9f4683929a968dc9b9493f4e608b109ad292a2
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 8 Nov 2016 22:08:30 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Nov 2016 11:20:56 -0300

perf hists browser: Fix indentation of folded sign on --hierarchy

It should indent 2 spaces for folded sign and a whitespace.

Signed-off-by: Namhyung Kim <[email protected]>
Tested-by: Markus Trippelsdorf <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 5adedc1..225ef2a 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1337,8 +1337,8 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
}

if (first) {
- ui_browser__printf(&browser->b, "%c", folded_sign);
- width--;
+ ui_browser__printf(&browser->b, "%c ", folded_sign);
+ width -= 2;
first = false;
} else {
ui_browser__printf(&browser->b, " ");
@@ -1555,7 +1555,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
int indent = hists->nr_hpp_node - 2;
bool first_node, first_col;

- ret = scnprintf(buf, size, " ");
+ ret = scnprintf(buf, size, " ");
if (advance_hpp_check(&dummy_hpp, ret))
return ret;


Subject: [tip:perf/urgent] perf hists browser: Show folded sign properly on --hierarchy

Commit-ID: 131d51eb1d17aac3a604cf929fd99ff4dd34f495
Gitweb: http://git.kernel.org/tip/131d51eb1d17aac3a604cf929fd99ff4dd34f495
Author: Namhyung Kim <[email protected]>
AuthorDate: Tue, 8 Nov 2016 22:08:31 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 Nov 2016 11:30:47 -0300

perf hists browser: Show folded sign properly on --hierarchy

When horizontal scrolling is used in hierarchy mode, the folded signed
disappears at the right most column.

Committer note:

To test it, run 'perf top --hierarchy, see the '+' symbol at the first
column, then press the right arrow key, the '+' symbol will disappear,
this patch fixes that.

Signed-off-by: Namhyung Kim <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Tested-by: Markus Trippelsdorf <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Move 'width -= 2' invariant to right after the if/else ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 225ef2a..e767fbd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1381,7 +1381,13 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
}

perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
- ui_browser__write_nstring(&browser->b, "", 2);
+ if (first) {
+ ui_browser__printf(&browser->b, "%c ", folded_sign);
+ first = false;
+ } else {
+ ui_browser__write_nstring(&browser->b, "", 2);
+ }
+
width -= 2;

/*