* Re: [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
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-13 23:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Venkat Rao Bagalkote @ 2026-02-12 10:54 UTC (permalink / raw)
To: Saket Kumar Bhaskar, linux-kernel, linux-kselftest, bpf,
linuxppc-dev
Cc: hbathini, sachinpb, andrii, eddyz87, ast, daniel, martin.lau,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
christophe.leroy, maddy, mpe
On 12/02/26 2:55 pm, Saket Kumar Bhaskar wrote:
> 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 this patch by applying on mainline kernel, and below selftests
passes.
Please add below tag.
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
./test_progs -t exe_ctx
[ 610.897388] bpf_testmod: loading out-of-tree module taints kernel.
[ 610.907373] audit: type=1334 audit(1771408772.036:229): prog-id=72
op=LOAD
[ 610.907385] audit: type=1334 audit(1771408772.036:230): prog-id=72
op=UNLOAD
[ 610.907461] audit: type=1334 audit(1771408772.036:231): prog-id=73
op=LOAD
[ 610.907467] audit: type=1334 audit(1771408772.036:232): prog-id=73
op=UNLOAD
[ 610.941282] audit: type=1334 audit(1771408772.076:233): prog-id=74
op=LOAD
[ 610.941290] audit: type=1334 audit(1771408772.076:234): prog-id=74
op=UNLOAD
[ 610.956474] audit: type=1334 audit(1771408772.086:235): prog-id=75
op=LOAD
[ 610.956481] audit: type=1334 audit(1771408772.086:236): prog-id=75
op=UNLOAD
[ 610.956964] audit: type=1334 audit(1771408772.086:237): prog-id=76
op=LOAD
[ 610.956970] audit: type=1334 audit(1771408772.086:238): prog-id=76
op=UNLOAD
#109 exe_ctx:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
./test_progs -t timer_interrupt
[ 730.106678] kauditd_printk_skb: 6 callbacks suppressed
[ 730.106685] audit: type=1334 audit(1771408891.236:245): prog-id=80
op=LOAD
[ 730.106700] audit: type=1334 audit(1771408891.236:246): prog-id=80
op=UNLOAD
[ 730.106787] audit: type=1334 audit(1771408891.236:247): prog-id=81
op=LOAD
[ 730.106794] audit: type=1334 audit(1771408891.236:248): prog-id=81
op=UNLOAD
[ 730.136150] audit: type=1334 audit(1771408891.266:249): prog-id=82
op=LOAD
[ 730.136158] audit: type=1334 audit(1771408891.266:250): prog-id=82
op=UNLOAD
[ 730.151245] audit: type=1334 audit(1771408891.286:251): prog-id=83
op=LOAD
[ 730.151252] audit: type=1334 audit(1771408891.286:252): prog-id=83
op=UNLOAD
[ 730.151572] audit: type=1334 audit(1771408891.286:253): prog-id=84
op=LOAD
[ 730.151578] audit: type=1334 audit(1771408891.286:254): prog-id=84
op=UNLOAD
#490 timer_interrupt:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
Regards,
Venkat.
> ---
> 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)
> {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
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
2 siblings, 1 reply; 5+ messages in thread
From: Yonghong Song @ 2026-02-12 23:52 UTC (permalink / raw)
To: Saket Kumar Bhaskar, linux-kernel, linux-kselftest, bpf,
linuxppc-dev
Cc: hbathini, sachinpb, venkat88, andrii, eddyz87, ast, daniel,
martin.lau, song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
christophe.leroy, maddy, mpe
On 2/12/26 1:25 AM, Saket Kumar Bhaskar wrote:
> 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
Maybe do
#elif defined(bpf_target_arm64) || defined(bpf_target_powerpc)
?
> 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)
> {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
2026-02-12 23:52 ` Yonghong Song
@ 2026-02-12 23:53 ` Yonghong Song
0 siblings, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2026-02-12 23:53 UTC (permalink / raw)
To: Saket Kumar Bhaskar, linux-kernel, linux-kselftest, bpf,
linuxppc-dev
Cc: hbathini, sachinpb, venkat88, andrii, eddyz87, ast, daniel,
martin.lau, song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
christophe.leroy, maddy, mpe
On 2/12/26 3:52 PM, Yonghong Song wrote:
>
>
> On 2/12/26 1:25 AM, Saket Kumar Bhaskar wrote:
>> 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
>
> Maybe do
> #elif defined(bpf_target_arm64) || defined(bpf_target_powerpc)
> ?
Sorry, my bad. Please ignore as missing preempt.count vs. preempt_count.
>
>> 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)
>> {
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
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-13 23:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-13 23:50 UTC (permalink / raw)
To: Saket Kumar Bhaskar
Cc: linux-kernel, linux-kselftest, bpf, linuxppc-dev, hbathini,
sachinpb, venkat88, andrii, eddyz87, ast, daniel, martin.lau,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
christophe.leroy, maddy, mpe
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 12 Feb 2026 14:55:58 +0530 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
https://git.kernel.org/bpf/bpf-next/c/4c51f90d45dc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread