From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
Andi Kleen <andi@firstfloor.org>, David Ahern <dsahern@gmail.com>,
Jiri Olsa <jolsa@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>,
Wang Nan <wangnan0@huawei.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 12/15] perf hists: Fix indent for multiple hierarchy sort key
Date: Mon, 7 Mar 2016 16:44:48 -0300 [thread overview]
Message-ID: <1457379891-28516-13-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1457379891-28516-1-git-send-email-acme@kernel.org>
From: Namhyung Kim <namhyung@kernel.org>
When multiple sort keys are used in a single hierarchy, it should indent
using number of hierarchy levels instead of number of sort keys.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1457361308-514-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/browsers/hists.c | 23 ++++++++++-------------
tools/perf/ui/hist.c | 1 +
tools/perf/ui/stdio/hist.c | 26 +++++++++++---------------
tools/perf/util/hist.h | 1 +
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 928b4825b752..2f02ce79bd9d 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1280,7 +1280,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
struct hist_entry *entry,
unsigned short row,
- int level, int nr_sort_keys)
+ int level)
{
int printed = 0;
int width = browser->b.width;
@@ -1294,7 +1294,7 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
.current_entry = current_entry,
};
int column = 0;
- int hierarchy_indent = (nr_sort_keys - 1) * HIERARCHY_INDENT;
+ int hierarchy_indent = (entry->hists->nr_hpp_node - 2) * HIERARCHY_INDENT;
if (current_entry) {
browser->he_selection = entry;
@@ -1436,8 +1436,7 @@ show_callchain:
}
static int hist_browser__show_no_entry(struct hist_browser *browser,
- unsigned short row,
- int level, int nr_sort_keys)
+ unsigned short row, int level)
{
int width = browser->b.width;
bool current_entry = ui_browser__is_current_entry(&browser->b, row);
@@ -1445,6 +1444,7 @@ static int hist_browser__show_no_entry(struct hist_browser *browser,
int column = 0;
int ret;
struct perf_hpp_fmt *fmt;
+ int indent = browser->hists->nr_hpp_node - 2;
if (current_entry) {
browser->he_selection = NULL;
@@ -1485,8 +1485,8 @@ static int hist_browser__show_no_entry(struct hist_browser *browser,
width -= ret;
}
- ui_browser__write_nstring(&browser->b, "", nr_sort_keys * HIERARCHY_INDENT);
- width -= nr_sort_keys * HIERARCHY_INDENT;
+ ui_browser__write_nstring(&browser->b, "", indent * HIERARCHY_INDENT);
+ width -= indent * HIERARCHY_INDENT;
if (column >= browser->b.horiz_scroll) {
char buf[32];
@@ -1553,7 +1553,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
struct perf_hpp_fmt *fmt;
size_t ret = 0;
int column = 0;
- int nr_sort_keys = hists->nr_sort_keys;
+ int indent = hists->nr_hpp_node - 2;
bool first = true;
ret = scnprintf(buf, size, " ");
@@ -1577,7 +1577,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
}
ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
- (nr_sort_keys - 1) * HIERARCHY_INDENT, "");
+ indent * HIERARCHY_INDENT, "");
if (advance_hpp_check(&dummy_hpp, ret))
return ret;
@@ -1645,7 +1645,6 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
u16 header_offset = 0;
struct rb_node *nd;
struct hist_browser *hb = container_of(browser, struct hist_browser, b);
- int nr_sort = hb->hists->nr_sort_keys;
if (hb->show_headers) {
hist_browser__show_headers(hb);
@@ -1672,14 +1671,12 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
if (symbol_conf.report_hierarchy) {
row += hist_browser__show_hierarchy_entry(hb, h, row,
- h->depth,
- nr_sort);
+ h->depth);
if (row == browser->rows)
break;
if (h->has_no_entry) {
- hist_browser__show_no_entry(hb, row, h->depth,
- nr_sort);
+ hist_browser__show_no_entry(hb, row, h->depth);
row++;
}
} else {
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 95795ef4209b..f03c4f70438f 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -740,6 +740,7 @@ static int add_hierarchy_fmt(struct hists *hists, struct perf_hpp_fmt *fmt)
node->level = fmt->level;
perf_hpp_list__init(&node->hpp);
+ hists->nr_hpp_node++;
list_add_tail(&node->list, &hists->hpp_formats);
}
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 073642a63cc9..543d7137cc0c 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -412,7 +412,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
struct perf_hpp *hpp,
- int nr_sort_key, struct hists *hists,
+ struct hists *hists,
FILE *fp)
{
const char *sep = symbol_conf.field_sep;
@@ -453,7 +453,7 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
if (!sep)
ret = scnprintf(hpp->buf, hpp->size, "%*s",
- (nr_sort_key - 1) * HIERARCHY_INDENT, "");
+ (hists->nr_hpp_node - 2) * HIERARCHY_INDENT, "");
advance_hpp(hpp, ret);
printed += fprintf(fp, "%s", buf);
@@ -504,12 +504,8 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
if (size == 0 || size > bfsz)
size = hpp.size = bfsz;
- if (symbol_conf.report_hierarchy) {
- int nr_sort = hists->nr_sort_keys;
-
- return hist_entry__hierarchy_fprintf(he, &hpp, nr_sort,
- hists, fp);
- }
+ if (symbol_conf.report_hierarchy)
+ return hist_entry__hierarchy_fprintf(he, &hpp, hists, fp);
hist_entry__snprintf(he, &hpp);
@@ -521,29 +517,29 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
return ret;
}
-static int print_hierarchy_indent(const char *sep, int nr_sort,
+static int print_hierarchy_indent(const char *sep, int indent,
const char *line, FILE *fp)
{
- if (sep != NULL || nr_sort < 1)
+ if (sep != NULL || indent < 2)
return 0;
- return fprintf(fp, "%-.*s", (nr_sort - 1) * HIERARCHY_INDENT, line);
+ return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line);
}
static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
const char *sep, FILE *fp)
{
bool first = true;
- int nr_sort;
+ int indent;
int depth;
unsigned width = 0;
unsigned header_width = 0;
struct perf_hpp_fmt *fmt;
- nr_sort = hists->nr_sort_keys;
+ indent = hists->nr_hpp_node;
/* preserve max indent depth for column headers */
- print_hierarchy_indent(sep, nr_sort, spaces, fp);
+ print_hierarchy_indent(sep, indent, spaces, fp);
hists__for_each_format(hists, fmt) {
if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
@@ -582,7 +578,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
fprintf(fp, "\n# ");
/* preserve max indent depth for initial dots */
- print_hierarchy_indent(sep, nr_sort, dots, fp);
+ print_hierarchy_indent(sep, indent, dots, fp);
first = true;
hists__for_each_format(hists, fmt) {
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 2209188d729c..2cb017f28f9e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -80,6 +80,7 @@ struct hists {
struct perf_hpp_list *hpp_list;
struct list_head hpp_formats;
int nr_sort_keys;
+ int nr_hpp_node;
};
struct hist_entry_iter;
--
2.5.0
next prev parent reply other threads:[~2016-03-07 19:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 19:44 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 01/15] perf tools: Explicitly declare inc_group_count as a void function Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 02/15] perf inject: Hit all DSOs for AUX data in JIT and other cases Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 03/15] perf session: Simplify tool stubs Arnaldo Carvalho de Melo
2016-03-08 7:45 ` Adrian Hunter
2016-03-08 9:17 ` Ingo Molnar
2016-03-07 19:44 ` [PATCH 04/15] perf jit: Let jit_process() return errors Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 05/15] perf jit: Move clockid validation Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 06/15] perf tools: Use 64-bit shifts with (TSC) time conversion Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 07/15] perf hists: Add level field to struct perf_hpp_fmt Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 08/15] perf stat: Document --detailed option Arnaldo Carvalho de Melo
2016-03-08 9:10 ` Ingo Molnar
2016-03-07 19:44 ` [PATCH 09/15] perf hists: Introduce perf_hpp__setup_hists_formats() Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 10/15] perf hists: Use own hpp_list for hierarchy mode Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 11/15] perf hists: Support multiple sort keys in a hierarchy level Arnaldo Carvalho de Melo
2016-03-07 19:44 ` Arnaldo Carvalho de Melo [this message]
2016-03-07 19:44 ` [PATCH 13/15] perf report: Use hierarchy hpp list on stdio Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 14/15] perf hists browser: Use hierarchy hpp list Arnaldo Carvalho de Melo
2016-03-07 19:44 ` [PATCH 15/15] perf report: Use hierarchy hpp list on gtk Arnaldo Carvalho de Melo
2016-03-10 9:32 ` [PATCH] perf tool: Build jitdump only on supported archs Jiri Olsa
2016-03-10 15:57 ` Arnaldo Carvalho de Melo
2016-03-10 16:04 ` Jiri Olsa
2016-03-10 16:13 ` Arnaldo Carvalho de Melo
2016-03-10 16:41 ` [PATCHv2] " Jiri Olsa
2016-03-11 8:47 ` [tip:perf/core] perf jitdump: Build " tip-bot for Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457379891-28516-13-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).