public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
@ 2026-02-12  9:25 Saket Kumar Bhaskar
  2026-02-12 10:54 ` Venkat Rao Bagalkote
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Saket Kumar Bhaskar @ 2026-02-12  9:25 UTC (permalink / raw)
  To: linux-kernel, linux-kselftest, bpf, linuxppc-dev
  Cc: hbathini, sachinpb, venkat88, andrii, eddyz87, ast, daniel,
	martin.lau, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, christophe.leroy, maddy, mpe

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>
---
Changes since v1:
* Updated the comments to include powerpc for the APIs.

v1: https://lore.kernel.org/bpf/20260129054035.168078-1-skb99@linux.ibm.com/
---
 tools/testing/selftests/bpf/bpf_experimental.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index 4b7210c318dd..9df77e59d4f5 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)
 {
-- 
2.52.0


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

end of thread, other threads:[~2026-02-13 23:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12  9:25 [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest Saket Kumar Bhaskar
2026-02-12 10:54 ` Venkat Rao Bagalkote
2026-02-12 23:52 ` Yonghong Song
2026-02-12 23:53   ` Yonghong Song
2026-02-13 23:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox