]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Add powerpc support for get_preempt_count() in selftest
authorSaket Kumar Bhaskar <skb99@linux.ibm.com>
Thu, 12 Feb 2026 09:25:58 +0000 (14:55 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Feb 2026 22:42:38 +0000 (14:42 -0800)
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 <skb99@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Link: https://lore.kernel.org/r/20260212092558.370623-1-skb99@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/bpf_experimental.h

index 4b7210c318ddd18ab67ccb18c528852809f96ecf..9df77e59d4f5d3b65c85347e177017de1b97c92b 100644 (file)
@@ -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)
 {