From: Alexei Starovoitov Date: Thu, 4 Sep 2025 16:05:58 +0000 (-0700) Subject: Merge branch 'selftests-bpf-introduce-experimental-bpf_in_interrupt' X-Git-Tag: v6.18-rc1~175^2~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d92ef7da2605fdb01db9b547e99d9ea8790c8eb;p=thirdparty%2Fkernel%2Fstable.git Merge branch 'selftests-bpf-introduce-experimental-bpf_in_interrupt' Leon Hwang says: ==================== selftests/bpf: Introduce experimental bpf_in_interrupt() Filtering pid_tgid is meanlingless when the current task is preempted by an interrupt. To address this, introduce 'bpf_in_interrupt()' helper function, which allows BPF programs to determine whether they are executing in interrupt context. 'get_preempt_count()': * On x86, '*(int *) bpf_this_cpu_ptr(&__preempt_count)'. * On arm64, 'bpf_get_current_task_btf()->thread_info.preempt.count'. Then 'bpf_in_interrupt()' will be: * If !PREEMPT_RT, 'get_preempt_count() & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_MASK)'. * If PREEMPT_RT, '(get_preempt_count() & (NMI_MASK | HARDIRQ_MASK)) | (bpf_get_current_task_btf()->softirq_disable_cnt & SOFTIRQ_MASK)'. 'bpf_in_interrupt()' runs well when PREEMPT_RT is enabled. But it's difficult for me to test it well because I'm not familiar with PREEMPT_RT. Changes: v2 -> v3: * Address comments from Alexei: * Move bpf_in_interrupt() to bpf_experimental.h. * Add support for arm64. v2: https://lore.kernel.org/bpf/20250825131502.54269-1-leon.hwang@linux.dev/ v1 -> v2: * Fix a build error reported by test bot. ==================== Link: https://patch.msgid.link/20250903140438.59517-1-leon.hwang@linux.dev Signed-off-by: Alexei Starovoitov --- 2d92ef7da2605fdb01db9b547e99d9ea8790c8eb