summaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/hist.c
diff options
context:
space:
mode:
authorNamhyung Kim2014-03-03 08:16:20 +0100
committerJiri Olsa2014-05-21 11:45:34 +0200
commit26d8b338271a17a8a9b78000ebaec8b4645f5476 (patch)
tree41d1a6c7e3204c005df6a8983ccc519d47a55258 /tools/perf/ui/hist.c
parentperf tools: Use hpp formats to sort final output (diff)
downloadkernel-qcow2-linux-26d8b338271a17a8a9b78000ebaec8b4645f5476.tar.gz
kernel-qcow2-linux-26d8b338271a17a8a9b78000ebaec8b4645f5476.tar.xz
kernel-qcow2-linux-26d8b338271a17a8a9b78000ebaec8b4645f5476.zip
perf tools: Consolidate output field handling to hpp format routines
Until now the hpp and sort functions do similar jobs different ways. Since the sort functions converted/wrapped to hpp formats it can do the job in a uniform way. The perf_hpp__sort_list has a list of hpp formats to sort entries and the perf_hpp__list has a list of hpp formats to print output result. To have a backward compatibility, it automatically adds 'overhead' field in front of sort list. And then all of fields in sort list added to the output list (if it's not already there). Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/n/tip-7g3h86woz2sckg3h1lj42ygj@git.kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/ui/hist.c')
-rw-r--r--tools/perf/ui/hist.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0299385284fd..400437ee60b1 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -354,6 +354,14 @@ LIST_HEAD(perf_hpp__sort_list);
void perf_hpp__init(void)
{
+ struct list_head *list;
+ int i;
+
+ for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
+ INIT_LIST_HEAD(&perf_hpp__format[i].list);
+ INIT_LIST_HEAD(&perf_hpp__format[i].sort_list);
+ }
+
perf_hpp__column_enable(PERF_HPP__OVERHEAD);
if (symbol_conf.show_cpu_utilization) {
@@ -371,6 +379,13 @@ void perf_hpp__init(void)
if (symbol_conf.show_total_period)
perf_hpp__column_enable(PERF_HPP__PERIOD);
+
+ /* prepend overhead field for backward compatiblity. */
+ list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
+ if (list_empty(list))
+ list_add(list, &perf_hpp__sort_list);
+
+ perf_hpp__setup_output_field();
}
void perf_hpp__column_register(struct perf_hpp_fmt *format)
@@ -389,6 +404,17 @@ void perf_hpp__column_enable(unsigned col)
perf_hpp__column_register(&perf_hpp__format[col]);
}
+void perf_hpp__setup_output_field(void)
+{
+ struct perf_hpp_fmt *fmt;
+
+ /* append sort keys to output field */
+ perf_hpp__for_each_sort_list(fmt) {
+ if (list_empty(&fmt->list))
+ perf_hpp__column_register(fmt);
+ }
+}
+
int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
struct hists *hists)
{