linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf test: Fix session topology test on heterogeneous systems
@ 2024-01-22 15:54 James Clark
  2024-01-22 15:58 ` James Clark
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: James Clark @ 2024-01-22 15:54 UTC (permalink / raw)
  To: linux-perf-users, mark.rutland, irogers
  Cc: James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Adrian Hunter, Kan Liang, Yang Jihong, Changbin Du,
	linux-kernel

The test currently fails with this message when evlist__new_default()
opens more than one event:

  32: Session topology                                                :
  --- start ---
  templ file: /tmp/perf-test-vv5YzZ
  Using CPUID 0x00000000410fd070
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xb00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xa00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
  non matching sample_type
  FAILED tests/topology.c:73 can't get session
  ---- end ----
  Session topology: FAILED!

This is because when re-opening the file and parsing the header, Perf
expects that any file that has more than one event has the session ID
flag set. Perf record already sets the flag in a similar way when there
is more than one event, so add the same logic to evlist__new_default().

evlist__new_default() is only currently used in tests, so I don't
expect this change to have any other side effects.

The session topology test has been failing on Arm big.LITTLE platforms
since commit 251aa040244a ("perf parse-events: Wildcard most
"numeric" events") when evlist__new_default() started opening multiple
events for 'cycles'.

Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
Signed-off-by: James Clark <james.clark@arm.com>
---
 tools/perf/util/evlist.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 95f25e9fb994..56db37fac6f6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void)
 	struct evlist *evlist = evlist__new();
 	bool can_profile_kernel;
 	int err;
+	struct evsel *evsel;
 
 	if (!evlist)
 		return NULL;
@@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void)
 		evlist = NULL;
 	}
 
+	if (evlist->core.nr_entries > 1)
+		evlist__for_each_entry(evlist, evsel)
+			evsel__set_sample_id(evsel, false);
+
 	return evlist;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] perf test: Fix session topology test on heterogeneous systems
  2024-01-22 15:54 [PATCH] perf test: Fix session topology test on heterogeneous systems James Clark
@ 2024-01-22 15:58 ` James Clark
  2024-01-22 16:41 ` Liang, Kan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: James Clark @ 2024-01-22 15:58 UTC (permalink / raw)
  To: linux-perf-users, mark.rutland, irogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, Yang Jihong, Changbin Du, linux-kernel



On 22/01/2024 15:54, James Clark wrote:
> The test currently fails with this message when evlist__new_default()
> opens more than one event:
> 
>   32: Session topology                                                :
>   --- start ---
>   templ file: /tmp/perf-test-vv5YzZ
>   Using CPUID 0x00000000410fd070
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xb00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xa00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
>   non matching sample_type
>   FAILED tests/topology.c:73 can't get session
>   ---- end ----
>   Session topology: FAILED!
> 
> This is because when re-opening the file and parsing the header, Perf
> expects that any file that has more than one event has the session ID

session ID -> sample ID

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] perf test: Fix session topology test on heterogeneous systems
  2024-01-22 15:54 [PATCH] perf test: Fix session topology test on heterogeneous systems James Clark
  2024-01-22 15:58 ` James Clark
