linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf header: exempt x86_64 from core id test
@ 2025-06-17 15:08 Anubhav Shelat
  2025-06-17 16:46 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Anubhav Shelat @ 2025-06-17 15:08 UTC (permalink / raw)
  To: mpetlan, acme, namhyung, irogers, linux-perf-users
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa,
	adrian.hunter, kan.liang, dapeng1.mi, james.clark, Anubhav Shelat

On a VM running on an x86_64 architecture, it is possible for the socket
id to be greater than the processor number. So exclude x86_64 arch from
the core id test.

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
---
 tools/perf/util/header.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e3cdc3b7b4ab..c1b4651d0c6a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2618,9 +2618,12 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
 	 * The socket_id number might be higher than the numbers of cpus.
 	 * This depends on the configuration.
 	 * AArch64 is the same.
+	 * It is also possible for a VM running x86_64 to have a larger
+	 * socket_id number than the number of cpus.
 	 */
 	if (ph->env.arch && (!strncmp(ph->env.arch, "s390", 4)
-			  || !strncmp(ph->env.arch, "aarch64", 7)))
+			  || !strncmp(ph->env.arch, "aarch64", 7)
+			  || !strncmp(ph->env.arch, "x86_64", 6)))
 		do_core_id_test = false;
 
 	for (i = 0; i < (u32)cpu_nr; i++) {
-- 
2.49.0


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

* Re: [PATCH] perf header: exempt x86_64 from core id test
  2025-06-17 15:08 [PATCH] perf header: exempt x86_64 from core id test Anubhav Shelat
@ 2025-06-17 16:46 ` Ian Rogers
  2025-06-18 13:55   ` Anubhav Shelat
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2025-06-17 16:46 UTC (permalink / raw)
  To: Anubhav Shelat
  Cc: mpetlan, acme, namhyung, linux-perf-users, peterz, mingo,
	mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
	dapeng1.mi, james.clark

On Tue, Jun 17, 2025 at 8:11 AM Anubhav Shelat <ashelat@redhat.com> wrote:
>
> On a VM running on an x86_64 architecture, it is possible for the socket
> id to be greater than the processor number. So exclude x86_64 arch from
> the core id test.
>
> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
> ---
>  tools/perf/util/header.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index e3cdc3b7b4ab..c1b4651d0c6a 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -2618,9 +2618,12 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
>          * The socket_id number might be higher than the numbers of cpus.
>          * This depends on the configuration.
>          * AArch64 is the same.
> +        * It is also possible for a VM running x86_64 to have a larger
> +        * socket_id number than the number of cpus.
>          */
>         if (ph->env.arch && (!strncmp(ph->env.arch, "s390", 4)
> -                         || !strncmp(ph->env.arch, "aarch64", 7)))
> +                         || !strncmp(ph->env.arch, "aarch64", 7)
> +                         || !strncmp(ph->env.arch, "x86_64", 6)))
>                 do_core_id_test = false;

Why do we have a boolean called do_core_id_test that is checking a
value assigned to the socket_id? :-)
I think at this point the test:
```
                if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
                       pr_debug("socket_id number is too big."
                                "You may need to upgrade the perf tool.\n");
                       goto free_cpu;
               }
```
has no purpose and we can just delete it.

Thanks,
Ian

>
>         for (i = 0; i < (u32)cpu_nr; i++) {
> --
> 2.49.0
>

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

* Re: [PATCH] perf header: exempt x86_64 from core id test
  2025-06-17 16:46 ` Ian Rogers
@ 2025-06-18 13:55   ` Anubhav Shelat
  0 siblings, 0 replies; 3+ messages in thread
From: Anubhav Shelat @ 2025-06-18 13:55 UTC (permalink / raw)
  To: Ian Rogers
  Cc: mpetlan, acme, namhyung, linux-perf-users, peterz, mingo,
	mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
	dapeng1.mi, james.clark

Yeah that makes more sense. I can send a patch to delete the test.

Anubhav

On Tue, Jun 17, 2025 at 12:46 PM Ian Rogers <irogers@google.com> wrote:
>
> On Tue, Jun 17, 2025 at 8:11 AM Anubhav Shelat <ashelat@redhat.com> wrote:
> >
> > On a VM running on an x86_64 architecture, it is possible for the socket
> > id to be greater than the processor number. So exclude x86_64 arch from
> > the core id test.
> >
> > Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
> > ---
> >  tools/perf/util/header.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index e3cdc3b7b4ab..c1b4651d0c6a 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -2618,9 +2618,12 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
> >          * The socket_id number might be higher than the numbers of cpus.
> >          * This depends on the configuration.
> >          * AArch64 is the same.
> > +        * It is also possible for a VM running x86_64 to have a larger
> > +        * socket_id number than the number of cpus.
> >          */
> >         if (ph->env.arch && (!strncmp(ph->env.arch, "s390", 4)
> > -                         || !strncmp(ph->env.arch, "aarch64", 7)))
> > +                         || !strncmp(ph->env.arch, "aarch64", 7)
> > +                         || !strncmp(ph->env.arch, "x86_64", 6)))
> >                 do_core_id_test = false;
>
> Why do we have a boolean called do_core_id_test that is checking a
> value assigned to the socket_id? :-)
> I think at this point the test:
> ```
>                 if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
>                        pr_debug("socket_id number is too big."
>                                 "You may need to upgrade the perf tool.\n");
>                        goto free_cpu;
>                }
> ```
> has no purpose and we can just delete it.
>
> Thanks,
> Ian
>
> >
> >         for (i = 0; i < (u32)cpu_nr; i++) {
> > --
> > 2.49.0
> >
>


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

end of thread, other threads:[~2025-06-18 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 15:08 [PATCH] perf header: exempt x86_64 from core id test Anubhav Shelat
2025-06-17 16:46 ` Ian Rogers
2025-06-18 13:55   ` Anubhav Shelat

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).