Commit 5395a048 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf hists: Separate overhead and baseline columns

Currently the overhead and baseline columns are handled within single
function and the distinction is made by 'baseline hists' pointer passed
by 'struct perf_hpp::ptr'.

Since hists pointer is now part of each hist_entry, it's possible to
locate paired hists pointer directly from the passed struct hist_entry
pointer.

Also separating those 2 columns makes the code more obvious.
Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1349354994-17853-4-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent dd464345
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
/* hist period print (hpp) functions */ /* hist period print (hpp) functions */
static int hpp__header_overhead(struct perf_hpp *hpp) static int hpp__header_overhead(struct perf_hpp *hpp)
{ {
const char *fmt = hpp->ptr ? "Baseline" : "Overhead"; return scnprintf(hpp->buf, hpp->size, "Overhead");
return scnprintf(hpp->buf, hpp->size, fmt);
} }
static int hpp__width_overhead(struct perf_hpp *hpp __maybe_unused) static int hpp__width_overhead(struct perf_hpp *hpp __maybe_unused)
...@@ -22,17 +20,6 @@ static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he) ...@@ -22,17 +20,6 @@ static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he)
{ {
double percent = 100.0 * he->period / hpp->total_period; double percent = 100.0 * he->period / hpp->total_period;
if (hpp->ptr) {
struct hists *old_hists = hpp->ptr;
u64 total_period = old_hists->stats.total_period;
u64 base_period = he->pair ? he->pair->period : 0;
if (total_period)
percent = 100.0 * base_period / total_period;
else
percent = 0.0;
}
return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent);
} }
...@@ -41,17 +28,6 @@ static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) ...@@ -41,17 +28,6 @@ static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he)
double percent = 100.0 * he->period / hpp->total_period; double percent = 100.0 * he->period / hpp->total_period;
const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
if (hpp->ptr) {
struct hists *old_hists = hpp->ptr;
u64 total_period = old_hists->stats.total_period;
u64 base_period = he->pair ? he->pair->period : 0;
if (total_period)
percent = 100.0 * base_period / total_period;
else
percent = 0.0;
}
return scnprintf(hpp->buf, hpp->size, fmt, percent); return scnprintf(hpp->buf, hpp->size, fmt, percent);
} }
...@@ -159,6 +135,47 @@ static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp, ...@@ -159,6 +135,47 @@ static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp,
return scnprintf(hpp->buf, hpp->size, fmt, percent); return scnprintf(hpp->buf, hpp->size, fmt, percent);
} }
static int hpp__header_baseline(struct perf_hpp *hpp)
{
return scnprintf(hpp->buf, hpp->size, "Baseline");
}
static int hpp__width_baseline(struct perf_hpp *hpp __maybe_unused)
{
return 8;
}
static double baseline_percent(struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hists *pair_hists = pair ? pair->hists : NULL;
double percent = 0.0;
if (pair) {
u64 total_period = pair_hists->stats.total_period;
u64 base_period = pair->period;
percent = 100.0 * base_period / total_period;
}
return percent;
}
static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he)
{
double percent = baseline_percent(he);
return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent);
}
static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he)
{
double percent = baseline_percent(he);
const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
return scnprintf(hpp->buf, hpp->size, fmt, percent);
}
static int hpp__header_samples(struct perf_hpp *hpp) static int hpp__header_samples(struct perf_hpp *hpp)
{ {
const char *fmt = symbol_conf.field_sep ? "%s" : "%11s"; const char *fmt = symbol_conf.field_sep ? "%s" : "%11s";
...@@ -269,6 +286,7 @@ static int hpp__entry_displ(struct perf_hpp *hpp, ...@@ -269,6 +286,7 @@ static int hpp__entry_displ(struct perf_hpp *hpp,
.entry = hpp__entry_ ## _name .entry = hpp__entry_ ## _name
struct perf_hpp_fmt perf_hpp__format[] = { struct perf_hpp_fmt perf_hpp__format[] = {
{ .cond = false, HPP__COLOR_PRINT_FNS(baseline) },
{ .cond = true, HPP__COLOR_PRINT_FNS(overhead) }, { .cond = true, HPP__COLOR_PRINT_FNS(overhead) },
{ .cond = false, HPP__COLOR_PRINT_FNS(overhead_sys) }, { .cond = false, HPP__COLOR_PRINT_FNS(overhead_sys) },
{ .cond = false, HPP__COLOR_PRINT_FNS(overhead_us) }, { .cond = false, HPP__COLOR_PRINT_FNS(overhead_us) },
...@@ -302,6 +320,8 @@ void perf_hpp__init(bool need_pair, bool show_displacement) ...@@ -302,6 +320,8 @@ void perf_hpp__init(bool need_pair, bool show_displacement)
perf_hpp__format[PERF_HPP__PERIOD].cond = true; perf_hpp__format[PERF_HPP__PERIOD].cond = true;
if (need_pair) { if (need_pair) {
perf_hpp__format[PERF_HPP__OVERHEAD].cond = false;
perf_hpp__format[PERF_HPP__BASELINE].cond = true;
perf_hpp__format[PERF_HPP__DELTA].cond = true; perf_hpp__format[PERF_HPP__DELTA].cond = true;
if (show_displacement) if (show_displacement)
...@@ -321,6 +341,7 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -321,6 +341,7 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
const char *sep = symbol_conf.field_sep; const char *sep = symbol_conf.field_sep;
char *start = hpp->buf; char *start = hpp->buf;
int i, ret; int i, ret;
bool first = true;
if (symbol_conf.exclude_other && !he->parent) if (symbol_conf.exclude_other && !he->parent)
return 0; return 0;
...@@ -329,9 +350,10 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -329,9 +350,10 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
if (!perf_hpp__format[i].cond) if (!perf_hpp__format[i].cond)
continue; continue;
if (!sep || i > 0) { if (!sep || !first) {
ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " "); ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
advance_hpp(hpp, ret); advance_hpp(hpp, ret);
first = false;
} }
if (color && perf_hpp__format[i].color) if (color && perf_hpp__format[i].color)
......
...@@ -353,6 +353,7 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ...@@ -353,6 +353,7 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
.size = sizeof(bf), .size = sizeof(bf),
.ptr = pair, .ptr = pair,
}; };
bool first = true;
init_rem_hits(); init_rem_hits();
...@@ -364,8 +365,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ...@@ -364,8 +365,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
if (!perf_hpp__format[idx].cond) if (!perf_hpp__format[idx].cond)
continue; continue;
if (idx) if (!first)
fprintf(fp, "%s", sep ?: " "); fprintf(fp, "%s", sep ?: " ");
else
first = false;
perf_hpp__format[idx].header(&dummy_hpp); perf_hpp__format[idx].header(&dummy_hpp);
fprintf(fp, "%s", bf); fprintf(fp, "%s", bf);
...@@ -400,6 +403,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ...@@ -400,6 +403,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
if (sep) if (sep)
goto print_entries; goto print_entries;
first = true;
fprintf(fp, "# "); fprintf(fp, "# ");
for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) { for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) {
unsigned int i; unsigned int i;
...@@ -407,8 +412,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ...@@ -407,8 +412,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
if (!perf_hpp__format[idx].cond) if (!perf_hpp__format[idx].cond)
continue; continue;
if (idx) if (!first)
fprintf(fp, "%s", sep ?: " "); fprintf(fp, "%s", sep ?: " ");
else
first = false;
width = perf_hpp__format[idx].width(&dummy_hpp); width = perf_hpp__format[idx].width(&dummy_hpp);
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
......
...@@ -133,6 +133,7 @@ struct perf_hpp_fmt { ...@@ -133,6 +133,7 @@ struct perf_hpp_fmt {
extern struct perf_hpp_fmt perf_hpp__format[]; extern struct perf_hpp_fmt perf_hpp__format[];
enum { enum {
PERF_HPP__BASELINE,
PERF_HPP__OVERHEAD, PERF_HPP__OVERHEAD,
PERF_HPP__OVERHEAD_SYS, PERF_HPP__OVERHEAD_SYS,
PERF_HPP__OVERHEAD_US, PERF_HPP__OVERHEAD_US,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment