Skip to contentSkip to conversation

perf tools: Build failure in v6.16-rc1

BUG Namhyung Kim 3 participants 8 messages Jun 10, 2025 – Jun 12, 2025

Subsystems (2)
lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

Hello,

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'

     88 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
  In file included from bench/futex.c:5:
  /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
    134 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~

make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

commit 60035a3981a7f9d965df81a48a07b94e52ccd54f

Author: Sebastian Andrzej Siewior <[email protected]>
Date:   Wed Apr 16 18:29:19 2025 +0200

tools/perf: Allow to select the number of hash buckets

Add the -b/ --buckets argument to specify the number of hash buckets for the private futex hash. This is directly passed to
prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, buckets, immutable)

and must return without an error if specified. The `immutable' is 0 by default and can be set to 1 via the -I/ --immutable argument. The size of the private hash is verified with PR_FUTEX_HASH_GET_SLOTS. If PR_FUTEX_HASH_GET_SLOTS failed then it is assumed that an older kernel was used without the support and that the global hash is used.

Thanks,
Namhyung

#1 lore raw
Quoted 1 line · Namhyung Kim

Hello,

Hi,

Quoted 11 lines

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'

     88 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
  In file included from bench/futex.c:5:
  /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
    134 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
Quoted 3 lines

make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

Hmm. So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

|       #include <linux/prctl.h>  /* Definition of PR_* constants */
|       #include <sys/prctl.h>

so musl doesn't follow this.

To align with the other builds, I guess the following help:

tools/perf/bench/futex.c +0 -1
index 26382e4d8d4ce..540261f299b1d 100644
@@ -2,7 +2,6 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 
 #include "futex.h"

Sebastian

#2 lore raw
Quoted 33 lines · Sebastian Andrzej Siewior
Quoted 1 line · Namhyung Kim

Hello,

Hi,

Quoted 11 lines

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'

     88 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
  In file included from bench/futex.c:5:
  /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
    134 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
Quoted 3 lines

make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

Hmm. So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

Quoted 7 lines

The man page for prctl(2) says:

|       #include <linux/prctl.h>  /* Definition of PR_* constants */
|       #include <sys/prctl.h>

so musl doesn't follow this.

To align with the other builds, I guess the following help:

So I noticed this as well in perf-tools/perf-tools, I'm trying with your patch applied, lets see...

- Arnaldo

Quoted 14 lines
tools/perf/bench/futex.c +0 -1
index 26382e4d8d4ce..540261f299b1d 100644
@@ -2,7 +2,6 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 
 #include "futex.h"

Sebastian

#3 lore raw
Quoted 38 lines · Arnaldo Carvalho de Melo
Quoted 37 lines · Sebastian Andrzej Siewior
Quoted 1 line · Namhyung Kim

Hello,

Hi,

Quoted 11 lines

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'

     88 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
  In file included from bench/futex.c:5:
  /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
    134 | struct prctl_mm_map {
        |        ^~~~~~~~~~~~
Quoted 3 lines

make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

Hmm. So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

|       #include <linux/prctl.h>  /* Definition of PR_* constants */
|       #include <sys/prctl.h>
Quoted 6 lines
Quoted 3 lines

so musl doesn't follow this.

To align with the other builds, I guess the following help:

So I noticed this as well in perf-tools/perf-tools, I'm trying with your patch applied, lets see...

Can I keep this as below?

With it:

toolsbuilder@five:~$ time dm from alpine:3.16
   5   130.36 alpine:3.16                   : Ok   gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
   6   100.65 alpine:3.17                   : Ok   gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
   7    90.44 alpine:3.18                   : Ok   gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924 , Alpine clang version 16.0.6 flex 2.6.4
   8   106.18 alpine:3.19                   : Ok   gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014 , Alpine clang version 17.0.5 flex 2.6.4
   9   108.16 alpine:3.20                   : Ok   gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309 , Alpine clang version 17.0.6 flex 2.6.4
  10   111.19 alpine:3.22                   : Ok   gcc (Alpine 14.2.0) 14.2.0 , Alpine clang version 20.1.6 flex 2.6.4
  11   109.28 alpine:edge                   : Ok   gcc (Alpine 14.2.0) 14.2.0 , Alpine clang version 19.1.4 flex 2.6.4
  12    92.62 amazonlinux:2023              : Ok   gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5) , clang version 15.0.7 (AWS 15.0.7-3.amzn2023.0.4) flex 2.6.4
  13    98.43 amazonlinux:devel             : Ok   gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4) , clang version 15.0.6 (Amazon Linux 15.0.6-3.amzn2023.0.2) flex 2.6.4
  14    17.24 archlinux:base                : FAIL gcc version 14.2.1 20240805 (GCC) 
    <command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
    <command-line>: note: this is the location of the previous definition
    cc1: all warnings being treated as errors
    error: command '/usr/sbin/gcc' failed with exit code 1
  15    97.65 centos:stream                 : Ok   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-21) , clang version 17.0.6 (Red Hat 17.0.6-1.module_el8+767+9fa966b8) flex 2.6.1

The archlinux one is unrelated. More are building now.

- Arnaldo

commit 8386dc356158fc50c55831c96b1248e01d112ebc

Author: Sebastian Andrzej Siewior <[email protected]>
Date:   Wed Jun 11 11:25:42 2025 +0200

perf bench futex: Fix prctl include in musl libc

Namhyung Kim reported:

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
88 | struct prctl_mm_map {
| ^~~~~~~~~~~~
In file included from bench/futex.c:5:
/linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
134 | struct prctl_mm_map {
| ^~~~~~~~~~~~
make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

| #include <linux/prctl.h> /* Definition of PR_* constants */
| #include <sys/prctl.h>

so musl doesn't follow this.

So align with the other builds.

[ Remove one more in tools/perf/bench/futex-hash.c and conditionally define PR_FUTEX_HASH and friends ]
tools/perf/bench/futex-hash.c +0 -1
index fdf133c9520f73a4..d2d6d7f3ea331c84 100644
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
-#include <linux/prctl.h>
 #include <linux/zalloc.h>
 #include <sys/time.h>
 #include <sys/mman.h>
tools/perf/bench/futex.c +8 -1
index 26382e4d8d4ce2ff..4c4fee107e5912d5 100644
@@ -2,11 +2,18 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 
 #include "futex.h"
 
+#ifndef PR_FUTEX_HASH
+#define PR_FUTEX_HASH                   78
+# define PR_FUTEX_HASH_SET_SLOTS        1
+# define FH_FLAG_IMMUTABLE              (1ULL << 0)
+# define PR_FUTEX_HASH_GET_SLOTS        2
+# define PR_FUTEX_HASH_GET_IMMUTABLE    3
+#endif // PR_FUTEX_HASH
+
 void futex_set_nbuckets_param(struct bench_futex_parameters *params)
 {
 	unsigned long flags;
#4 lore raw
Quoted 42 lines · Arnaldo Carvalho de Melo

commit 8386dc356158fc50c55831c96b1248e01d112ebc

Author: Sebastian Andrzej Siewior <[email protected]>
Date:   Wed Jun 11 11:25:42 2025 +0200

perf bench futex: Fix prctl include in musl libc

Namhyung Kim reported:

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
88 | struct prctl_mm_map {
| ^~~~~~~~~~~~
In file included from bench/futex.c:5:
/linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
134 | struct prctl_mm_map {
| ^~~~~~~~~~~~
make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

| #include <linux/prctl.h> /* Definition of PR_* constants */
| #include <sys/prctl.h>

Quoted 7 lines

so musl doesn't follow this.

So align with the other builds.

s/Link/Closes/

Quoted 20 lines
[ Remove one more in tools/perf/bench/futex-hash.c and conditionally define PR_FUTEX_HASH and friends ]
tools/perf/bench/futex-hash.c +0 -1
index fdf133c9520f73a4..d2d6d7f3ea331c84 100644
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
-#include <linux/prctl.h>
 #include <linux/zalloc.h>
 #include <sys/time.h>
 #include <sys/mman.h>
tools/perf/bench/futex.c +0 -0
index 26382e4d8d4ce2ff..4c4fee107e5912d5 100644

tools/perf/bench/futex.c line 6

Quoted 6 lines
tools/perf/bench/futex.c +0 -1
@@ -2,11 +2,18 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 

This is what I had locally and was waiting for confirmation.

tools/perf/bench/futex.c line 15

Quoted 9 lines
tools/perf/bench/futex.c +7 -0
 #include "futex.h"
 
+#ifndef PR_FUTEX_HASH
+#define PR_FUTEX_HASH                   78
+# define PR_FUTEX_HASH_SET_SLOTS        1
+# define FH_FLAG_IMMUTABLE              (1ULL << 0)
+# define PR_FUTEX_HASH_GET_SLOTS        2
+# define PR_FUTEX_HASH_GET_IMMUTABLE    3
+#endif // PR_FUTEX_HASH

Is this needed? Aren't these defines coming from that local copy?

tools/perf/bench/futex.c line 19

Quoted 3 lines
tools/perf/bench/futex.c +0 -0
 void futex_set_nbuckets_param(struct bench_futex_parameters *params)
 {
 	unsigned long flags;

Sebastian

#5 lore raw
Quoted 45 lines · Sebastian Andrzej Siewior
Quoted 44 lines · Arnaldo Carvalho de Melo

commit 8386dc356158fc50c55831c96b1248e01d112ebc

Author: Sebastian Andrzej Siewior <[email protected]>
Date:   Wed Jun 11 11:25:42 2025 +0200

perf bench futex: Fix prctl include in musl libc

Namhyung Kim reported:

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
88 | struct prctl_mm_map {
| ^~~~~~~~~~~~
In file included from bench/futex.c:5:
/linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
134 | struct prctl_mm_map {
| ^~~~~~~~~~~~
make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

| #include <linux/prctl.h> /* Definition of PR_* constants */
| #include <sys/prctl.h>

so musl doesn't follow this.

Quoted 7 lines
Quoted 5 lines

So align with the other builds.

s/Link/Closes/

ok

Quoted 30 lines
Quoted 20 lines
[ Remove one more in tools/perf/bench/futex-hash.c and conditionally define PR_FUTEX_HASH and friends ]
tools/perf/bench/futex-hash.c +0 -1
index fdf133c9520f73a4..d2d6d7f3ea331c84 100644
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
-#include <linux/prctl.h>
 #include <linux/zalloc.h>
 #include <sys/time.h>
 #include <sys/mman.h>
tools/perf/bench/futex.c +0 -0
index 26382e4d8d4ce2ff..4c4fee107e5912d5 100644

tools/perf/bench/futex.c line 6

Quoted 6 lines
tools/perf/bench/futex.c +0 -1
@@ -2,11 +2,18 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 

This is what I had locally and was waiting for confirmation.

Quoted 2 lines
tools/perf/bench/futex.c +0 -0
 #include "futex.h"
 
Quoted 9 lines

tools/perf/bench/futex.c line 15

Quoted 7 lines
tools/perf/bench/futex.c +7 -0
+#ifndef PR_FUTEX_HASH
+#define PR_FUTEX_HASH                   78
+# define PR_FUTEX_HASH_SET_SLOTS        1
+# define FH_FLAG_IMMUTABLE              (1ULL << 0)
+# define PR_FUTEX_HASH_GET_SLOTS        2
+# define PR_FUTEX_HASH_GET_IMMUTABLE    3
+#endif // PR_FUTEX_HASH

Is this needed? Aren't these defines coming from that local copy?

So, these are, as you say, in the copied linux/prctl.h, but in musl libc we have:

/tmp/perf-6.16.0-rc1 $ grep 'struct prctl_mm_map {' /usr/include/linux/prctl.h struct prctl_mm_map {
/tmp/perf-6.16.0-rc1 $ grep 'struct prctl_mm_map {' /usr/include/sys/prctl.h struct prctl_mm_map {
/tmp/perf-6.16.0-rc1 $

And sys/prctl.h doesn't include linux/prctl.h, if we do it, we get multiple definitions for 'struct prctl_mm_map'.

While in fedora (probably in all the others, haven't checked, but no failure on them from my last container set build tests):

⬢ [acme@toolbx perf-tools]$ grep 'struct prctl_mm_map {' /usr/include/linux/prctl.h struct prctl_mm_map {
⬢ [acme@toolbx perf-tools]$ grep 'struct prctl_mm_map {' /usr/include/sys/prctl.h ⬢ [acme@toolbx perf-tools]$

furthermore fedora's sys/prctl.h includes linux/prctl.h, while musl libc doesn't.

I thought this would be something fixed in newer alpine versions, but no:

toolsbuilder@five:~$ grep FAIL dm.log.old/summary 
   5    19.53 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219) 
   6    20.83 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) 
   7    13.94 alpine:3.18                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10) 
   8    16.60 alpine:3.19                   : FAIL gcc version 13.2.1 20231014 (Alpine 13.2.1_git20231014) 
   9    15.72 alpine:3.20                   : FAIL gcc version 13.2.1 20240309 (Alpine 13.2.1_git20240309) 
  10    16.38 alpine:3.22                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
  11    15.09 alpine:edge                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
toolsbuilder@five:~$

So the easiest way out of this seems to be not to explicitely include linux/prctl.h and define the new stuff conditionally, as I did, right?

- Arnaldo

Quoted 5 lines

tools/perf/bench/futex.c line 19

Quoted 3 lines
tools/perf/bench/futex.c +0 -0
 void futex_set_nbuckets_param(struct bench_futex_parameters *params)
 {
 	unsigned long flags;

Sebastian

author maintainer Tested-by
#6 lore raw
Quoted 132 lines · Arnaldo Carvalho de Melo
Quoted 45 lines · Sebastian Andrzej Siewior
Quoted 44 lines · Arnaldo Carvalho de Melo

commit 8386dc356158fc50c55831c96b1248e01d112ebc

Author: Sebastian Andrzej Siewior <[email protected]>
Date:   Wed Jun 11 11:25:42 2025 +0200

perf bench futex: Fix prctl include in musl libc

Namhyung Kim reported:

I've updated the perf-tools-next to v6.16-rc1 and found a build error like below on alpine linux 3.18.

In file included from bench/futex.c:6:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
88 | struct prctl_mm_map {
| ^~~~~~~~~~~~
In file included from bench/futex.c:5:
/linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
134 | struct prctl_mm_map {
| ^~~~~~~~~~~~
make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

git bisect says it's the first commit introduced the failure.

So your /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h both provide struct prctl_mm_map but their include guard must be different.

My /usr/include/sys/prctl.h is provided by glibc and contains the prctl() declaration. It includes also linux/prctl.h. The tools/include/uapi/linux/prctl.h is the same as /usr/include/linux/prctl.h.

The /usr/include/sys/prctl.h on alpine linux is different. This is probably coming from musl. It contains the PR_* definition and the prctl() declaration. So it clashes here because now the one struct is available twice.

The man page for prctl(2) says:

| #include <linux/prctl.h> /* Definition of PR_* constants */
| #include <sys/prctl.h>

so musl doesn't follow this.

Quoted 7 lines
Quoted 5 lines

So align with the other builds.

s/Link/Closes/

ok

Quoted 30 lines
Quoted 20 lines
[ Remove one more in tools/perf/bench/futex-hash.c and conditionally define PR_FUTEX_HASH and friends ]
tools/perf/bench/futex-hash.c +0 -1
index fdf133c9520f73a4..d2d6d7f3ea331c84 100644
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
-#include <linux/prctl.h>
 #include <linux/zalloc.h>
 #include <sys/time.h>
 #include <sys/mman.h>
tools/perf/bench/futex.c +0 -0
index 26382e4d8d4ce2ff..4c4fee107e5912d5 100644

tools/perf/bench/futex.c line 6

Quoted 6 lines
tools/perf/bench/futex.c +0 -1
@@ -2,11 +2,18 @@
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <linux/prctl.h>
 #include <sys/prctl.h>
 

This is what I had locally and was waiting for confirmation.

Quoted 2 lines
tools/perf/bench/futex.c +0 -0
 #include "futex.h"
 
Quoted 9 lines

tools/perf/bench/futex.c line 15

Quoted 7 lines
tools/perf/bench/futex.c +7 -0
+#ifndef PR_FUTEX_HASH
+#define PR_FUTEX_HASH                   78
+# define PR_FUTEX_HASH_SET_SLOTS        1
+# define FH_FLAG_IMMUTABLE              (1ULL << 0)
+# define PR_FUTEX_HASH_GET_SLOTS        2
+# define PR_FUTEX_HASH_GET_IMMUTABLE    3
+#endif // PR_FUTEX_HASH

Is this needed? Aren't these defines coming from that local copy?

So, these are, as you say, in the copied linux/prctl.h, but in musl libc we have:

/tmp/perf-6.16.0-rc1 $ grep 'struct prctl_mm_map {' /usr/include/linux/prctl.h struct prctl_mm_map {
/tmp/perf-6.16.0-rc1 $ grep 'struct prctl_mm_map {' /usr/include/sys/prctl.h struct prctl_mm_map {
/tmp/perf-6.16.0-rc1 $

And sys/prctl.h doesn't include linux/prctl.h, if we do it, we get multiple definitions for 'struct prctl_mm_map'.

While in fedora (probably in all the others, haven't checked, but no failure on them from my last container set build tests):

⬢ [acme@toolbx perf-tools]$ grep 'struct prctl_mm_map {' /usr/include/linux/prctl.h struct prctl_mm_map {
⬢ [acme@toolbx perf-tools]$ grep 'struct prctl_mm_map {' /usr/include/sys/prctl.h ⬢ [acme@toolbx perf-tools]$

furthermore fedora's sys/prctl.h includes linux/prctl.h, while musl libc doesn't.

I thought this would be something fixed in newer alpine versions, but no:

toolsbuilder@five:~$ grep FAIL dm.log.old/summary 
   5    19.53 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219) 
   6    20.83 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) 
   7    13.94 alpine:3.18                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10) 
   8    16.60 alpine:3.19                   : FAIL gcc version 13.2.1 20231014 (Alpine 13.2.1_git20231014) 
   9    15.72 alpine:3.20                   : FAIL gcc version 13.2.1 20240309 (Alpine 13.2.1_git20240309) 
  10    16.38 alpine:3.22                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
  11    15.09 alpine:edge                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
toolsbuilder@five:~$
Quoted 2 lines

So the easiest way out of this seems to be not to explicitely include linux/prctl.h and define the new stuff conditionally, as I did, right?

Yep, it fixes my build too. Without the defines, I see

bench/futex.c: In function 'futex_set_nbuckets_param':
bench/futex.c:25:45: error: 'FH_FLAG_IMMUTABLE' undeclared (first use in this function)

     25 |         flags = params->buckets_immutable ? FH_FLAG_IMMUTABLE : 0;
        |                                             ^~~~~~~~~~~~~~~~~
  bench/futex.c:25:45: note: each undeclared identifier is reported only once for each function it appears in
  bench/futex.c:26:21: error: 'PR_FUTEX_HASH' undeclared (first use in this function)
     26 |         ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, flags);
        |                     ^~~~~~~~~~~~~
    CC      /build/ui/browsers/annotate-data.o
  bench/futex.c:26:36: error: 'PR_FUTEX_HASH_SET_SLOTS' undeclared (first use in this function)
     26 |         ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, flags);
        |                                    ^~~~~~~~~~~~~~~~~~~~~~~
  bench/futex.c: In function 'futex_print_nbuckets':
  bench/futex.c:39:21: error: 'PR_FUTEX_HASH' undeclared (first use in this function)
     39 |         ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS);
        |                     ^~~~~~~~~~~~~
  bench/futex.c:39:36: error: 'PR_FUTEX_HASH_GET_SLOTS' undeclared (first use in this function)
     39 |         ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS);
        |                                    ^~~~~~~~~~~~~~~~~~~~~~~
  bench/futex.c:53:52: error: 'PR_FUTEX_HASH_GET_IMMUTABLE' undeclared (first use in this function)
     53 |                         ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_IMMUTABLE);
        |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~

make[4]: *** [/linux/tools/build/Makefile.build:86: /build/bench/futex.o] Error 1

Thanks,
Namhyung

Quoted 8 lines

- Arnaldo

Quoted 5 lines

tools/perf/bench/futex.c line 19

Quoted 3 lines
tools/perf/bench/futex.c +0 -0
 void futex_set_nbuckets_param(struct bench_futex_parameters *params)
 {
 	unsigned long flags;

Sebastian

#7 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 4 lines · Arnaldo Carvalho de Melo
Quoted 1 line

Is this needed? Aren't these defines coming from that local copy?

So, these are, as you say, in the copied linux/prctl.h, but in musl libc we have:

right, I briefly forgot about musl.
All good.
…

Quoted 13 lines

I thought this would be something fixed in newer alpine versions, but no:

toolsbuilder@five:~$ grep FAIL dm.log.old/summary 
   5    19.53 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219) 
   6    20.83 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) 
   7    13.94 alpine:3.18                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10) 
   8    16.60 alpine:3.19                   : FAIL gcc version 13.2.1 20231014 (Alpine 13.2.1_git20231014) 
   9    15.72 alpine:3.20                   : FAIL gcc version 13.2.1 20240309 (Alpine 13.2.1_git20240309) 
  10    16.38 alpine:3.22                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
  11    15.09 alpine:edge                   : FAIL gcc version 14.2.0 (Alpine 14.2.0) 
toolsbuilder@five:~$
Quoted 2 lines

So the easiest way out of this seems to be not to explicitely include linux/prctl.h and define the new stuff conditionally, as I did, right?

Let me drop an email to alpine and check with them.

Quoted 1 line

- Arnaldo

Sebastian