Re: [PATCH v3 4/8] perf trace: Pretty print struct data

Arnaldo Carvalho de Melo
2024-09-09T14:46:47Z

On Mon, Sep 09, 2024 at 11:40:14AM -0300, Arnaldo Carvalho de Melo wrote:
> On Fri, Aug 30, 2024 at 08:16:38AM +0800, Howard Chu wrote:
> > On Thu, Aug 29, 2024 at 5:05 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > > I.e. isn't this a change in the protocol of the BPF colector with the
> > > userpace augmented snprintf routines?

> > > If I remember we discussed that first you make this change in the
> > > protocol, test it with the pre-existing BPF collector, it works. Ok, now
> > > we have a new protocol and we then use it in the generic BTF-based BPF
> > > collector. This way that option of using the BTF-based collector or the
> > > preexisting BPF collector works.

> > > I'll try to do this.

> > Thank you so much.

> Now that I have:

> 6b22c2b502a1c21b (x1/perf-tools-next, perf-tools-next/tmp.perf-tools-next, acme/tmp.perf-tools-next) perf trace: Use a common encoding for augmented arguments, with size + error + payload
> 5d9cd24924f57066 perf trace augmented_syscalls.bpf: Move the renameat aumenter to renameat2, temporarily

> And also:

> 7bedcbaefdf5d4f7 perf trace: Pass the richer 'struct syscall_arg' pointer to trace__btf_scnprintf()
> 8df1d8c6cbd6825b perf trace: Fix perf trace -p <PID>

> I can move to this patch, but then it doesn't build as it uses things
> that will only be available when we get to adding the new BPF components
> in a later patch:
>
> builtin-trace.c: In function ‘trace__init_syscalls_bpf_prog_array_maps’:
> builtin-trace.c:3725:58: error: ‘struct <anonymous>’ has no member named ‘beauty_map_enter’
> 3725 | int beauty_map_fd = bpf_map__fd(trace->skel->maps.beauty_map_enter);
> | ^
> make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/builtin-trace.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
>
> It will only come when we add:
>
> Subject: [PATCH v3 6/8] perf trace: Collect augmented data using BPF
>
> Where we have:
>
> +struct beauty_map_enter {
> + __uint(type, BPF_MAP_TYPE_HASH);
> + __type(key, int);
> + __type(value, __u32[6]);
> + __uint(max_entries, 512);
> +} beauty_map_enter SEC(".maps");
>
>
> So I'll try to combine the addition of the map with the code that uses
> it in the builtin-trace.c codebase.
>

diff --git a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
index 9c7d2f8552945695..4ebce67637435192 100644
--- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
+++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
@@ -124,6 +124,13 @@ struct augmented_args_tmp {
__uint(max_entries, 1);
} augmented_args_tmp SEC(".maps");

+struct beauty_map_enter {
+ __uint(type, BPF_MAP_TYPE_HASH);
+ __type(key, int);
+ __type(value, __u32[6]);
+ __uint(max_entries, 512);
+} beauty_map_enter SEC(".maps");
+
static inline struct augmented_args_payload *augmented_args_payload(void)
{
int key = 0;