Re: [PATCH v6 15/26] perf trace: Filter the target's tasks in BPF
From: Arnaldo Carvalho de Melo
Date: Thu Oct 01 2026 - 12:17:01 EST
On Mon, Sep 28, 2026 at 11:25:54AM -0700, Ian Rogers wrote:
> +static bool task_traced(void)
> +{
> + u64 pid_tgid = bpf_get_current_pid_tgid();
> + pid_t pid = uses_tgid ? pid_tgid >> 32 : (pid_t)pid_tgid;
> + bool *traced;
> +
> + if (!has_pids_to_trace)
> + return true;
> +
I didn't look at the generated code, some optimization may well make the
bpf_get_current_pif_tgid() to be executed only if has_pids_to_trace is
!NULL, otherwise it would be better to move that to after the test.
I'm applying it anyway, just caught my attention while applying.
- Arnaldo
> + traced = bpf_map_lookup_elem(&pids_to_trace, &pid);
> + return traced && *traced;
> +}