@ 2024-01-22 16:41 ` Liang, Kan
  2024-01-22 17:09 ` Ian Rogers
  2024-01-23 10:27 ` [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU James Clark
  3 siblings, 0 replies; 11+ messages in thread
From: Liang, Kan @ 2024-01-22 16:41 UTC (permalink / raw)
  To: James Clark, linux-perf-users, mark.rutland, irogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Yang Jihong, Changbin Du, linux-kernel



On 2024-01-22 10:54 a.m., James Clark wrote:
> The test currently fails with this message when evlist__new_default()
> opens more than one event:
> 
>   32: Session topology                                                :
>   --- start ---
>   templ file: /tmp/perf-test-vv5YzZ
>   Using CPUID 0x00000000410fd070
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xb00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xa00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
>   non matching sample_type
>   FAILED tests/topology.c:73 can't get session
>   ---- end ----
>   Session topology: FAILED!
> 
> This is because when re-opening the file and parsing the header, Perf
> expects that any file that has more than one event has the session ID
> flag set. Perf record already sets the flag in a similar way when there
> is more than one event, so add the same logic to evlist__new_default().
> 
> evlist__new_default() is only currently used in tests, so I don't
> expect this change to have any other side effects.
> 
> The session topology test has been failing on Arm big.LITTLE platforms
> since commit 251aa040244a ("perf parse-events: Wildcard most
> "numeric" events") when evlist__new_default() started opening multiple
> events for 'cycles'.
> 
> Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
> Signed-off-by: James Clark <james.clark@arm.com>
Verified on an Intel hybrid machine.

Tested-by: Kan Liang <kan.liang@linux.intel.com>

Thanks,
Kan


> ---
>  tools/perf/util/evlist.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 95f25e9fb994..56db37fac6f6 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void)
>  	struct evlist *evlist = evlist__new();
>  	bool can_profile_kernel;
>  	int err;
> +	struct evsel *evsel;
>  
>  	if (!evlist)
>  		return NULL;
> @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void)
>  		evlist = NULL;
>  	}
>  
> +	if (evlist->core.nr_entries > 1)
> +		evlist__for_each_entry(evlist, evsel)
> +			evsel__set_sample_id(evsel, false);
> +
>  	return evlist;
>  }
>  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] perf test: Fix session topology test on heterogeneous systems
  2024-01-22 15:54 [PATCH] perf test: Fix session topology test on heterogeneous systems James Clark
  2024-01-22 15:58 ` James Clark
  2024-01-22 16:41 ` Liang, Kan
@ 2024-01-22 17:09 ` Ian Rogers
  2024-01-23  0:09   ` Ian Rogers
  2024-01-23 10:27 ` [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU James Clark
  3 siblings, 1 reply; 11+ messages in thread
From: Ian Rogers @ 2024-01-22 17:09 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, mark.rutland, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Adrian Hunter, Kan Liang, Yang Jihong, Changbin Du,
	linux-kernel

Hi James, I think the subject should be something like "perf evlist:
Fix new_default for >1 core PMU" as the change will apply more widely
than just the test. The test failure fix can be in the subject. You
could add a:

Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/

On Mon, Jan 22, 2024 at 7:55 AM James Clark <james.clark@arm.com> wrote:
>
> The test currently fails with this message when evlist__new_default()
> opens more than one event:
>
>   32: Session topology                                                :
>   --- start ---
>   templ file: /tmp/perf-test-vv5YzZ
>   Using CPUID 0x00000000410fd070
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xb00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xa00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
>   non matching sample_type
>   FAILED tests/topology.c:73 can't get session
>   ---- end ----
>   Session topology: FAILED!
>
> This is because when re-opening the file and parsing the header, Perf
> expects that any file that has more than one event has the session ID
> flag set. Perf record already sets the flag in a similar way when there
> is more than one event, so add the same logic to evlist__new_default().
>
> evlist__new_default() is only currently used in tests, so I don't
> expect this change to have any other side effects.
>
> The session topology test has been failing on Arm big.LITTLE platforms
> since commit 251aa040244a ("perf parse-events: Wildcard most
> "numeric" events") when evlist__new_default() started opening multiple
> events for 'cycles'.
>
> Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
>  tools/perf/util/evlist.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 95f25e9fb994..56db37fac6f6 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void)
>         struct evlist *evlist = evlist__new();
>         bool can_profile_kernel;
>         int err;
> +       struct evsel *evsel;
>
>         if (!evlist)
>                 return NULL;
> @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void)
>                 evlist = NULL;
>         }
>
> +       if (evlist->core.nr_entries > 1)
> +               evlist__for_each_entry(evlist, evsel)
> +                       evsel__set_sample_id(evsel, false);
> +

nit: the if should have curlies, with them we can reduce the scope of
evsel like below. It is also nice for constants to name the arguments
[1].

if (evlist->core.nr_entries > 1) {
    struct evsel *evsel;

    evlist__for_each_entry(evlist, evsel)
        evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
}

Tested-by: Ian Rogers <irogers@google.com>
(also Reviewed-by)

