[PATCH 08/37] perf hists: Introduce perf_hpp__list for period related columns

2012-12-11 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

Adding perf_hpp__list list to register and contain all period related
columns the command is interested in.

This way we get rid of static array holding all possible columns and
enable commands to register their own columns.

It'll be handy for diff command in future to process and display data
for multiple files.

Signed-off-by: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Paul Mackerras 
Cc: Corey Ashford 
Cc: Frederic Weisbecker 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/n/tip-kiykge4igrcl7etmpmvet...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-diff.c  |   21 -
 tools/perf/builtin-report.c|1 +
 tools/perf/ui/browsers/hists.c |   20 +
 tools/perf/ui/gtk/browser.c|   30 +
 tools/perf/ui/hist.c   |   96 ++--
 tools/perf/ui/setup.c  |1 +
 tools/perf/ui/stdio/hist.c |   17 +++
 tools/perf/util/hist.h |   11 -
 8 files changed, 101 insertions(+), 96 deletions(-)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 93b852f..9fbbc01 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -597,40 +597,35 @@ static const struct option options[] = {
 
 static void ui_init(void)
 {
-   perf_hpp__init();
-
-   /* No overhead column. */
-   perf_hpp__column_enable(PERF_HPP__OVERHEAD, false);
-
/*
 * Display baseline/delta/ratio/displacement/
 * formula/periods columns.
 */
-   perf_hpp__column_enable(PERF_HPP__BASELINE, true);
+   perf_hpp__column_enable(PERF_HPP__BASELINE);
 
switch (compute) {
case COMPUTE_DELTA:
-   perf_hpp__column_enable(PERF_HPP__DELTA, true);
+   perf_hpp__column_enable(PERF_HPP__DELTA);
break;
case COMPUTE_RATIO:
-   perf_hpp__column_enable(PERF_HPP__RATIO, true);
+   perf_hpp__column_enable(PERF_HPP__RATIO);
break;
case COMPUTE_WEIGHTED_DIFF:
-   perf_hpp__column_enable(PERF_HPP__WEIGHTED_DIFF, true);
+   perf_hpp__column_enable(PERF_HPP__WEIGHTED_DIFF);
break;
default:
BUG_ON(1);
};
 
if (show_displacement)
-   perf_hpp__column_enable(PERF_HPP__DISPL, true);
+   perf_hpp__column_enable(PERF_HPP__DISPL);
 
if (show_formula)
-   perf_hpp__column_enable(PERF_HPP__FORMULA, true);
+   perf_hpp__column_enable(PERF_HPP__FORMULA);
 
if (show_period) {
-   perf_hpp__column_enable(PERF_HPP__PERIOD, true);
-   perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE, true);
+   perf_hpp__column_enable(PERF_HPP__PERIOD);
+   perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE);
}
 }
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index fc25100..5134acf 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -692,6 +692,7 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
setup_browser(true);
else {
use_browser = 0;
+   perf_hpp__column_enable(PERF_HPP__OVERHEAD);
perf_hpp__init();
}
 
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ccc4bd1..57b82c2 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -587,6 +587,8 @@ HPP__COLOR_FN(overhead_guest_us, period_guest_us)
 
 void hist_browser__init_hpp(void)
 {
+   perf_hpp__column_enable(PERF_HPP__OVERHEAD);
+
perf_hpp__init();
 
perf_hpp__format[PERF_HPP__OVERHEAD].color =
@@ -607,12 +609,13 @@ static int hist_browser__show_entry(struct hist_browser 
*browser,
 {
char s[256];
double percent;
-   int i, printed = 0;
+   int printed = 0;
int width = browser->b.width;
char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(>b, row);
off_t row_offset = entry->row_offset;
bool first = true;
+   struct perf_hpp_fmt *fmt;
 
if (current_entry) {
browser->he_selection = entry;
@@ -629,12 +632,11 @@ static int hist_browser__show_entry(struct hist_browser 
*browser,
.buf= s,
.size   = sizeof(s),
};
+   int i = 0;
 
ui_browser__gotorc(>b, row, 0);
 
-   for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
-   if (!perf_hpp__format[i].cond)
-   continue;
+   perf_hpp__for_each_format(fmt) {
 
if (!first) {
slsmg_printf("  ");
@@ -642,14 +644,14 @@ static int hist_browser__show_entry(struct hist_browser 
*browser,

[PATCH 08/37] perf hists: Introduce perf_hpp__list for period related columns

2012-12-11 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa jo...@redhat.com

Adding perf_hpp__list list to register and contain all period related
columns the command is interested in.

This way we get rid of static array holding all possible columns and
enable commands to register their own columns.

It'll be handy for diff command in future to process and display data
for multiple files.

Signed-off-by: Jiri Olsa jo...@redhat.com
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Ingo Molnar mi...@elte.hu
Cc: Paul Mackerras pau...@samba.org
Cc: Corey Ashford cjash...@linux.vnet.ibm.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Namhyung Kim namhy...@kernel.org
Link: http://lkml.kernel.org/n/tip-kiykge4igrcl7etmpmvet...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-diff.c  |   21 -
 tools/perf/builtin-report.c|1 +
 tools/perf/ui/browsers/hists.c |   20 +
 tools/perf/ui/gtk/browser.c|   30 +
 tools/perf/ui/hist.c   |   96 ++--
 tools/perf/ui/setup.c  |1 +
 tools/perf/ui/stdio/hist.c |   17 +++
 tools/perf/util/hist.h |   11 -
 8 files changed, 101 insertions(+), 96 deletions(-)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 93b852f..9fbbc01 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -597,40 +597,35 @@ static const struct option options[] = {
 
 static void ui_init(void)
 {
-   perf_hpp__init();
-
-   /* No overhead column. */
-   perf_hpp__column_enable(PERF_HPP__OVERHEAD, false);
-
/*
 * Display baseline/delta/ratio/displacement/
 * formula/periods columns.
 */
-   perf_hpp__column_enable(PERF_HPP__BASELINE, true);
+   perf_hpp__column_enable(PERF_HPP__BASELINE);
 
switch (compute) {
case COMPUTE_DELTA:
-   perf_hpp__column_enable(PERF_HPP__DELTA, true);
+   perf_hpp__column_enable(PERF_HPP__DELTA);
break;
case COMPUTE_RATIO:
-   perf_hpp__column_enable(PERF_HPP__RATIO, true);
+   perf_hpp__column_enable(PERF_HPP__RATIO);
break;
case COMPUTE_WEIGHTED_DIFF:
-   perf_hpp__column_enable(PERF_HPP__WEIGHTED_DIFF, true);
+   perf_hpp__column_enable(PERF_HPP__WEIGHTED_DIFF);
break;
default:
BUG_ON(1);
};
 
if (show_displacement)
-   perf_hpp__column_enable(PERF_HPP__DISPL, true);
+   perf_hpp__column_enable(PERF_HPP__DISPL);
 
if (show_formula)
-   perf_hpp__column_enable(PERF_HPP__FORMULA, true);
+   perf_hpp__column_enable(PERF_HPP__FORMULA);
 
if (show_period) {
-   perf_hpp__column_enable(PERF_HPP__PERIOD, true);
-   perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE, true);
+   perf_hpp__column_enable(PERF_HPP__PERIOD);
+   perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE);
}
 }
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index fc25100..5134acf 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -692,6 +692,7 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
setup_browser(true);
else {
use_browser = 0;
+   perf_hpp__column_enable(PERF_HPP__OVERHEAD);
perf_hpp__init();
}
 
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ccc4bd1..57b82c2 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -587,6 +587,8 @@ HPP__COLOR_FN(overhead_guest_us, period_guest_us)
 
 void hist_browser__init_hpp(void)
 {
+   perf_hpp__column_enable(PERF_HPP__OVERHEAD);
+
perf_hpp__init();
 
perf_hpp__format[PERF_HPP__OVERHEAD].color =
@@ -607,12 +609,13 @@ static int hist_browser__show_entry(struct hist_browser 
*browser,
 {
char s[256];
double percent;
-   int i, printed = 0;
+   int printed = 0;
int width = browser-b.width;
char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(browser-b, row);
off_t row_offset = entry-row_offset;
bool first = true;
+   struct perf_hpp_fmt *fmt;
 
if (current_entry) {
browser-he_selection = entry;
@@ -629,12 +632,11 @@ static int hist_browser__show_entry(struct hist_browser 
*browser,
.buf= s,
.size   = sizeof(s),
};
+   int i = 0;
 
ui_browser__gotorc(browser-b, row, 0);
 
-   for (i = 0; i  PERF_HPP__MAX_INDEX; i++) {
-   if (!perf_hpp__format[i].cond)
-   continue;
+   perf_hpp__for_each_format(fmt) {