Re: [PATCH v3 1/2] perf stat: Introduce struct runtime_stat_data
Em Fri, Jan 15, 2021 at 09:37:44AM +0100, Jiri Olsa escreveu: > On Fri, Jan 15, 2021 at 04:11:38PM +0900, Namhyung Kim wrote: > > To pass more info to the saved_value in the runtime_stat, add a new > > struct runtime_stat_data. Currently it only has 'ctx' field but later > > patch will add more. > > > > Note that we intentionally pass 0 as ctx to clock-related events for > > compatibility. It was already there in a few places. So move the > > code into the saved_value_lookup() explicitly and add a comment. > > > > Suggested-by: Andi Kleen > > Signed-off-by: Namhyung Kim > > for the patchset > > Acked-by: Jiri Olsa Thanks, applied. - Arnaldo > thanks, > jirka > > > --- > > tools/perf/util/stat-shadow.c | 346 +- > > 1 file changed, 173 insertions(+), 173 deletions(-) > > > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c > > index 901265127e36..a1565b6e38f2 100644 > > --- a/tools/perf/util/stat-shadow.c > > +++ b/tools/perf/util/stat-shadow.c > > @@ -114,6 +114,10 @@ static struct saved_value *saved_value_lookup(struct > > evsel *evsel, > > > > rblist = &st->value_list; > > > > + /* don't use context info for clock events */ > > + if (type == STAT_NSECS) > > + dm.ctx = 0; > > + > > nd = rblist__find(rblist, &dm); > > if (nd) > > return container_of(nd, struct saved_value, rb_node); > > @@ -191,12 +195,17 @@ void perf_stat__reset_shadow_per_stat(struct > > runtime_stat *st) > > reset_stat(st); > > } > > > > +struct runtime_stat_data { > > + int ctx; > > +}; > > + > > static void update_runtime_stat(struct runtime_stat *st, > > enum stat_type type, > > - int ctx, int cpu, u64 count) > > + int cpu, u64 count, > > + struct runtime_stat_data *rsd) > > { > > - struct saved_value *v = saved_value_lookup(NULL, cpu, true, > > - type, ctx, st); > > + struct saved_value *v = saved_value_lookup(NULL, cpu, true, type, > > + rsd->ctx, st); > > > > if (v) > > update_stats(&v->stats, count); > > @@ -210,73 +219,75 @@ static void update_runtime_stat(struct runtime_stat > > *st, > > void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, > > int cpu, struct runtime_stat *st) > > { > > - int ctx = evsel_context(counter); > > u64 count_ns = count; > > struct saved_value *v; > > + struct runtime_stat_data rsd = { > > + .ctx = evsel_context(counter), > > + }; > > > > count *= counter->scale; > > > > if (evsel__is_clock(counter)) > > - update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns); > > + update_runtime_stat(st, STAT_NSECS, cpu, count_ns, &rsd); > > else if (evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) > > - update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count); > > + update_runtime_stat(st, STAT_CYCLES, cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) > > - update_runtime_stat(st, STAT_CYCLES_IN_TX, ctx, cpu, count); > > + update_runtime_stat(st, STAT_CYCLES_IN_TX, cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TRANSACTION_START)) > > - update_runtime_stat(st, STAT_TRANSACTION, ctx, cpu, count); > > + update_runtime_stat(st, STAT_TRANSACTION, cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, ELISION_START)) > > - update_runtime_stat(st, STAT_ELISION, ctx, cpu, count); > > + update_runtime_stat(st, STAT_ELISION, cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS)) > > update_runtime_stat(st, STAT_TOPDOWN_TOTAL_SLOTS, > > - ctx, cpu, count); > > + cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED)) > > update_runtime_stat(st, STAT_TOPDOWN_SLOTS_ISSUED, > > - ctx, cpu, count); > > + cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED)) > > update_runtime_stat(st, STAT_TOPDOWN_SLOTS_RETIRED, > > - ctx, cpu, count); > > + cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES)) > > update_runtime_stat(st, STAT_TOPDOWN_FETCH_BUBBLES, > > - ctx, cpu, count); > > + cpu, count, &rsd); > > else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES)) > > update_runtime_stat(st, STAT_TOPDOWN_RECOVERY_BUBBLES, > > - ctx, cpu, count); > > + cpu,
Re: [PATCH v3 1/2] perf stat: Introduce struct runtime_stat_data
On Fri, Jan 15, 2021 at 04:11:38PM +0900, Namhyung Kim wrote: > To pass more info to the saved_value in the runtime_stat, add a new > struct runtime_stat_data. Currently it only has 'ctx' field but later > patch will add more. > > Note that we intentionally pass 0 as ctx to clock-related events for > compatibility. It was already there in a few places. So move the > code into the saved_value_lookup() explicitly and add a comment. > > Suggested-by: Andi Kleen > Signed-off-by: Namhyung Kim for the patchset Acked-by: Jiri Olsa thanks, jirka > --- > tools/perf/util/stat-shadow.c | 346 +- > 1 file changed, 173 insertions(+), 173 deletions(-) > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c > index 901265127e36..a1565b6e38f2 100644 > --- a/tools/perf/util/stat-shadow.c > +++ b/tools/perf/util/stat-shadow.c > @@ -114,6 +114,10 @@ static struct saved_value *saved_value_lookup(struct > evsel *evsel, > > rblist = &st->value_list; > > + /* don't use context info for clock events */ > + if (type == STAT_NSECS) > + dm.ctx = 0; > + > nd = rblist__find(rblist, &dm); > if (nd) > return container_of(nd, struct saved_value, rb_node); > @@ -191,12 +195,17 @@ void perf_stat__reset_shadow_per_stat(struct > runtime_stat *st) > reset_stat(st); > } > > +struct runtime_stat_data { > + int ctx; > +}; > + > static void update_runtime_stat(struct runtime_stat *st, > enum stat_type type, > - int ctx, int cpu, u64 count) > + int cpu, u64 count, > + struct runtime_stat_data *rsd) > { > - struct saved_value *v = saved_value_lookup(NULL, cpu, true, > -type, ctx, st); > + struct saved_value *v = saved_value_lookup(NULL, cpu, true, type, > +rsd->ctx, st); > > if (v) > update_stats(&v->stats, count); > @@ -210,73 +219,75 @@ static void update_runtime_stat(struct runtime_stat *st, > void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, > int cpu, struct runtime_stat *st) > { > - int ctx = evsel_context(counter); > u64 count_ns = count; > struct saved_value *v; > + struct runtime_stat_data rsd = { > + .ctx = evsel_context(counter), > + }; > > count *= counter->scale; > > if (evsel__is_clock(counter)) > - update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns); > + update_runtime_stat(st, STAT_NSECS, cpu, count_ns, &rsd); > else if (evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) > - update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count); > + update_runtime_stat(st, STAT_CYCLES, cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) > - update_runtime_stat(st, STAT_CYCLES_IN_TX, ctx, cpu, count); > + update_runtime_stat(st, STAT_CYCLES_IN_TX, cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TRANSACTION_START)) > - update_runtime_stat(st, STAT_TRANSACTION, ctx, cpu, count); > + update_runtime_stat(st, STAT_TRANSACTION, cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, ELISION_START)) > - update_runtime_stat(st, STAT_ELISION, ctx, cpu, count); > + update_runtime_stat(st, STAT_ELISION, cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS)) > update_runtime_stat(st, STAT_TOPDOWN_TOTAL_SLOTS, > - ctx, cpu, count); > + cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED)) > update_runtime_stat(st, STAT_TOPDOWN_SLOTS_ISSUED, > - ctx, cpu, count); > + cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED)) > update_runtime_stat(st, STAT_TOPDOWN_SLOTS_RETIRED, > - ctx, cpu, count); > + cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES)) > update_runtime_stat(st, STAT_TOPDOWN_FETCH_BUBBLES, > - ctx, cpu, count); > + cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES)) > update_runtime_stat(st, STAT_TOPDOWN_RECOVERY_BUBBLES, > - ctx, cpu, count); > + cpu, count, &rsd); > else if (perf_stat_evsel__is(counter, TOPDOWN_RETIRING)) > update_runtime_stat(st, STAT_TOPDOWN_RETIRING, > - ctx, cpu, c
[PATCH v3 1/2] perf stat: Introduce struct runtime_stat_data
To pass more info to the saved_value in the runtime_stat, add a new struct runtime_stat_data. Currently it only has 'ctx' field but later patch will add more. Note that we intentionally pass 0 as ctx to clock-related events for compatibility. It was already there in a few places. So move the code into the saved_value_lookup() explicitly and add a comment. Suggested-by: Andi Kleen Signed-off-by: Namhyung Kim --- tools/perf/util/stat-shadow.c | 346 +- 1 file changed, 173 insertions(+), 173 deletions(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 901265127e36..a1565b6e38f2 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -114,6 +114,10 @@ static struct saved_value *saved_value_lookup(struct evsel *evsel, rblist = &st->value_list; + /* don't use context info for clock events */ + if (type == STAT_NSECS) + dm.ctx = 0; + nd = rblist__find(rblist, &dm); if (nd) return container_of(nd, struct saved_value, rb_node); @@ -191,12 +195,17 @@ void perf_stat__reset_shadow_per_stat(struct runtime_stat *st) reset_stat(st); } +struct runtime_stat_data { + int ctx; +}; + static void update_runtime_stat(struct runtime_stat *st, enum stat_type type, - int ctx, int cpu, u64 count) + int cpu, u64 count, + struct runtime_stat_data *rsd) { - struct saved_value *v = saved_value_lookup(NULL, cpu, true, - type, ctx, st); + struct saved_value *v = saved_value_lookup(NULL, cpu, true, type, + rsd->ctx, st); if (v) update_stats(&v->stats, count); @@ -210,73 +219,75 @@ static void update_runtime_stat(struct runtime_stat *st, void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, int cpu, struct runtime_stat *st) { - int ctx = evsel_context(counter); u64 count_ns = count; struct saved_value *v; + struct runtime_stat_data rsd = { + .ctx = evsel_context(counter), + }; count *= counter->scale; if (evsel__is_clock(counter)) - update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns); + update_runtime_stat(st, STAT_NSECS, cpu, count_ns, &rsd); else if (evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) - update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count); + update_runtime_stat(st, STAT_CYCLES, cpu, count, &rsd); else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) - update_runtime_stat(st, STAT_CYCLES_IN_TX, ctx, cpu, count); + update_runtime_stat(st, STAT_CYCLES_IN_TX, cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TRANSACTION_START)) - update_runtime_stat(st, STAT_TRANSACTION, ctx, cpu, count); + update_runtime_stat(st, STAT_TRANSACTION, cpu, count, &rsd); else if (perf_stat_evsel__is(counter, ELISION_START)) - update_runtime_stat(st, STAT_ELISION, ctx, cpu, count); + update_runtime_stat(st, STAT_ELISION, cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS)) update_runtime_stat(st, STAT_TOPDOWN_TOTAL_SLOTS, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED)) update_runtime_stat(st, STAT_TOPDOWN_SLOTS_ISSUED, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED)) update_runtime_stat(st, STAT_TOPDOWN_SLOTS_RETIRED, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES)) update_runtime_stat(st, STAT_TOPDOWN_FETCH_BUBBLES, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES)) update_runtime_stat(st, STAT_TOPDOWN_RECOVERY_BUBBLES, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_RETIRING)) update_runtime_stat(st, STAT_TOPDOWN_RETIRING, - ctx, cpu, count); + cpu, count, &rsd); else if (perf_stat_evsel__is(counter, TOPDOWN_BAD_SPEC)) update_runtime_stat(st, STAT_TOPDOWN_BAD_SPEC, -