[v1,04/10] perf stat: Modify the group test

Message ID 20230302041211.852330-5-irogers@google.com
State New
Headers
Series Better fixes for grouping of events |

Commit Message

Ian Rogers March 2, 2023, 4:12 a.m. UTC
  Previously nr_members would be 0 for an event with no group. The
previous change made that count 1, the event is its own leader without
a group. Make the find_stat logic consistent with this, an improvement
suggested by Namhyung Kim.

Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/stat-shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Arnaldo Carvalho de Melo March 2, 2023, 2:34 p.m. UTC | #1
Em Wed, Mar 01, 2023 at 08:12:05PM -0800, Ian Rogers escreveu:
> Previously nr_members would be 0 for an event with no group. The
> previous change made that count 1, the event is its own leader without
> a group. Make the find_stat logic consistent with this, an improvement
> suggested by Namhyung Kim.

Is this the only place where this change in behaviour needs to be taken
into account?

- Arnaldo
 
> Suggested-by: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/stat-shadow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> index ef85f1ae1ab2..eeccab6751d7 100644
> --- a/tools/perf/util/stat-shadow.c
> +++ b/tools/perf/util/stat-shadow.c
> @@ -163,7 +163,7 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type
>  			continue;
>  
>  		/* Ignore evsels that are part of different groups. */
> -		if (evsel->core.leader->nr_members &&
> +		if (evsel->core.leader->nr_members > 1 &&
>  		    evsel->core.leader != cur->core.leader)
>  			continue;
>  		/* Ignore evsels with mismatched modifiers. */
> -- 
> 2.39.2.722.g9855ee24e9-goog
>
  
Ian Rogers March 2, 2023, 4:10 p.m. UTC | #2
On Thu, Mar 2, 2023 at 6:34 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> Em Wed, Mar 01, 2023 at 08:12:05PM -0800, Ian Rogers escreveu:
> > Previously nr_members would be 0 for an event with no group. The
> > previous change made that count 1, the event is its own leader without
> > a group. Make the find_stat logic consistent with this, an improvement
> > suggested by Namhyung Kim.
>
> Is this the only place where this change in behaviour needs to be taken
> into account?
>
> - Arnaldo

Actually, I reordered the patches and so the review comment is off.
The nr_members change is in the sorting patch 9. I'll fix up the
comment. I did look for other uses and didn't spot any. I also think
we can add some kind of helper. The current evsel__is_leader functions
are weird. When thinking about the helper I couldn't think of a good
name as I want groups greater than size 1. I'll tweak this.

Thanks,
Ian

> > Suggested-by: Namhyung Kim <namhyung@kernel.org>
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/util/stat-shadow.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> > index ef85f1ae1ab2..eeccab6751d7 100644
> > --- a/tools/perf/util/stat-shadow.c
> > +++ b/tools/perf/util/stat-shadow.c
> > @@ -163,7 +163,7 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type
> >                       continue;
> >
> >               /* Ignore evsels that are part of different groups. */
> > -             if (evsel->core.leader->nr_members &&
> > +             if (evsel->core.leader->nr_members > 1 &&
> >                   evsel->core.leader != cur->core.leader)
> >                       continue;
> >               /* Ignore evsels with mismatched modifiers. */
> > --
> > 2.39.2.722.g9855ee24e9-goog
> >
>
> --
>
> - Arnaldo
  

Patch

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index ef85f1ae1ab2..eeccab6751d7 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -163,7 +163,7 @@  static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type
 			continue;
 
 		/* Ignore evsels that are part of different groups. */
-		if (evsel->core.leader->nr_members &&
+		if (evsel->core.leader->nr_members > 1 &&
 		    evsel->core.leader != cur->core.leader)
 			continue;
 		/* Ignore evsels with mismatched modifiers. */