Skip to content

bpf: Add kfuncs and selftests for detecting execution context and selftests

Jiayuan Chen bpf linux-kselftest lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Add kfuncs for detecting execution contextkernel/bpf/helpers.c+45 -01 reply
2/2selftests/bpf: Add selftests for context detection kfuncstools/testing/selftests/bpf/prog_tests/context.c tools/testing/selftests/bpf/progs/context_prog.c+65 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next v1 0/2] bpf: Add kfuncs and selftests for detecting execution context and selftests

This path introduces several kfuncs to help BPF programs determine their current execution context. When hooking functions for statistics, we often need to use current->comm to get the process name.

However, these hooked functions can be called from either process context or interrupt context. When called from interrupt context, the current we obtain may refer to the process that was interrupted, which may not be what we need.

These new kfuncs expose APIs that allow users to determine the actual execution context.

Jiayuan Chen (2):
bpf: Add kfuncs for detecting execution context selftests/bpf: Add selftests for context detection kfuncs

 kernel/bpf/helpers.c                          | 45 +++++++++++++++++++
 .../selftests/bpf/prog_tests/context.c        | 32 +++++++++++++
 .../selftests/bpf/progs/context_prog.c        | 33 ++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/context.c
 create mode 100644 tools/testing/selftests/bpf/progs/context_prog.c
Signature · 1 line
2.43.0