Re: [PATCH 4/4] perf stat: Use group read for event groups

From: Jiri Olsa
Date: Mon Jul 24 2017 - 03:34:29 EST


On Sun, Jul 23, 2017 at 09:53:00AM +0900, Namhyung Kim wrote:

SNIP

> > Link: http://lkml.kernel.org/n/tip-b6g8qarwvptr81cqdtfst59u@xxxxxxxxxxxxxx
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> > tools/perf/builtin-stat.c | 30 +++++++++++++++++++++++++++---
> > tools/perf/util/counts.h | 1 +
> > tools/perf/util/evsel.c | 10 ++++++++++
> > 3 files changed, 38 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> > index 48ac53b199fc..866da7aa54bf 100644
> > --- a/tools/perf/builtin-stat.c
> > +++ b/tools/perf/builtin-stat.c
> > @@ -213,10 +213,20 @@ static void perf_stat__reset_stats(void)
> > static int create_perf_stat_counter(struct perf_evsel *evsel)
> > {
> > struct perf_event_attr *attr = &evsel->attr;
> > + struct perf_evsel *leader = evsel->leader;
> >
> > - if (stat_config.scale)
> > + if (stat_config.scale) {
> > attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
> > PERF_FORMAT_TOTAL_TIME_RUNNING;
> > + }
> > +
> > + /*
> > + * The event is part of non trivial group, let's enable
> > + * the group read (for leader) and ID retrieval for all
> > + * members.
> > + */
> > + if (leader->nr_members > 1)
> > + attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP;
>
> I just wonder ID is really necessary. Doesn't it have same order we
> can traverse with the for_each_group_member()?

right, but I don't like to rely on user and kernel space
order to stay the same.. I don't think it's guaranteed
in uapi

jirka