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

-- 
2.43.0


Reply via email to