Skip to content

Commit

Permalink
perf trace: Fix wrong size to bpf_map__update_elem call
Browse files Browse the repository at this point in the history
In linux-next
commit c760174 ("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!
 #

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

Output after:
 # ./perf test 100
 100: perf trace BTF general tests         : Ok
 #

Fixes: c760174 ("perf cpumap: Reduce cpu size from int to int16_t")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Acked-by: Howard Chu <howardchu95@gmail.com>
Cc: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250324152756.3879571-1-tmricht@linux.ibm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
  • Loading branch information
Thomas Richter authored and Namhyung Kim committed Mar 24, 2025
1 parent 9a352a9 commit 216d567
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4476,10 +4476,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(mycpu),
xyarray__entry(trace->syscalls.events.bpf_output->core.fd,
cpu.cpu, 0),
mycpu, 0),
sizeof(__u32), BPF_ANY);
}
}
Expand Down

0 comments on commit 216d567

Please sign in to comment.