public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] Add kfunc for doing pid -> task lookup
@ 2022-11-22 14:52 David Vernet
  2022-11-22 14:52 ` [PATCH bpf-next 1/2] bpf: Add bpf_task_from_pid() kfunc David Vernet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Vernet @ 2022-11-22 14:52 UTC (permalink / raw)
  To: bpf
  Cc: ast, andrii, daniel, martin.lau, yhs, song, sdf, john.fastabend,
	kpsingh, jolsa, haoluo, tj, kernel-team, linux-kernel

A series of prior patches added support for storing struct task_struct *
objects as kptrs. This patch set proposes extending this with another
kfunc called bpf_task_from_pid() which performs a lookup of a task from
its pid, from the root pid namespace idr.

This allows BPF programs that don't have a kptr to a task, to instead
perform a lookup by pid. This will be useful for programs that are
tracking pids and want, e.g., to do a lookup to find task->comm.

David Vernet (2):
  bpf: Add bpf_task_from_pid() kfunc
  selftests/bpf: Add selftests for bpf_task_from_pid()

 kernel/bpf/helpers.c                          | 20 +++++
 .../selftests/bpf/prog_tests/task_kfunc.c     |  3 +
 .../selftests/bpf/progs/task_kfunc_common.h   |  1 +
 .../selftests/bpf/progs/task_kfunc_success.c  | 73 +++++++++++++++++++
 4 files changed, 97 insertions(+)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-24  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 14:52 [PATCH bpf-next 0/2] Add kfunc for doing pid -> task lookup David Vernet
2022-11-22 14:52 ` [PATCH bpf-next 1/2] bpf: Add bpf_task_from_pid() kfunc David Vernet
2022-11-22 14:53 ` [PATCH bpf-next 2/2] selftests/bpf: Add selftests for bpf_task_from_pid() David Vernet
2022-11-24  2:10 ` [PATCH bpf-next 0/2] Add kfunc for doing pid -> task lookup patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox