Commit db4b2840 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf sort: Fix the 'p_stage_cyc' sort key behavior

andle 'p_stage_cyc' (for pipeline stage cycles) sort key with the same
rationale as for the 'weight' and 'local_weight', see the fix in this
series for a full explanation.

Not sure it also needs the local and global variants.

But I couldn't test it actually because I don't have the machine.
Reviewed-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Tested-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20211105225617.151364-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4d03c753
...@@ -289,12 +289,10 @@ static long hist_time(unsigned long htime) ...@@ -289,12 +289,10 @@ static long hist_time(unsigned long htime)
return htime; return htime;
} }
static void he_stat__add_period(struct he_stat *he_stat, u64 period, static void he_stat__add_period(struct he_stat *he_stat, u64 period)
u64 p_stage_cyc)
{ {
he_stat->period += period; he_stat->period += period;
he_stat->nr_events += 1; he_stat->nr_events += 1;
he_stat->p_stage_cyc += p_stage_cyc;
} }
static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src) static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
...@@ -305,7 +303,6 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src) ...@@ -305,7 +303,6 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
dest->period_guest_sys += src->period_guest_sys; dest->period_guest_sys += src->period_guest_sys;
dest->period_guest_us += src->period_guest_us; dest->period_guest_us += src->period_guest_us;
dest->nr_events += src->nr_events; dest->nr_events += src->nr_events;
dest->p_stage_cyc += src->p_stage_cyc;
} }
static void he_stat__decay(struct he_stat *he_stat) static void he_stat__decay(struct he_stat *he_stat)
...@@ -593,7 +590,6 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists, ...@@ -593,7 +590,6 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
struct hist_entry *he; struct hist_entry *he;
int64_t cmp; int64_t cmp;
u64 period = entry->stat.period; u64 period = entry->stat.period;
u64 p_stage_cyc = entry->stat.p_stage_cyc;
bool leftmost = true; bool leftmost = true;
p = &hists->entries_in->rb_root.rb_node; p = &hists->entries_in->rb_root.rb_node;
...@@ -612,11 +608,11 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists, ...@@ -612,11 +608,11 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
if (!cmp) { if (!cmp) {
if (sample_self) { if (sample_self) {
he_stat__add_period(&he->stat, period, p_stage_cyc); he_stat__add_period(&he->stat, period);
hist_entry__add_callchain_period(he, period); hist_entry__add_callchain_period(he, period);
} }
if (symbol_conf.cumulate_callchain) if (symbol_conf.cumulate_callchain)
he_stat__add_period(he->stat_acc, period, p_stage_cyc); he_stat__add_period(he->stat_acc, period);
/* /*
* This mem info was allocated from sample__resolve_mem * This mem info was allocated from sample__resolve_mem
...@@ -726,7 +722,6 @@ __hists__add_entry(struct hists *hists, ...@@ -726,7 +722,6 @@ __hists__add_entry(struct hists *hists,
.stat = { .stat = {
.nr_events = 1, .nr_events = 1,
.period = sample->period, .period = sample->period,
.p_stage_cyc = sample->p_stage_cyc,
}, },
.parent = sym_parent, .parent = sym_parent,
.filtered = symbol__parent_filter(sym_parent) | al->filtered, .filtered = symbol__parent_filter(sym_parent) | al->filtered,
...@@ -741,6 +736,7 @@ __hists__add_entry(struct hists *hists, ...@@ -741,6 +736,7 @@ __hists__add_entry(struct hists *hists,
.time = hist_time(sample->time), .time = hist_time(sample->time),
.weight = sample->weight, .weight = sample->weight,
.ins_lat = sample->ins_lat, .ins_lat = sample->ins_lat,
.p_stage_cyc = sample->p_stage_cyc,
}, *he = hists__findnew_entry(hists, &entry, al, sample_self); }, *he = hists__findnew_entry(hists, &entry, al, sample_self);
if (!hists->has_callchains && he && he->callchain_size != 0) if (!hists->has_callchains && he && he->callchain_size != 0)
......
...@@ -1394,13 +1394,13 @@ struct sort_entry sort_global_ins_lat = { ...@@ -1394,13 +1394,13 @@ struct sort_entry sort_global_ins_lat = {
static int64_t static int64_t
sort__global_p_stage_cyc_cmp(struct hist_entry *left, struct hist_entry *right) sort__global_p_stage_cyc_cmp(struct hist_entry *left, struct hist_entry *right)
{ {
return left->stat.p_stage_cyc - right->stat.p_stage_cyc; return left->p_stage_cyc - right->p_stage_cyc;
} }
static int hist_entry__p_stage_cyc_snprintf(struct hist_entry *he, char *bf, static int hist_entry__p_stage_cyc_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width) size_t size, unsigned int width)
{ {
return repsep_snprintf(bf, size, "%-*u", width, he->stat.p_stage_cyc); return repsep_snprintf(bf, size, "%-*u", width, he->p_stage_cyc);
} }
struct sort_entry sort_p_stage_cyc = { struct sort_entry sort_p_stage_cyc = {
......
...@@ -49,7 +49,6 @@ struct he_stat { ...@@ -49,7 +49,6 @@ struct he_stat {
u64 period_us; u64 period_us;
u64 period_guest_sys; u64 period_guest_sys;
u64 period_guest_us; u64 period_guest_us;
u64 p_stage_cyc;
u32 nr_events; u32 nr_events;
}; };
...@@ -109,6 +108,7 @@ struct hist_entry { ...@@ -109,6 +108,7 @@ struct hist_entry {
u64 code_page_size; u64 code_page_size;
u64 weight; u64 weight;
u64 ins_lat; u64 ins_lat;
u64 p_stage_cyc;
u8 cpumode; u8 cpumode;
u8 depth; u8 depth;
......
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