When testing with this with Mark's change [2] I see on alderlake two failures:
```
irogers@alderlake:~$ perf test 74 -vv
Couldn't bump rlimit(MEMLOCK), failures may take place when creating
BPF maps, etc
74: daemon operations                                               :
--- start ---
test child forked, pid 553821
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [554082]'
signal 12 sent to session 'test [554082]'
FAILED: perf data no generated
test daemon ping
test daemon lock
test child finished with -1
---- end ----
daemon operations: FAILED!
irogers@alderlake:~$ perf test 76 -vv
Couldn't bump rlimit(MEMLOCK), failures may take place when creating
BPF maps, etc
76: perf list tests                                                 :
--- start ---
test child forked, pid 554167
Json output test
Expecting ',' delimiter: line 4971 column 2 (char 243497)
test child finished with -1
---- end ----
perf list tests: FAILED!
```
So I think this patch may be exposing other latent issues. I'll try to
take a look.

Another thought, rather than having an evlist validate we should just
assert the evlist is always in a good shape whenever it is mutated.
That would have avoided this bug as the code would have blown up
early.

Thanks,
Ian

[1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html
[2] https://lore.kernel.org/lkml/20240116170348.463479-1-mark.rutland@arm.com/

>         return evlist;
>  }


>
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] perf test: Fix session topology test on heterogeneous systems
  2024-01-22 17:09 ` Ian Rogers
@ 2024-01-23  0:09   ` Ian Rogers
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Rogers @ 2024-01-23  0:09 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, mark.rutland, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Adrian Hunter, Kan Liang, Yang Jihong, Changbin Du,
	linux-kernel

On Mon, Jan 22, 2024 at 9:09 AM Ian Rogers <irogers@google.com> wrote:
>
> Hi James, I think the subject should be something like "perf evlist:
> Fix new_default for >1 core PMU" as the change will apply more widely
> than just the test. The test failure fix can be in the subject. You
> could add a:
>
> Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/
>
> On Mon, Jan 22, 2024 at 7:55 AM James Clark <james.clark@arm.com> wrote:
> >
> > The test currently fails with this message when evlist__new_default()
> > opens more than one event:
> >
> >   32: Session topology                                                :
> >   --- start ---
> >   templ file: /tmp/perf-test-vv5YzZ
> >   Using CPUID 0x00000000410fd070
> >   Opening: unknown-hardware:HG
> >   ------------------------------------------------------------
> >   perf_event_attr:
> >     type                             0 (PERF_TYPE_HARDWARE)
> >     config                           0xb00000000
> >     disabled                         1
> >   ------------------------------------------------------------
> >   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
> >   Opening: unknown-hardware:HG
> >   ------------------------------------------------------------
> >   perf_event_attr:
> >     type                             0 (PERF_TYPE_HARDWARE)
> >     config                           0xa00000000
> >     disabled                         1
> >   ------------------------------------------------------------
> >   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
> >   non matching sample_type
> >   FAILED tests/topology.c:73 can't get session
> >   ---- end ----
> >   Session topology: FAILED!
> >
> > This is because when re-opening the file and parsing the header, Perf
> > expects that any file that has more than one event has the session ID
> > flag set. Perf record already sets the flag in a similar way when there
> > is more than one event, so add the same logic to evlist__new_default().
> >
> > evlist__new_default() is only currently used in tests, so I don't
> > expect this change to have any other side effects.
> >
> > The session topology test has been failing on Arm big.LITTLE platforms
> > since commit 251aa040244a ("perf parse-events: Wildcard most
> > "numeric" events") when evlist__new_default() started opening multiple
> > events for 'cycles'.
> >
> > Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
> > Signed-off-by: James Clark <james.clark@arm.com>
> > ---
> >  tools/perf/util/evlist.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> > index 95f25e9fb994..56db37fac6f6 100644
> > --- a/tools/perf/util/evlist.c
> > +++ b/tools/perf/util/evlist.c
> > @@ -95,6 +95,7 @@ struct evlist *evlist__new_default(void)
> >         struct evlist *evlist = evlist__new();
> >         bool can_profile_kernel;
> >         int err;
> > +       struct evsel *evsel;
> >
> >         if (!evlist)
> >                 return NULL;
> > @@ -106,6 +107,10 @@ struct evlist *evlist__new_default(void)
> >                 evlist = NULL;
> >         }
> >
> > +       if (evlist->core.nr_entries > 1)
> > +               evlist__for_each_entry(evlist, evsel)
> > +                       evsel__set_sample_id(evsel, false);
> > +
>
> nit: the if should have curlies, with them we can reduce the scope of
> evsel like below. It is also nice for constants to name the arguments
> [1].
>
> if (evlist->core.nr_entries > 1) {
>     struct evsel *evsel;
>
>     evlist__for_each_entry(evlist, evsel)
>         evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
> }
>
> Tested-by: Ian Rogers <irogers@google.com>
> (also Reviewed-by)
>
> When testing with this with Mark's change [2] I see on alderlake two failures:
> ```
> irogers@alderlake:~$ perf test 74 -vv
> Couldn't bump rlimit(MEMLOCK), failures may take place when creating
> BPF maps, etc
> 74: daemon operations                                               :
> --- start ---
> test child forked, pid 553821
> test daemon list
> test daemon reconfig
> test daemon stop
> test daemon signal
> signal 12 sent to session 'test [554082]'
> signal 12 sent to session 'test [554082]'
> FAILED: perf data no generated
> test daemon ping
> test daemon lock
> test child finished with -1
> ---- end ----
> daemon operations: FAILED!
> irogers@alderlake:~$ perf test 76 -vv
> Couldn't bump rlimit(MEMLOCK), failures may take place when creating
> BPF maps, etc
> 76: perf list tests                                                 :
> --- start ---
> test child forked, pid 554167
> Json output test
> Expecting ',' delimiter: line 4971 column 2 (char 243497)
> test child finished with -1
> ---- end ----
> perf list tests: FAILED!
> ```
> So I think this patch may be exposing other latent issues. I'll try to
> take a look.

