Skip to contentSkip to conversation

libbpf: fix missing __WORDSIZE definition

PATCH In review Andrii Nakryiko 4 participants 6 messages Jul 18, 2019 – Jul 29, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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.

Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")
---
 tools/lib/bpf/hashmap.h | 5 +++++
 1 file changed, 5 insertions(+)
tools/lib/bpf/hashmap.h +5 -0
index 03748a742146..bae8879cdf58 100644
@@ -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
#1 lore raw
Quoted 8 lines · Andrii Nakryiko

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.

Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")

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
---
 tools/lib/bpf/hashmap.h | 5 +++++
 1 file changed, 5 insertions(+)
tools/lib/bpf/hashmap.h +5 -1
index 03748a742146..bae8879cdf58 100644
@@ -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

Tested-by on v2 1/1
#2 lore raw
In reply to Andrii Nakryiko

Em Thu, Jul 18, 2019 at 10:30:21AM -0700, Andrii Nakryiko escreveu:

Quoted 8 lines

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.

Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")

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
index 03748a742146..bae8879cdf58 100644
@@ -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
#3 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Thu, Jul 18, 2019 at 10:30:21AM -0700, Andrii Nakryiko escreveu:

Quoted 5 lines

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.

Quoted 7 lines
Quoted 3 lines
Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")

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
index 03748a742146..bae8879cdf58 100644
@@ -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

#4 lore raw
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.h depends on __WORDSIZE being defined. It is defined by glibc/musl in different headers. It's an explicit goal for musl to

be

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 safe

internal hashmap")

Quoted 3 lines
Quoted 2 lines
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
index 03748a742146..bae8879cdf58 100644
@@ -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

#5 lore raw
In reply to Andrii Nakryiko
libbpf: 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.

Cc Alexei Starovoitov <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Daniel Borkmann <[email protected]>
Fixes e3b924224028 ("libbpf: add resizable non-thread safe internal hashmap")
---
 tools/lib/bpf/hashmap.h | 5 +++++
 1 file changed, 5 insertions(+)
tools/lib/bpf/hashmap.h +5 -0
index 03748a742146..bae8879cdf58 100644
@@ -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)