Skip to content

Commit 1c85c94

Browse files
committed
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 both /usr/include/sys/prctl.h and /linux/tools/include/uapi/linux/prctl.h provide struct prctl_mm_map but their include guard must be different. /usr/include/sys/prctl.h provided by glibc contains the prctl() declaration. It includes also 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 don't include linux/prctl.h explicitely and add some new defines needed if they aren't available. Acked-by: Sebastian Andrzej Siewior <[email protected]> Reported-by: Namhyung Kim <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Link: https://www.openwall.com/lists/musl/2025/06/12/11 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 19f4422 commit 1c85c94

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tools/perf/bench/futex-hash.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <stdlib.h>
1919
#include <linux/compiler.h>
2020
#include <linux/kernel.h>
21-
#include <linux/prctl.h>
2221
#include <linux/zalloc.h>
2322
#include <sys/time.h>
2423
#include <sys/mman.h>

tools/perf/bench/futex.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
#include <err.h>
33
#include <stdio.h>
44
#include <stdlib.h>
5-
#include <linux/prctl.h>
65
#include <sys/prctl.h>
76

87
#include "futex.h"
98

9+
#ifndef PR_FUTEX_HASH
10+
#define PR_FUTEX_HASH 78
11+
# define PR_FUTEX_HASH_SET_SLOTS 1
12+
# define FH_FLAG_IMMUTABLE (1ULL << 0)
13+
# define PR_FUTEX_HASH_GET_SLOTS 2
14+
# define PR_FUTEX_HASH_GET_IMMUTABLE 3
15+
#endif // PR_FUTEX_HASH
16+
1017
void futex_set_nbuckets_param(struct bench_futex_parameters *params)
1118
{
1219
unsigned long flags;

0 commit comments

Comments
 (0)