* [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC
@ 2025-03-11 15:42 Kumar Kartikeya Dwivedi
2025-03-11 15:43 ` Kumar Kartikeya Dwivedi
2025-03-12 23:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2025-03-11 15:42 UTC (permalink / raw)
To: bpf
Cc: Venkat Rao Bagalkote, Alexei Starovoitov, Andrii Nakryiko,
Daniel Borkmann, Martin KaFai Lau, Eduard Zingerman, kkd,
kernel-team
Venkat reported a compilation error for BPF selftests on PowerPC [0].
The crux of the error is the following message:
In file included from progs/arena_spin_lock.c:7:
/root/bpf-next/tools/testing/selftests/bpf/bpf_arena_spin_lock.h:122:8:
error: member reference base type '__attribute__((address_space(1)))
u32' (aka '__attribute__((address_space(1))) unsigned int') is not a
structure or union
122 | old = atomic_read(&lock->val);
This is because PowerPC overrides the qspinlock type changing the
lock->val member's type from atomic_t to u32.
To remedy this, import the asm-generic version in the arena spin lock
header, name it __qspinlock (since it's aliased to arena_spinlock_t, the
actual name hardly matters), and adjust the selftest to not depend on
the type in vmlinux.h.
[0]: https://lore.kernel.org/bpf/7bc80a3b-d708-4735-aa3b-6a8c21720f9d@linux.ibm.com
Fixes: 0201027a026c ("selftests/bpf: Introduce arena spin lock")
Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
.../selftests/bpf/bpf_arena_spin_lock.h | 23 ++++++++++++++++++-
.../bpf/prog_tests/arena_spin_lock.c | 4 ++--
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h
index 3aca389ce424..fb8dc0768999 100644
--- a/tools/testing/selftests/bpf/bpf_arena_spin_lock.h
+++ b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h
@@ -22,7 +22,28 @@
extern unsigned long CONFIG_NR_CPUS __kconfig;
-#define arena_spinlock_t struct qspinlock
+/*
+ * Typically, we'd just rely on the definition in vmlinux.h for qspinlock, but
+ * PowerPC overrides the definition to define lock->val as u32 instead of
+ * atomic_t, leading to compilation errors. Import a local definition below so
+ * that we don't depend on the vmlinux.h version.
+ */
+
+struct __qspinlock {
+ union {
+ atomic_t val;
+ struct {
+ u8 locked;
+ u8 pending;
+ };
+ struct {
+ u16 locked_pending;
+ u16 tail;
+ };
+ };
+};
+
+#define arena_spinlock_t struct __qspinlock
/* FIXME: Using typedef causes CO-RE relocation error */
/* typedef struct qspinlock arena_spinlock_t; */
diff --git a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
index bc3616ba891c..7565fc7690c2 100644
--- a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
+++ b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
@@ -4,8 +4,8 @@
#include <network_helpers.h>
#include <sys/sysinfo.h>
-struct qspinlock { int val; };
-typedef struct qspinlock arena_spinlock_t;
+struct __qspinlock { int val; };
+typedef struct __qspinlock arena_spinlock_t;
struct arena_qnode {
unsigned long next;
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC
2025-03-11 15:42 [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC Kumar Kartikeya Dwivedi
@ 2025-03-11 15:43 ` Kumar Kartikeya Dwivedi
2025-03-11 18:21 ` Venkat Rao Bagalkote
2025-03-12 23:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2025-03-11 15:43 UTC (permalink / raw)
To: Venkat Rao Bagalkote
Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
Martin KaFai Lau, Eduard Zingerman, kkd, kernel-team
On Tue, 11 Mar 2025 at 16:42, Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
>
> Venkat reported a compilation error for BPF selftests on PowerPC [0].
> The crux of the error is the following message:
> In file included from progs/arena_spin_lock.c:7:
> /root/bpf-next/tools/testing/selftests/bpf/bpf_arena_spin_lock.h:122:8:
> error: member reference base type '__attribute__((address_space(1)))
> u32' (aka '__attribute__((address_space(1))) unsigned int') is not a
> structure or union
> 122 | old = atomic_read(&lock->val);
>
> This is because PowerPC overrides the qspinlock type changing the
> lock->val member's type from atomic_t to u32.
>
> To remedy this, import the asm-generic version in the arena spin lock
> header, name it __qspinlock (since it's aliased to arena_spinlock_t, the
> actual name hardly matters), and adjust the selftest to not depend on
> the type in vmlinux.h.
>
> [0]: https://lore.kernel.org/bpf/7bc80a3b-d708-4735-aa3b-6a8c21720f9d@linux.ibm.com
>
> Fixes: 0201027a026c ("selftests/bpf: Introduce arena spin lock")
> Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
Venkat, please help test, as CI and I don't have access to a PowerPC machine.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC
2025-03-11 15:43 ` Kumar Kartikeya Dwivedi
@ 2025-03-11 18:21 ` Venkat Rao Bagalkote
0 siblings, 0 replies; 4+ messages in thread
From: Venkat Rao Bagalkote @ 2025-03-11 18:21 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi
Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
Martin KaFai Lau, Eduard Zingerman, kkd, kernel-team
On 11/03/25 9:13 pm, Kumar Kartikeya Dwivedi wrote:
> On Tue, 11 Mar 2025 at 16:42, Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
>> Venkat reported a compilation error for BPF selftests on PowerPC [0].
>> The crux of the error is the following message:
>> In file included from progs/arena_spin_lock.c:7:
>> /root/bpf-next/tools/testing/selftests/bpf/bpf_arena_spin_lock.h:122:8:
>> error: member reference base type '__attribute__((address_space(1)))
>> u32' (aka '__attribute__((address_space(1))) unsigned int') is not a
>> structure or union
>> 122 | old = atomic_read(&lock->val);
>>
>> This is because PowerPC overrides the qspinlock type changing the
>> lock->val member's type from atomic_t to u32.
>>
>> To remedy this, import the asm-generic version in the arena spin lock
>> header, name it __qspinlock (since it's aliased to arena_spinlock_t, the
>> actual name hardly matters), and adjust the selftest to not depend on
>> the type in vmlinux.h.
>>
>> [0]: https://lore.kernel.org/bpf/7bc80a3b-d708-4735-aa3b-6a8c21720f9d@linux.ibm.com
>>
>> Fixes: 0201027a026c ("selftests/bpf: Introduce arena spin lock")
>> Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
>> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> ---
Built the kernel by applying this patch on bpf-next. And selftests/bpf
compiles successfully.
Please add below tag.
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Venkat, please help test, as CI and I don't have access to a PowerPC machine.
>
> Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC
2025-03-11 15:42 [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC Kumar Kartikeya Dwivedi
2025-03-11 15:43 ` Kumar Kartikeya Dwivedi
@ 2025-03-12 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-12 23:30 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi
Cc: bpf, venkat88, ast, andrii, daniel, martin.lau, eddyz87, kkd,
kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 11 Mar 2025 08:42:44 -0700 you wrote:
> Venkat reported a compilation error for BPF selftests on PowerPC [0].
> The crux of the error is the following message:
> In file included from progs/arena_spin_lock.c:7:
> /root/bpf-next/tools/testing/selftests/bpf/bpf_arena_spin_lock.h:122:8:
> error: member reference base type '__attribute__((address_space(1)))
> u32' (aka '__attribute__((address_space(1))) unsigned int') is not a
> structure or union
> 122 | old = atomic_read(&lock->val);
>
> [...]
Here is the summary with links:
- [bpf-next,v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC
https://git.kernel.org/bpf/bpf-next/c/46d38f489ef0
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] 4+ messages in thread
end of thread, other threads:[~2025-03-12 23:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 15:42 [PATCH bpf-next v1] selftests/bpf: Fix arena_spin_lock compilation on PowerPC Kumar Kartikeya Dwivedi
2025-03-11 15:43 ` Kumar Kartikeya Dwivedi
2025-03-11 18:21 ` Venkat Rao Bagalkote
2025-03-12 23:30 ` 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