[PATCH RFC bpf-next 2/2] selftests/bpf: Add LoongArch support for get_preempt_count()
Tiezhu Yang
yangtiezhu at loongson.cn
Mon Apr 20 04:15:16 PDT 2026
There is no LoongArch support for get_preempt_count() currently and its
fallback path always returns 0, just add it so that bpf_in_interrupt(),
bpf_in_nmi(), bpf_in_hardirq(), bpf_in_serving_softirq(), bpf_in_task()
works for LoongArch as well. With this patch, "./test_progs -t exe_ctx"
should pass on LoongArch.
Signed-off-by: Tiezhu Yang <yangtiezhu at loongson.cn>
---
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 e5c039bc44cb..5847bbf12d24 100644
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -507,6 +507,8 @@ static inline int get_preempt_count(void)
return bpf_get_lowcore()->preempt_count;
#elif defined(bpf_target_riscv)
return bpf_get_current_task_btf()->thread_info.preempt_count;
+#elif defined(bpf_target_loongarch)
+ return bpf_get_current_task_btf()->thread_info.preempt_count;
#endif
return 0;
}
@@ -518,6 +520,7 @@ static inline int get_preempt_count(void)
* * powerpc64
* * s390x
* * riscv
+ * * loongarch
*/
static inline int bpf_in_interrupt(void)
{
@@ -540,6 +543,7 @@ static inline int bpf_in_interrupt(void)
* * powerpc64
* * s390x
* * riscv
+ * * loongarch
*/
static inline int bpf_in_nmi(void)
{
@@ -553,6 +557,7 @@ static inline int bpf_in_nmi(void)
* * powerpc64
* * s390x
* * riscv
+ * * loongarch
*/
static inline int bpf_in_hardirq(void)
{
@@ -566,6 +571,7 @@ static inline int bpf_in_hardirq(void)
* * powerpc64
* * s390x
* * riscv
+ * * loongarch
*/
static inline int bpf_in_serving_softirq(void)
{
@@ -587,6 +593,7 @@ static inline int bpf_in_serving_softirq(void)
* * powerpc64
* * s390x
* * riscv
+ * * loongarch
*/
static inline int bpf_in_task(void)
{
--
2.42.0
More information about the linux-riscv
mailing list