Unrelated issues to this patch, fixes in:
https://lore.kernel.org/lkml/20240123000604.1211486-1-irogers@google.com/

Thanks,
Ian

> Another thought, rather than having an evlist validate we should just
> assert the evlist is always in a good shape whenever it is mutated.
> That would have avoided this bug as the code would have blown up
> early.
>
> Thanks,
> Ian
>
> [1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html
> [2] https://lore.kernel.org/lkml/20240116170348.463479-1-mark.rutland@arm.com/
>
> >         return evlist;
> >  }
>
>
> >
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-22 15:54 [PATCH] perf test: Fix session topology test on heterogeneous systems James Clark
                   ` (2 preceding siblings ...)
  2024-01-22 17:09 ` Ian Rogers
@ 2024-01-23 10:27 ` James Clark
  2024-01-23 10:39   ` [PATCH v3] " James Clark
  3 siblings, 1 reply; 11+ messages in thread
From: James Clark @ 2024-01-23 10:27 UTC (permalink / raw)
  To: linux-perf-users, irogers, kan.liang
  Cc: mark.rutland, James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Adrian Hunter, Changbin Du, Yang Jihong, linux-kernel

The 'Session topology' test currently fails with this message when
evlist__new_default() opens more than one event:

  32: Session topology                                                :
  --- start ---
  templ file: /tmp/perf-test-vv5YzZ
  Using CPUID 0x00000000410fd070
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xb00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xa00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
  non matching sample_type
  FAILED tests/topology.c:73 can't get session
  ---- end ----
  Session topology: FAILED!

This is because when re-opening the file and parsing the header, Perf
expects that any file that has more than one event has the sample ID
flag set. Perf record already sets the flag in a similar way when there
is more than one event, so add the same logic to evlist__new_default().

evlist__new_default() is only currently used in tests, so I don't
expect this change to have any other side effects. The other tests that
use it don't save and re-open the file so don't hit this issue.

The session topology test has been failing on Arm big.LITTLE platforms
since commit 251aa040244a ("perf parse-events: Wildcard most
"numeric" events") when evlist__new_default() started opening multiple
events for 'cycles'.

Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/
Tested-by: Ian Rogers <irogers@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 tools/perf/util/evlist.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Changes since v1:

  * Reduce scope of evsel variable
  * Add argument label
  * Change summary to be less specific about the failing test
  * Add the closes: tag

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 56db37fac6f6..979a6053a84d 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -95,7 +95,6 @@ struct evlist *evlist__new_default(void)
 	struct evlist *evlist = evlist__new();
 	bool can_profile_kernel;
 	int err;
-	struct evsel *evsel;
 
 	if (!evlist)
 		return NULL;
@@ -107,9 +106,12 @@ struct evlist *evlist__new_default(void)
 		evlist = NULL;
 	}
 
