public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Howard Chu <howardchu95@gmail.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-perf-users@vger.kernel.org, acme@kernel.org,
	namhyung@kernel.org, irogers@google.com, james.clark@linaro.org,
	agordeev@linux.ibm.com, gor@linux.ibm.com,
	sumanthk@linux.ibm.com, hca@linux.ibm.com
Subject: Re: [PATCH] perf trace: Fix wrong size to bpf_map__update_elem call
Date: Mon, 24 Mar 2025 13:32:09 -0700	[thread overview]
Message-ID: <Z-HBSReviPphH2LJ@gmail.com> (raw)
In-Reply-To: <20250324152756.3879571-1-tmricht@linux.ibm.com>

On Mon, Mar 24, 2025 at 04:27:56PM +0100, Thomas Richter wrote:
> In linux-next
> commit c760174401f6 ("perf cpumap: Reduce cpu size from int to int16_t")
> causes the perf tests 100 126 to fail on s390:
>
> Output before:
>  # ./perf test 100
>  100: perf trace BTF general tests         : FAILED!

Arnaldo encountered similar failure, but I couldn't reproduce it, so the
fix was stalled.

>  #
>
> The root cause is the change from int to int16_t for the
> cpu maps. The size of the CPU key value pair changes from
> four bytes to two bytes. However a two byte key size is
> not supported for bpf_map__update_elem().
> Note: validate_map_op() in libbpf.c emits warning
>  libbpf: map '__augmented_syscalls__': \
>        unexpected key size 2 provided, expected 4
> when key size is set to int16_t.
>
> Therefore change to variable size back to 4 bytes for
> invocation of bpf_map__update_elem().

Makes sense, thank you so much for digging into this and fixing it.

>
> Output after:
>  # ./perf test 100
>  100: perf trace BTF general tests         : Ok
>  #
>
> Fixes: c760174401f6 ("perf cpumap: Reduce cpu size from int to int16_t")
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: James Clark <james.clark@linaro.org>
> ---
>  tools/perf/builtin-trace.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 092c5f6404ba..464c97a11852 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -4375,10 +4375,12 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>                * CPU the bpf-output event's file descriptor.
>                */
>               perf_cpu_map__for_each_cpu(cpu, i, trace->syscalls.events.bpf_output->core.cpus) {
> +                     int mycpu = cpu.cpu;
> +
>                       bpf_map__update_elem(trace->skel->maps.__augmented_syscalls__,
> -                                     &cpu.cpu, sizeof(int),
> +                                     &mycpu, sizeof(int),
>                                       xyarray__entry(trace->syscalls.events.bpf_output->core.fd,
> -                                                    cpu.cpu, 0),
> +                                                    mycpu, 0),
>                                       sizeof(__u32), BPF_ANY);
>               }
>       }
> --
> 2.48.1
>
>

Acked-by: Howard Chu <howardchu95@gmail.com>

Thanks,
Howard

  parent reply	other threads:[~2025-03-24 20:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 15:27 [PATCH] perf trace: Fix wrong size to bpf_map__update_elem call Thomas Richter
2025-03-24 15:38 ` Ian Rogers
2025-03-24 15:50   ` Ian Rogers
2025-03-24 16:58     ` Namhyung Kim
2025-03-24 20:59     ` Howard Chu
2025-03-24 20:32 ` Howard Chu [this message]
2025-03-25 19:49 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z-HBSReviPphH2LJ@gmail.com \
    --to=howardchu95@gmail.com \
    --cc=acme@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sumanthk@linux.ibm.com \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox