Skip to content

Commit efe7c5f

Browse files
kkdwivediKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
selftests/bpf: Fix arena_spin_lock compilation on PowerPC
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/[email protected] Fixes: 0201027 ("selftests/bpf: Introduce arena spin lock") Reported-by: Venkat Rao Bagalkote <[email protected]> Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>
1 parent 474f6ed commit efe7c5f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

tools/testing/selftests/bpf/bpf_arena_spin_lock.h

+22-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,28 @@
2222

2323
extern unsigned long CONFIG_NR_CPUS __kconfig;
2424

25-
#define arena_spinlock_t struct qspinlock
25+
/*
26+
* Typically, we'd just rely on the definition in vmlinux.h for qspinlock, but
27+
* PowerPC overrides the definition to define lock->val as u32 instead of
28+
* atomic_t, leading to compilation errors. Import a local definition below so
29+
* that we don't depend on the vmlinux.h version.
30+
*/
31+
32+
struct __qspinlock {
33+
union {
34+
atomic_t val;
35+
struct {
36+
u8 locked;
37+
u8 pending;
38+
};
39+
struct {
40+
u16 locked_pending;
41+
u16 tail;
42+
};
43+
};
44+
};
45+
46+
#define arena_spinlock_t struct __qspinlock
2647
/* FIXME: Using typedef causes CO-RE relocation error */
2748
/* typedef struct qspinlock arena_spinlock_t; */
2849

tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <network_helpers.h>
55
#include <sys/sysinfo.h>
66

7-
struct qspinlock { int val; };
8-
typedef struct qspinlock arena_spinlock_t;
7+
struct __qspinlock { int val; };
8+
typedef struct __qspinlock arena_spinlock_t;
99

1010
struct arena_qnode {
1111
unsigned long next;

0 commit comments

Comments
 (0)