tools/bpf: fix perf build error with uClibc (seen on ARC)
Subsystems (5)
PATCH 1/1 tools/bpf: fix perf build error with uClibc (seen on ARC)
When build perf for ARC recently, there was a build failure due to lack of __NR_bpf.
| Auto-detecting system features:
|
| ... get_cpuid: [ OFF ]
| ... bpf: [ on ]
|
| # error __NR_bpf not defined. libbpf does not support your arch.
^~~~~
| bpf.c: In function 'sys_bpf':
| bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
| return syscall(__NR_bpf, cmd, attr, size);
| ^~~~~~~~
| sys_bpfThe fix is to define a fallbak __NR_bpf.
The obvious fix with be __arc__ specific value, but i think a better fix is to use the asm-generic uapi value applicable to ARC as well as any new arch (hopefully we don't add an old existing arch here). Otherwise I can just add __arc__
--- tools/lib/bpf/bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/lib/bpf/bpf.c +4 -1
@@ -47,7 +47,10 @@# elif defined(__s390__)# define __NR_bpf 351# else -# error __NR_bpf not defined. libbpf does not support your arch. +/* +* Any non listed arch (new) will have to asm-generic uapi complient +*/ +# define __NR_bpf 280# endif #endif
Signature · 1 line
2.7.4
Quoted 17 lines · Vineet Gupta
When build perf for ARC recently, there was a build failure due to lack of
__NR_bpf.| Auto-detecting system features: | | ... get_cpuid: [ OFF ] | ... bpf: [ on ] | | # error __NR_bpf not defined. libbpf does not support your arch. ^~~~~ | bpf.c: In function 'sys_bpf': | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function) | return syscall(__NR_bpf, cmd, attr, size); | ^~~~~~~~ | sys_bpf
Quoted 6 lines
The fix is to define a fallbak
__NR_bpf.The obvious fix with be
__arc__specific value, but i think a better fix is to use the asm-generic uapi value applicable to ARC as well as any new arch (hopefully we don't add an old existing arch here). Otherwise I can just add__arc__
I prefer explicitly guard with __arc__. We still have arm/sh with different __NR_bpf values. This patch will give wrong bpf syscall values for these two architectures.
Alternatively, you could add support for arm/sh together with your current patch. Hopefully I did not miss other architectures.
Quoted 25 lines
Signed-off-by Vineet Gupta <[email protected]>--- tools/lib/bpf/bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/lib/bpf/bpf.c +4
-2@@ -47,7 +47,10 @@# elif defined(__s390__)# define __NR_bpf 351# else -# error __NR_bpf not defined. libbpf does not support your arch. +/* +* Any non listed arch (new) will have to asm-generic uapi complient +*/ +# define __NR_bpf 280# endif #endif --2.7.4
PATCH v2 1/1 tools/bpf: fix perf build error with uClibc (seen on ARC)
When build perf for ARC recently, there was a build failure due to lack of __NR_bpf.
| Auto-detecting system features:
|
| ... get_cpuid: [ OFF ]
| ... bpf: [ on ]
|
| # error __NR_bpf not defined. libbpf does not support your arch.
^~~~~
| bpf.c: In function 'sys_bpf':
| bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
| return syscall(__NR_bpf, cmd, attr, size);
| ^~~~~~~~
| sys_bpf---
v1 -> v2
- Only add syscall nr for ARC, as asm-generic won't work with arm/sh [Y Song]
--- tools/lib/bpf/bpf.c | 2 ++ 1 file changed, 2 insertions(+)
tools/lib/bpf/bpf.c +2 -0
@@ -46,6 +46,8 @@# define __NR_bpf 349# elif defined(__s390__)# define __NR_bpf 351 +# elif defined(__arc__) +# define __NR_bpf 280# else # error __NR_bpf not defined. libbpf does not support your arch.# endif
Signature · 1 line
2.7.4
Quoted 17 lines · Vineet Gupta
When build perf for ARC recently, there was a build failure due to lack of
__NR_bpf.| Auto-detecting system features: | | ... get_cpuid: [ OFF ] | ... bpf: [ on ] | | # error __NR_bpf not defined. libbpf does not support your arch. ^~~~~ | bpf.c: In function 'sys_bpf': | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function) | return syscall(__NR_bpf, cmd, attr, size); | ^~~~~~~~ | sys_bpf
Quoted 1 line
Signed-off-by Vineet Gupta <[email protected]>
Quoted 23 lines
---
v1 -> v2
- Only add syscall nr for ARC, as asm-generic won't work with arm/sh [Y Song]--- tools/lib/bpf/bpf.c | 2 ++ 1 file changed, 2 insertions(+)tools/lib/bpf/bpf.c +2
-1@@ -46,6 +46,8 @@# define __NR_bpf 349# elif defined(__s390__)# define __NR_bpf 351 +# elif defined(__arc__) +# define __NR_bpf 280# else # error __NR_bpf not defined. libbpf does not support your arch.# endif --2.7.4
Alexei Starovoitov
AppliedQuoted 19 lines · Y Song
Quoted 17 lines · Vineet Gupta
When build perf for ARC recently, there was a build failure due to lack of
__NR_bpf.| Auto-detecting system features: | | ... get_cpuid: [ OFF ] | ... bpf: [ on ] | | # error __NR_bpf not defined. libbpf does not support your arch. ^~~~~ | bpf.c: In function 'sys_bpf': | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function) | return syscall(__NR_bpf, cmd, attr, size); | ^~~~~~~~ | sys_bpf
Quoted 3 lines
Quoted 1 line
Signed-off-by Vineet Gupta <[email protected]>Acked-by Yonghong Song <[email protected]>
Applied. Thanks