-	if (evlist->core.nr_entries > 1)
+	if (evlist->core.nr_entries > 1) {
+		struct evsel *evsel;
+
 		evlist__for_each_entry(evlist, evsel)
-			evsel__set_sample_id(evsel, false);
+			evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
+	}
 
 	return evlist;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-23 10:27 ` [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU James Clark
@ 2024-01-23 10:39   ` James Clark
  2024-01-24  0:46     ` Namhyung Kim
  0 siblings, 1 reply; 11+ messages in thread
From: James Clark @ 2024-01-23 10:39 UTC (permalink / raw)
  To: linux-perf-users, irogers, kan.liang
  Cc: mark.rutland, James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Adrian Hunter, Changbin Du, Yang Jihong, linux-kernel

The 'Session topology' test currently fails with this message when
evlist__new_default() opens more than one event:

  32: Session topology                                                :
  --- start ---
  templ file: /tmp/perf-test-vv5YzZ
  Using CPUID 0x00000000410fd070
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xb00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
  Opening: unknown-hardware:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xa00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
  non matching sample_type
  FAILED tests/topology.c:73 can't get session
  ---- end ----
  Session topology: FAILED!

This is because when re-opening the file and parsing the header, Perf
expects that any file that has more than one event has the sample ID
flag set. Perf record already sets the flag in a similar way when there
is more than one event, so add the same logic to evlist__new_default().

evlist__new_default() is only currently used in tests, so I don't
expect this change to have any other side effects. The other tests that
use it don't save and re-open the file so don't hit this issue.

The session topology test has been failing on Arm big.LITTLE platforms
since commit 251aa040244a ("perf parse-events: Wildcard most
"numeric" events") when evlist__new_default() started opening multiple
events for 'cycles'.

Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/
Tested-by: Ian Rogers <irogers@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 tools/perf/util/evlist.c | 7 +++++++
 1 file changed, 7 insertions(+)

Changes since v2:

   * Undo the fact that v2 was accidentally based on v1 instead of
     perf-tools

Changes since v1:

  * Reduce scope of evsel variable
  * Add argument label
  * Change summary to be less specific about the failing test
  * Add the closes: tag

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 95f25e9fb994..979a6053a84d 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -106,6 +106,13 @@ struct evlist *evlist__new_default(void)
 		evlist = NULL;
 	}
 
+	if (evlist->core.nr_entries > 1) {
+		struct evsel *evsel;
+
+		evlist__for_each_entry(evlist, evsel)
+			evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
+	}
+
 	return evlist;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-23 10:39   ` [PATCH v3] " James Clark
@ 2024-01-24  0:46     ` Namhyung Kim
  2024-01-24  9:03       ` James Clark
  0 siblings, 1 reply; 11+ messages in thread
From: Namhyung Kim @ 2024-01-24  0:46 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, irogers, kan.liang, mark.rutland,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Changbin Du,
	Yang Jihong, linux-kernel

Hi James,

