From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Howard Chu <howardchu95@gmail.com>
Cc: adrian.hunter@intel.com, irogers@google.com, jolsa@kernel.org,
kan.liang@linux.intel.com, namhyung@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 09/10] perf trace: Collect augmented data using BPF
Date: Fri, 23 Aug 2024 10:42:21 -0300 [thread overview]
Message-ID: <ZsiRvQiaIK4qN9Vs@x1> (raw)
In-Reply-To: <ZsiQyahfNYCAmbZq@x1>
On Fri, Aug 23, 2024 at 10:38:21AM -0300, Arnaldo Carvalho de Melo wrote:
> On Fri, Aug 23, 2024 at 10:24:09AM -0300, Arnaldo Carvalho de Melo wrote:
> > On Thu, Aug 15, 2024 at 09:36:25AM +0800, Howard Chu wrote:
> > > +++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
> > > @@ -427,7 +538,8 @@ int sys_enter(struct syscall_enter_args *args)
> > > * "!raw_syscalls:unaugmented" that will just return 1 to return the
> > > * unaugmented tracepoint payload.
> > > */
> > > - bpf_tail_call(args, &syscalls_sys_enter, augmented_args->args.syscall_nr);
> > > + if (augment_sys_enter(args, &augmented_args->args))
> > > + bpf_tail_call(args, &syscalls_sys_enter, augmented_args->args.syscall_nr);
> >
> > We shouldn't do that, instead we keep doing
> >
> > bpf_tail_call(args, &syscalls_sys_enter, augmented_args->args.syscall_nr);
> >
> > And userspace will setup the syscalls_sys_enter map adding the generic
> > pointer collector (augment_sys_enter) for syscalls that have pointers
> > _and_ are not serviced by a pre-existing, specialized handler, this way
> > we keep the ones we have already and that already take into account
> > pretty printing network addresses based on the network family, knows how
> > to pretty print flags (the perf_event_open, etc).
> >
> > I'll try to do this now.
>
> So, step by step, first this, and then hook it to the syscalls that:
>
> 1) have a pointer to collect and no handler, i.e. as a last step in
> assigning the functions to be tail called from the syscalls BPF map.
>
Sorry, sent the wrong patch, this one is the right one:
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 f29a8dfca044649b..4c8176f9a77ca5bb 100644
--- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
+++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
@@ -398,7 +398,11 @@ static bool pid_filter__has(struct pids_filtered *pids, pid_t pid)
return bpf_map_lookup_elem(pids, &pid) != NULL;
}
-static int augment_sys_enter(void *ctx, struct syscall_enter_args *args)
+// Will be tail called for syscalls with pointers, the setup is done
+// in builtin-trace.c as the fallback for syscalls not handled by specialed code,
+// like the network ones that need to look at one field to then decide how to
+// pretty print a network specific address, etc.
+int sys_enter_augmented(struct syscall_enter_args *args)
{
bool augmented, do_output = false;
int zero = 0, size, aug_size, index, output = 0,
@@ -480,7 +484,7 @@ static int augment_sys_enter(void *ctx, struct syscall_enter_args *args)
if (!do_output)
return 1;
- return augmented__beauty_output(ctx, payload, sizeof(struct syscall_enter_args) + output);
+ return augmented__beauty_output(args, payload, sizeof(struct syscall_enter_args) + output);
}
SEC("tp/raw_syscalls/sys_enter")
@@ -511,8 +515,7 @@ int sys_enter(struct syscall_enter_args *args)
* "!raw_syscalls:unaugmented" that will just return 1 to return the
* unaugmented tracepoint payload.
*/
- if (augment_sys_enter(args, &augmented_args->args))
- bpf_tail_call(args, &syscalls_sys_enter, augmented_args->args.syscall_nr);
+ bpf_tail_call(args, &syscalls_sys_enter, augmented_args->args.syscall_nr);
// If not found on the PROG_ARRAY syscalls map, then we're filtering it:
return 0;
next prev parent reply other threads:[~2024-08-23 13:42 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 1:36 [PATCH v2 00/10] perf trace: Enhanced augmentation for pointer arguments Howard Chu
2024-08-15 1:36 ` [PATCH v2 01/10] perf trace: Fix perf trace -p <PID> Howard Chu
2024-08-15 18:28 ` Ian Rogers
2024-08-16 14:52 ` Arnaldo Carvalho de Melo
2024-08-16 17:25 ` Howard Chu
2024-08-15 1:36 ` [PATCH v2 02/10] perf trace: Change some comments Howard Chu
2024-08-16 14:58 ` Arnaldo Carvalho de Melo
2024-08-15 1:36 ` [PATCH v2 03/10] perf trace: Add trace__bpf_sys_enter_beauty_map() to prepare for fetching data in BPF Howard Chu
2024-08-22 17:49 ` Arnaldo Carvalho de Melo
2024-08-22 17:53 ` Arnaldo Carvalho de Melo
2024-08-22 21:09 ` Arnaldo Carvalho de Melo
2024-08-23 4:09 ` Howard Chu
2024-08-15 1:36 ` [PATCH v2 04/10] perf trace: Add some string arguments' name in syscall_arg_fmt__init_array() Howard Chu
2024-08-22 22:14 ` Arnaldo Carvalho de Melo
2024-08-23 4:37 ` Howard Chu
2024-08-23 13:17 ` Arnaldo Carvalho de Melo
2024-08-15 1:36 ` [PATCH v2 05/10] perf trace: Add a new argument to trace__btf_scnprintf() Howard Chu
2024-08-22 18:00 ` Arnaldo Carvalho de Melo
2024-08-22 18:13 ` Arnaldo Carvalho de Melo
2024-08-23 4:05 ` Howard Chu
2024-08-15 1:36 ` [PATCH v2 06/10] perf trace: Pretty print struct data Howard Chu
2024-08-23 12:41 ` Arnaldo Carvalho de Melo
2024-08-23 13:15 ` Arnaldo Carvalho de Melo
2024-08-15 1:36 ` [PATCH v2 07/10] perf trace: Pretty print buffer data Howard Chu
2024-08-23 14:17 ` Arnaldo Carvalho de Melo
2024-08-15 1:36 ` [PATCH v2 08/10] perf trace: Add pids_allowed and rename pids_filtered Howard Chu
2024-08-15 1:36 ` [PATCH v2 09/10] perf trace: Collect augmented data using BPF Howard Chu
2024-08-23 13:24 ` Arnaldo Carvalho de Melo
2024-08-23 13:38 ` Arnaldo Carvalho de Melo
2024-08-23 13:42 ` Arnaldo Carvalho de Melo [this message]
2024-08-23 14:23 ` Arnaldo Carvalho de Melo
2024-08-15 1:36 ` [PATCH v2 10/10] perf trace: Add general tests for augmented syscalls Howard Chu
2024-08-16 3:15 ` Ian Rogers
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=ZsiRvQiaIK4qN9Vs@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).