bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/2] bpf: Introduce bpf_in_interrupt kfunc
@ 2025-08-25 13:14 Leon Hwang
  2025-08-25 13:15 ` [PATCH bpf-next v2 1/2] " Leon Hwang
  2025-08-25 13:15 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add case to test " Leon Hwang
  0 siblings, 2 replies; 12+ messages in thread
From: Leon Hwang @ 2025-08-25 13:14 UTC (permalink / raw)
  To: bpf
  Cc: ast, andrii, daniel, martin.lau, eddyz87, song, yonghong.song,
	leon.hwang, kernel-patches-bot

Filtering pid_tgid is meaningless when the current task is preempted by
an interrupt.

To address this, introduce the bpf_in_interrupt kfunc, which allows BPF
programs to determine whether they are executing in interrupt context.

Internally, bpf_in_interrupt() is a thin wrapper around in_interrupt().
It is marked as fastcall function.

On x86_64, it is inlined for efficiency.

Changes:
v1 -> v2:
* Fix a build error reported by test bot.

Leon Hwang (2):
  bpf: Introduce bpf_in_interrupt kfunc
  selftests/bpf: Add case to test bpf_in_interrupt kfunc

 kernel/bpf/helpers.c                    |  9 +++++++++
 kernel/bpf/verifier.c                   | 11 +++++++++++
 tools/testing/selftests/bpf/progs/irq.c |  7 +++++++
 3 files changed, 27 insertions(+)

--
2.50.1


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

end of thread, other threads:[~2025-09-03  5:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 13:14 [PATCH bpf-next v2 0/2] bpf: Introduce bpf_in_interrupt kfunc Leon Hwang
2025-08-25 13:15 ` [PATCH bpf-next v2 1/2] " Leon Hwang
2025-08-25 15:17   ` Alexei Starovoitov
2025-08-26  3:00     ` Leon Hwang
2025-08-26 22:18       ` Alexei Starovoitov
2025-09-01 15:12         ` Leon Hwang
2025-09-02  2:29           ` Alexei Starovoitov
2025-09-03  5:22             ` Leon Hwang
2025-08-25 13:15 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add case to test " Leon Hwang
2025-08-25 17:26   ` Eduard Zingerman
2025-08-26  3:05     ` Leon Hwang
2025-08-26 22:31       ` Eduard Zingerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).