From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: Saket Kumar Bhaskar <skb99@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: hbathini@linux.ibm.com, sachinpb@linux.ibm.com,
andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, christophe.leroy@csgroup.eu,
maddy@linux.ibm.com, mpe@ellerman.id.au
Subject: Re: [PATCH v2] selftests/bpf: Add powerpc support for get_preempt_count() in selftest
Date: Thu, 12 Feb 2026 16:24:32 +0530 [thread overview]
Message-ID: <ab6ee329-ca59-4765-b309-22e64dfca861@linux.ibm.com> (raw)
In-Reply-To: <20260212092558.370623-1-skb99@linux.ibm.com>
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)
> {
next prev parent reply other threads:[~2026-02-12 11:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-02-12 23:52 ` Yonghong Song
2026-02-12 23:53 ` Yonghong Song
2026-02-13 23:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab6ee329-ca59-4765-b309-22e64dfca861@linux.ibm.com \
--to=venkat88@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hbathini@linux.ibm.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=martin.lau@linux.dev \
--cc=mpe@ellerman.id.au \
--cc=sachinpb@linux.ibm.com \
--cc=sdf@fomichev.me \
--cc=skb99@linux.ibm.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox