Re: [PATCH v4 2/3] Now that BPF supports adding new kernel functions with kfuncs, and storing kernel objects in maps with kptrs, we can add a set of kfuncs which allow struct task_struct objects to be stored in maps as referenced kptrs. The possible use cases for doing this are plentiful. During tracing, for example, it would be useful to be able to collect some tasks that performed a certain operation, and then periodically summarize who they are, which cgroup they're in, how much CPU time they've utilized, etc.

From: David Vernet
Date: Fri Oct 14 2022 - 17:13:13 EST


On Fri, Oct 14, 2022 at 03:28:51PM -0500, David Vernet wrote:
> In order to enable this, this patch adds three new kfuncs:
>
> struct task_struct *bpf_task_acquire(struct task_struct *p);
> struct task_struct *bpf_task_kptr_get(struct task_struct **pp);
> void bpf_task_release(struct task_struct *p);
>
> A follow-on patch will add selftests validating these kfuncs.
>
> Signed-off-by: David Vernet <void@xxxxxxxxxxxxx>

And somehow I managed to remove the commit title for this one. Sincere
apologies for the noise everyone. Hopefully I'll stop going off the
rails in v5.