libbpf: fix missing __WORDSIZE definition
Subsystems (4)
PATCH v2 1/1 libbpf: fix missing __WORDSIZE definition
hashmap.h depends on __WORDSIZE being defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to be "non-detectable" at compilation time, so instead include glibc header if glibc is explicitly detected and fall back to musl header otherwise.
--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)
tools/lib/bpf/hashmap.h +5 -0
@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits)
Signature · 1 line
2.17.1
Quoted 8 lines · Andrii Nakryiko
hashmap.hdepends on__WORDSIZEbeing defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to be "non-detectable" at compilation time, so instead include glibc header if glibc is explicitly detected and fall back to musl header otherwise.Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")Reported-by Arnaldo Carvalho de Melo <[email protected]>
Arnaldo,
As it compiled fine for me even before and I don't have a musl set up, could you please verify this fixes the issue for perf for all your test environments?
Thanks!
Quoted 24 lines
Signed-off-by Andrii Nakryiko <[email protected]>--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)tools/lib/bpf/hashmap.h +5
-1@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits) --2.17.1
Em Thu, Jul 18, 2019 at 10:30:21AM -0700, Andrii Nakryiko escreveu:
Quoted 8 lines
hashmap.hdepends on__WORDSIZEbeing defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to be "non-detectable" at compilation time, so instead include glibc header if glibc is explicitly detected and fall back to musl header otherwise.Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")Reported-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Couldn't find ths in the bpf tree, please consider applying it:
- Arnaldo
Quoted 22 lines
--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)tools/lib/bpf/hashmap.h +5
-0@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits)Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
Quoted 7 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 18, 2019 at 10:30:21AM -0700, Andrii Nakryiko escreveu:
Quoted 5 lines
hashmap.hdepends on__WORDSIZEbeing defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to be "non-detectable" at compilation time, so instead include glibc header if glibc is explicitly detected and fall back to musl header otherwise.
Quoted 7 lines
Quoted 3 lines
Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")Reported-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Couldn't find ths in the bpf tree, please consider applying it:
Arnaldo, I somehow got impression that you were going to pull this into your perf tree. Can you please confirm that it wasn't pulled into your tree, so that Alexei can apply it to bpf tree? Thanks!
Quoted 30 lines
- Arnaldo
Quoted 21 lines
--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)tools/lib/bpf/hashmap.h +5
-1@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits) --Quoted 1 line
2.17.1
--
- Arnaldo
Quoted 17 lines · Andrii Nakryiko
Quoted 4 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 18, 2019 at 10:30:21AM -0700, Andrii Nakryiko escreveu:
Quoted 2 lines
hashmap.hdepends on__WORDSIZEbeing defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl tobe
Quoted 1 line
Quoted 1 line
"non-detectable" at compilation time, so instead include glibc
header if
Quoted 1 line
Quoted 1 line
glibc is explicitly detected and fall back to musl header
otherwise.
Quoted 2 lines
Quoted 2 lines
Fixes e3b924224028 ("libbpf: add resizable non-thread safeinternal hashmap")
Quoted 3 lines
Quoted 2 lines
Reported-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Quoted 8 lines
Quoted 3 lines
Couldn't find ths in the bpf tree, please consider applying it:
Arnaldo, I somehow got impression that you were going to pull this into your perf tree. Can you please confirm that it wasn't pulled into your tree, so that Alexei can apply it to bpf tree? Thanks!
I can process it, just was unsure about where it should go by,
I'll have it in my next perf/urgent pull req,
Thanks,
- Arnaldo
Quoted 31 lines
Quoted 31 lines
- Arnaldo
Quoted 21 lines
--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)tools/lib/bpf/hashmap.h +5
-1@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits) --Quoted 1 line
2.17.1
--
- Arnaldo
tip-bot for Andrii Nakryiko
merge botlibbpf: fix missing __WORDSIZE definition
Commit-ID: 8aa259b10a6a759c50137bbbf225df0c17ca5d27 Gitweb: https://git.kernel.org/tip/8aa259b10a6a759c50137bbbf225df0c17ca5d27 Author: Andrii Nakryiko <[email protected]> AuthorDate: Thu, 18 Jul 2019 10:30:21 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 10:18:08 -0300
libbpf: fix missing __WORDSIZE definition
hashmap.h depends on __WORDSIZE being defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to be "non-detectable" at compilation time, so instead include glibc header if glibc is explicitly detected and fall back to musl header otherwise.
--- tools/lib/bpf/hashmap.h | 5 +++++ 1 file changed, 5 insertions(+)
tools/lib/bpf/hashmap.h +5 -0
@@ -10,6 +10,11 @@#include <stdbool.h> #include <stddef.h> +#ifdef __GLIBC__ +#include <bits/wordsize.h> +#else +#include <bits/reg.h> +#endif #include "libbpf_internal.h" static inline size_t hash_bits (size_t h,int bits)