Skip to content

Commit 4e1a096

Browse files
Andi Kleenacmel
authored andcommitted
perf stat: Don't use ctx for saved values lookup
We don't need to use ctx to look up events for saved values. The context is already part of the evsel pointer, which is the primary key. Signed-off-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 71b0acc commit 4e1a096

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

tools/perf/util/stat-shadow.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct saved_value {
5656
struct rb_node rb_node;
5757
struct perf_evsel *evsel;
5858
int cpu;
59-
int ctx;
6059
struct stats stats;
6160
};
6261

@@ -67,8 +66,6 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
6766
rb_node);
6867
const struct saved_value *b = entry;
6968

70-
if (a->ctx != b->ctx)
71-
return a->ctx - b->ctx;
7269
if (a->cpu != b->cpu)
7370
return a->cpu - b->cpu;
7471
if (a->evsel == b->evsel)
@@ -90,13 +87,12 @@ static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused,
9087
}
9188

9289
static struct saved_value *saved_value_lookup(struct perf_evsel *evsel,
93-
int cpu, int ctx,
90+
int cpu,
9491
bool create)
9592
{
9693
struct rb_node *nd;
9794
struct saved_value dm = {
9895
.cpu = cpu,
99-
.ctx = ctx,
10096
.evsel = evsel,
10197
};
10298
nd = rblist__find(&runtime_saved_values, &dm);
@@ -232,8 +228,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
232228
update_stats(&runtime_aperf_stats[ctx][cpu], count[0]);
233229

234230
if (counter->collect_stat) {
235-
struct saved_value *v = saved_value_lookup(counter, cpu, ctx,
236-
true);
231+
struct saved_value *v = saved_value_lookup(counter, cpu, true);
237232
update_stats(&v->stats, count[0]);
238233
}
239234
}
@@ -634,7 +629,6 @@ static void generic_metric(const char *metric_expr,
634629
const char *metric_name,
635630
double avg,
636631
int cpu,
637-
int ctx,
638632
struct perf_stat_output_ctx *out)
639633
{
640634
print_metric_t print_metric = out->print_metric;
@@ -648,7 +642,7 @@ static void generic_metric(const char *metric_expr,
648642
for (i = 0; metric_events[i]; i++) {
649643
struct saved_value *v;
650644

651-
v = saved_value_lookup(metric_events[i], cpu, ctx, false);
645+
v = saved_value_lookup(metric_events[i], cpu, false);
652646
if (!v)
653647
break;
654648
expr__add_id(&pctx, metric_events[i]->name, avg_stats(&v->stats));
@@ -866,7 +860,7 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
866860
print_metric(ctxp, NULL, NULL, name, 0);
867861
} else if (evsel->metric_expr) {
868862
generic_metric(evsel->metric_expr, evsel->metric_events, evsel->name,
869-
evsel->metric_name, avg, cpu, ctx, out);
863+
evsel->metric_name, avg, cpu, out);
870864
} else if (runtime_nsecs_stats[cpu].n != 0) {
871865
char unit = 'M';
872866
char unit_buf[10];
@@ -895,7 +889,7 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
895889
out->new_line(ctxp);
896890
generic_metric(mexp->metric_expr, mexp->metric_events,
897891
evsel->name, mexp->metric_name,
898-
avg, cpu, ctx, out);
892+
avg, cpu, out);
899893
}
900894
}
901895
if (num == 0)

0 commit comments

Comments
 (0)