On Tue, Jan 23, 2024 at 2:39 AM James Clark <james.clark@arm.com> wrote:
>
> The 'Session topology' test currently fails with this message when
> evlist__new_default() opens more than one event:
>
>   32: Session topology                                                :
>   --- start ---
>   templ file: /tmp/perf-test-vv5YzZ
>   Using CPUID 0x00000000410fd070
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xb00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
>   Opening: unknown-hardware:HG
>   ------------------------------------------------------------
>   perf_event_attr:
>     type                             0 (PERF_TYPE_HARDWARE)
>     config                           0xa00000000
>     disabled                         1
>   ------------------------------------------------------------
>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
>   non matching sample_type
>   FAILED tests/topology.c:73 can't get session
>   ---- end ----
>   Session topology: FAILED!
>
> This is because when re-opening the file and parsing the header, Perf
> expects that any file that has more than one event has the sample ID
> flag set. Perf record already sets the flag in a similar way when there
> is more than one event, so add the same logic to evlist__new_default().
>
> evlist__new_default() is only currently used in tests, so I don't
> expect this change to have any other side effects. The other tests that
> use it don't save and re-open the file so don't hit this issue.
>
> The session topology test has been failing on Arm big.LITTLE platforms
> since commit 251aa040244a ("perf parse-events: Wildcard most
> "numeric" events") when evlist__new_default() started opening multiple
> events for 'cycles'.
>
> Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
> Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/
> Tested-by: Ian Rogers <irogers@google.com>
> Reviewed-by: Ian Rogers <irogers@google.com>
> Tested-by: Kan Liang <kan.liang@linux.intel.com>
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
>  tools/perf/util/evlist.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> Changes since v2:
>
>    * Undo the fact that v2 was accidentally based on v1 instead of
>      perf-tools
>
> Changes since v1:
>
>   * Reduce scope of evsel variable
>   * Add argument label
>   * Change summary to be less specific about the failing test
>   * Add the closes: tag
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 95f25e9fb994..979a6053a84d 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -106,6 +106,13 @@ struct evlist *evlist__new_default(void)
>                 evlist = NULL;
>         }
>
> +       if (evlist->core.nr_entries > 1) {

I think you need a NULL check for evlist here.

Thanks,
Namhyung


> +               struct evsel *evsel;
> +
> +               evlist__for_each_entry(evlist, evsel)
> +                       evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
> +       }
> +
>         return evlist;
>  }
>
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-24  0:46     ` Namhyung Kim
@ 2024-01-24  9:03       ` James Clark
  2024-01-26 16:25         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 11+ messages in thread
From: James Clark @ 2024-01-24  9:03 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: linux-perf-users, irogers, kan.liang, mark.rutland,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Changbin Du,
	Yang Jihong, linux-kernel



On 24/01/2024 00:46, Namhyung Kim wrote:
> Hi James,
> 
> On Tue, Jan 23, 2024 at 2:39 AM James Clark <james.clark@arm.com> wrote:
>>
>> The 'Session topology' test currently fails with this message when
>> evlist__new_default() opens more than one event:
>>
>>   32: Session topology                                                :
>>   --- start ---
>>   templ file: /tmp/perf-test-vv5YzZ
>>   Using CPUID 0x00000000410fd070
>>   Opening: unknown-hardware:HG
>>   ------------------------------------------------------------
>>   perf_event_attr:
>>     type                             0 (PERF_TYPE_HARDWARE)
>>     config                           0xb00000000
>>     disabled                         1
>>   ------------------------------------------------------------
>>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 4
>>   Opening: unknown-hardware:HG
>>   ------------------------------------------------------------
>>   perf_event_attr:
>>     type                             0 (PERF_TYPE_HARDWARE)
>>     config                           0xa00000000
>>     disabled                         1
>>   ------------------------------------------------------------
>>   sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 5
>>   non matching sample_type
>>   FAILED tests/topology.c:73 can't get session
>>   ---- end ----
>>   Session topology: FAILED!
>>
>> This is because when re-opening the file and parsing the header, Perf
>> expects that any file that has more than one event has the sample ID
>> flag set. Perf record already sets the flag in a similar way when there
>> is more than one event, so add the same logic to evlist__new_default().
>>
>> evlist__new_default() is only currently used in tests, so I don't
>> expect this change to have any other side effects. The other tests that
>> use it don't save and re-open the file so don't hit this issue.
>>
>> The session topology test has been failing on Arm big.LITTLE platforms
>> since commit 251aa040244a ("perf parse-events: Wildcard most
>> "numeric" events") when evlist__new_default() started opening multiple
>> events for 'cycles'.
>>
>> Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
>> Closes: https://lore.kernel.org/lkml/CAP-5=fWVQ-7ijjK3-w1q+k2WYVNHbAcejb-xY0ptbjRw476VKA@mail.gmail.com/
>> Tested-by: Ian Rogers <irogers@google.com>
>> Reviewed-by: Ian Rogers <irogers@google.com>
>> Tested-by: Kan Liang <kan.liang@linux.intel.com>
>> Signed-off-by: James Clark <james.clark@arm.com>
>> ---
>>  tools/perf/util/evlist.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> Changes since v2:
>>
>>    * Undo the fact that v2 was accidentally based on v1 instead of
>>      perf-tools
>>
>> Changes since v1:
>>
>>   * Reduce scope of evsel variable
>>   * Add argument label
>>   * Change summary to be less specific about the failing test
>>   * Add the closes: tag
>>
>> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
>> index 95f25e9fb994..979a6053a84d 100644
>> --- a/tools/perf/util/evlist.c
>> +++ b/tools/perf/util/evlist.c
>> @@ -106,6 +106,13 @@ struct evlist *evlist__new_default(void)
>>                 evlist = NULL;
>>         }
>>
>> +       if (evlist->core.nr_entries > 1) {
> 
> I think you need a NULL check for evlist here.
> 
> Thanks,
> Namhyung
> 
> 

Oops yes. Or just return on the error above.

>> +               struct evsel *evsel;
>> +
>> +               evlist__for_each_entry(evlist, evsel)
>> +                       evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
>> +       }
>> +
>>         return evlist;
>>  }
>>
>> --
>> 2.34.1
>>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-24  9:03       ` James Clark
@ 2024-01-26 16:25         ` Arnaldo Carvalho de Melo
  2024-01-26 20:49           ` Namhyung Kim
  0 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-01-26 16:25 UTC (permalink / raw)
  To: James Clark
  Cc: Namhyung Kim, linux-perf-users, irogers, kan.liang, mark.rutland,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, Changbin Du, Yang Jihong, linux-kernel

Em Wed, Jan 24, 2024 at 09:03:57AM +0000, James Clark escreveu:
> On 24/01/2024 00:46, Namhyung Kim wrote:
> > On Tue, Jan 23, 2024 at 2:39 AM James Clark <james.clark@arm.com> wrote:
> >> +++ b/tools/perf/util/evlist.c
> >> @@ -106,6 +106,13 @@ struct evlist *evlist__new_default(void)
> >>                 evlist = NULL;
> >>         }

> >> +       if (evlist->core.nr_entries > 1) {

> > I think you need a NULL check for evlist here.
 
> Oops yes. Or just return on the error above.

Was there a v4? I'm assuming this is for perf-tools, i.e. for v6.8-rc,
right?

- Arnaldo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] perf evlist: Fix evlist__new_default() for > 1 core PMU
  2024-01-26 16:25         ` Arnaldo Carvalho de Melo
