From: Yonghong Song <yonghong.song@linux.dev>
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,
venkat88@linux.ibm.com, andrii@kernel.org, eddyz87@gmail.com,
ast@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
song@kernel.org, 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 15:52:01 -0800 [thread overview]
Message-ID: <a3dfdbc2-bd72-412d-83b4-f17d68949c6b@linux.dev> (raw)
In-Reply-To: <20260212092558.370623-1-skb99@linux.ibm.com>
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)
> {
next prev parent reply other threads:[~2026-02-12 23:52 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
2026-02-12 23:52 ` Yonghong Song [this message]
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=a3dfdbc2-bd72-412d-83b4-f17d68949c6b@linux.dev \
--to=yonghong.song@linux.dev \
--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=venkat88@linux.ibm.com \
/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