[PATCH] selftests/bpf: Add powerpc support for get_preempt_count() in selftest

Saket Kumar Bhaskar
2026-01-29T05:41:34Z

get_preempt_count() is enabled to return preempt_count for powerpc,
so that bpf_in_interrupt()/get_preempt_count() works for powerpc as
well.

Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
---
tools/testing/selftests/bpf/bpf_experimental.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index 2cd9165c7348..c3f039a878f3 100644
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -630,6 +630,8 @@ static inline int get_preempt_count(void)
return *(int *) bpf_this_cpu_ptr(&__preempt_count);
#elif defined(bpf_target_arm64)
return bpf_get_current_task_btf()->thread_info.preempt.count;
+#elif defined(bpf_target_powerpc)
+ return bpf_get_current_task_btf()->thread_info.preempt_count;
#endif
return 0;
}
--
2.52.0