@ 2024-01-26 20:49           ` Namhyung Kim
  0 siblings, 0 replies; 11+ messages in thread
From: Namhyung Kim @ 2024-01-26 20:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: James Clark, linux-perf-users, irogers, kan.liang, mark.rutland,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, Changbin Du, Yang Jihong, linux-kernel

On Fri, Jan 26, 2024 at 8:25 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Wed, Jan 24, 2024 at 09:03:57AM +0000, James Clark escreveu:
> > On 24/01/2024 00:46, Namhyung Kim wrote:
> > > On Tue, Jan 23, 2024 at 2:39 AM James Clark <james.clark@arm.com> wrote:
> > >> +++ b/tools/perf/util/evlist.c
> > >> @@ -106,6 +106,13 @@ struct evlist *evlist__new_default(void)
> > >>                 evlist = NULL;
> > >>         }
>
> > >> +       if (evlist->core.nr_entries > 1) {
>
> > > I think you need a NULL check for evlist here.
>
> > Oops yes. Or just return on the error above.
>
> Was there a v4?

https://lore.kernel.org/linux-perf-users/20240124094358.489372-1-james.clark@arm.com/

> I'm assuming this is for perf-tools, i.e. for v6.8-rc, right?

It fixes 251aa040244a which is added to v6.5.  So I applied it
to perf-tools-next, do you want to take it to perf-tools?

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-01-26 20:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-22 15:54 [PATCH] perf test: Fix session topology test on heterogeneous systems James Clark
2024-01-22 15:58 ` James Clark
2024-01-22 16:41 ` Liang, Kan
2024-01-22 17:09 ` Ian Rogers
2024-01-23  0:09   ` Ian Rogers
2024-01-23 10:27 ` [PATCH v2] perf evlist: Fix evlist__new_default() for > 1 core PMU James Clark
2024-01-23 10:39   ` [PATCH v3] " James Clark
2024-01-24  0:46     ` Namhyung Kim
2024-01-24  9:03       ` James Clark
2024-01-26 16:25         ` Arnaldo Carvalho de Melo
2024-01-26 20:49           ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).