perf hists: Use own hpp_list for hierarchy mode
Now each hists has its own hpp lists in hierarchy. So instead of having a pointer to a single perf_hpp_fmt in a hist entry, make it point the hpp_list for its level. This will be used to support multiple sort keys in a single hierarchy level. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1457361308-514-3-git-send-email-namhyung@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:

committed by
Ingo Molnar

parent
c3bc0c4368
commit
1b2dbbf41a
@@ -1388,25 +1388,26 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
|
||||
HE_COLORSET_NORMAL);
|
||||
}
|
||||
|
||||
ui_browser__write_nstring(&browser->b, "", 2);
|
||||
width -= 2;
|
||||
perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
|
||||
ui_browser__write_nstring(&browser->b, "", 2);
|
||||
width -= 2;
|
||||
|
||||
/*
|
||||
* No need to call hist_entry__snprintf_alignment()
|
||||
* since this fmt is always the last column in the
|
||||
* hierarchy mode.
|
||||
*/
|
||||
fmt = entry->fmt;
|
||||
if (fmt->color) {
|
||||
width -= fmt->color(fmt, &hpp, entry);
|
||||
} else {
|
||||
int i = 0;
|
||||
/*
|
||||
* No need to call hist_entry__snprintf_alignment()
|
||||
* since this fmt is always the last column in the
|
||||
* hierarchy mode.
|
||||
*/
|
||||
if (fmt->color) {
|
||||
width -= fmt->color(fmt, &hpp, entry);
|
||||
} else {
|
||||
int i = 0;
|
||||
|
||||
width -= fmt->entry(fmt, &hpp, entry);
|
||||
ui_browser__printf(&browser->b, "%s", ltrim(s));
|
||||
width -= fmt->entry(fmt, &hpp, entry);
|
||||
ui_browser__printf(&browser->b, "%s", ltrim(s));
|
||||
|
||||
while (isspace(s[i++]))
|
||||
width++;
|
||||
while (isspace(s[i++]))
|
||||
width++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1934,7 +1935,7 @@ static int hist_browser__fprintf_hierarchy_entry(struct hist_browser *browser,
|
||||
struct perf_hpp_fmt *fmt;
|
||||
bool first = true;
|
||||
int ret;
|
||||
int hierarchy_indent = (nr_sort_keys + 1) * HIERARCHY_INDENT;
|
||||
int hierarchy_indent = nr_sort_keys * HIERARCHY_INDENT;
|
||||
|
||||
printed = fprintf(fp, "%*s", level * HIERARCHY_INDENT, "");
|
||||
|
||||
@@ -1962,9 +1963,13 @@ static int hist_browser__fprintf_hierarchy_entry(struct hist_browser *browser,
|
||||
ret = scnprintf(hpp.buf, hpp.size, "%*s", hierarchy_indent, "");
|
||||
advance_hpp(&hpp, ret);
|
||||
|
||||
fmt = he->fmt;
|
||||
ret = fmt->entry(fmt, &hpp, he);
|
||||
advance_hpp(&hpp, ret);
|
||||
perf_hpp_list__for_each_format(he->hpp_list, fmt) {
|
||||
ret = scnprintf(hpp.buf, hpp.size, " ");
|
||||
advance_hpp(&hpp, ret);
|
||||
|
||||
ret = fmt->entry(fmt, &hpp, he);
|
||||
advance_hpp(&hpp, ret);
|
||||
}
|
||||
|
||||
printed += fprintf(fp, "%s\n", rtrim(s));
|
||||
|
||||
|
@@ -412,6 +412,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists,
|
||||
for (node = rb_first(root); node; node = rb_next(node)) {
|
||||
GtkTreeIter iter;
|
||||
float percent;
|
||||
char *bf;
|
||||
|
||||
he = rb_entry(node, struct hist_entry, rb_node);
|
||||
if (he->filtered)
|
||||
@@ -437,13 +438,20 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists,
|
||||
gtk_tree_store_set(store, &iter, col_idx++, hpp->buf, -1);
|
||||
}
|
||||
|
||||
fmt = he->fmt;
|
||||
if (fmt->color)
|
||||
fmt->color(fmt, hpp, he);
|
||||
else
|
||||
fmt->entry(fmt, hpp, he);
|
||||
bf = hpp->buf;
|
||||
perf_hpp_list__for_each_format(he->hpp_list, fmt) {
|
||||
int ret;
|
||||
|
||||
gtk_tree_store_set(store, &iter, col_idx, rtrim(hpp->buf), -1);
|
||||
if (fmt->color)
|
||||
ret = fmt->color(fmt, hpp, he);
|
||||
else
|
||||
ret = fmt->entry(fmt, hpp, he);
|
||||
|
||||
snprintf(hpp->buf + ret, hpp->size - ret, " ");
|
||||
advance_hpp(hpp, ret + 2);
|
||||
}
|
||||
|
||||
gtk_tree_store_set(store, &iter, col_idx, rtrim(bf), -1);
|
||||
|
||||
if (!he->leaf) {
|
||||
perf_gtk__add_hierarchy_entries(hists, &he->hroot_out,
|
||||
|
@@ -722,6 +722,7 @@ static int add_hierarchy_fmt(struct hists *hists, struct perf_hpp_fmt *fmt)
|
||||
struct perf_hpp_list_node *node = NULL;
|
||||
struct perf_hpp_fmt *fmt_copy;
|
||||
bool found = false;
|
||||
bool skip = perf_hpp__should_skip(fmt, hists);
|
||||
|
||||
list_for_each_entry(node, &hists->hpp_formats, list) {
|
||||
if (node->level == fmt->level) {
|
||||
@@ -735,6 +736,7 @@ static int add_hierarchy_fmt(struct hists *hists, struct perf_hpp_fmt *fmt)
|
||||
if (node == NULL)
|
||||
return -1;
|
||||
|
||||
node->skip = skip;
|
||||
node->level = fmt->level;
|
||||
perf_hpp_list__init(&node->hpp);
|
||||
|
||||
@@ -745,6 +747,9 @@ static int add_hierarchy_fmt(struct hists *hists, struct perf_hpp_fmt *fmt)
|
||||
if (fmt_copy == NULL)
|
||||
return -1;
|
||||
|
||||
if (!skip)
|
||||
node->skip = false;
|
||||
|
||||
list_add_tail(&fmt_copy->list, &node->hpp.fields);
|
||||
list_add_tail(&fmt_copy->sort_list, &node->hpp.sorts);
|
||||
|
||||
|
@@ -451,33 +451,33 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
|
||||
advance_hpp(hpp, ret);
|
||||
}
|
||||
|
||||
if (sep)
|
||||
ret = scnprintf(hpp->buf, hpp->size, "%s", sep);
|
||||
else
|
||||
if (!sep)
|
||||
ret = scnprintf(hpp->buf, hpp->size, "%*s",
|
||||
(nr_sort_key - 1) * HIERARCHY_INDENT + 2, "");
|
||||
(nr_sort_key - 1) * HIERARCHY_INDENT, "");
|
||||
advance_hpp(hpp, ret);
|
||||
|
||||
printed += fprintf(fp, "%s", buf);
|
||||
|
||||
hpp->buf = buf;
|
||||
hpp->size = size;
|
||||
perf_hpp_list__for_each_format(he->hpp_list, fmt) {
|
||||
hpp->buf = buf;
|
||||
hpp->size = size;
|
||||
|
||||
/*
|
||||
* No need to call hist_entry__snprintf_alignment() since this
|
||||
* fmt is always the last column in the hierarchy mode.
|
||||
*/
|
||||
fmt = he->fmt;
|
||||
if (perf_hpp__use_color() && fmt->color)
|
||||
fmt->color(fmt, hpp, he);
|
||||
else
|
||||
fmt->entry(fmt, hpp, he);
|
||||
/*
|
||||
* No need to call hist_entry__snprintf_alignment() since this
|
||||
* fmt is always the last column in the hierarchy mode.
|
||||
*/
|
||||
if (perf_hpp__use_color() && fmt->color)
|
||||
fmt->color(fmt, hpp, he);
|
||||
else
|
||||
fmt->entry(fmt, hpp, he);
|
||||
|
||||
/*
|
||||
* dynamic entries are right-aligned but we want left-aligned
|
||||
* in the hierarchy mode
|
||||
*/
|
||||
printed += fprintf(fp, "%s\n", ltrim(buf));
|
||||
/*
|
||||
* dynamic entries are right-aligned but we want left-aligned
|
||||
* in the hierarchy mode
|
||||
*/
|
||||
printed += fprintf(fp, "%s%s", sep ?: " ", ltrim(buf));
|
||||
}
|
||||
printed += putc('\n', fp);
|
||||
|
||||
if (symbol_conf.use_callchain && he->leaf) {
|
||||
u64 total = hists__total_period(hists);
|
||||
|
Reference in New Issue
Block a user