From: Saket Kumar Bhaskar Date: Thu, 12 Feb 2026 09:25:58 +0000 (+0530) Subject: selftests/bpf: Add powerpc support for get_preempt_count() in selftest X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c51f90d45dca71e7974ed5a7c40b9c04a6c6762;p=thirdparty%2Flinux.git selftests/bpf: Add powerpc support for get_preempt_count() in selftest get_preempt_count() is enabled to return preempt_count for powerpc, so that bpf_in_interrupt()/bpf_in_nmi()/bpf_in_serving_softirq()/ bpf_in_task()/bpf_in_hardirq()/get_preempt_count() works for powerpc as well. Signed-off-by: Saket Kumar Bhaskar Tested-by: Venkat Rao Bagalkote Link: https://lore.kernel.org/r/20260212092558.370623-1-skb99@linux.ibm.com Signed-off-by: Alexei Starovoitov --- diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h index 4b7210c318ddd..9df77e59d4f5d 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -645,6 +645,8 @@ static inline int get_preempt_count(void) bpf_this_cpu_ptr(&pcpu_hot))->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; } @@ -653,6 +655,7 @@ static inline int get_preempt_count(void) * Report whether it is in interrupt context. Only works on the following archs: * * x86 * * arm64 + * * powerpc64 */ static inline int bpf_in_interrupt(void) { @@ -672,6 +675,7 @@ static inline int bpf_in_interrupt(void) * Report whether it is in NMI context. Only works on the following archs: * * x86 * * arm64 + * * powerpc64 */ static inline int bpf_in_nmi(void) { @@ -682,6 +686,7 @@ static inline int bpf_in_nmi(void) * Report whether it is in hard IRQ context. Only works on the following archs: * * x86 * * arm64 + * * powerpc64 */ static inline int bpf_in_hardirq(void) { @@ -692,6 +697,7 @@ static inline int bpf_in_hardirq(void) * Report whether it is in softirq context. Only works on the following archs: * * x86 * * arm64 + * * powerpc64 */ static inline int bpf_in_serving_softirq(void) { @@ -710,6 +716,7 @@ static inline int bpf_in_serving_softirq(void) * Report whether it is in task context. Only works on the following archs: * * x86 * * arm64 + * * powerpc64 */ static inline int bpf_in_task(void) {