Message ID | 20211209235857.423773-1-alistair.francis@opensource.wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v5,1/6] perf bench futex: Add support for 32-bit systems with 64-bit time_t | expand |
Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > From: Alistair Francis <alistair.francis@wdc.com> > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > time_t and as such don't have the SYS_futex syscall. This patch will > allow us to use the SYS_futex_time64 syscall on those platforms. > > This also converts the futex calls to be y2038 safe (when built for a > 5.1+ kernel). > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > The original commit was reverted as including linux/time_types.h would > fail to compile on older kernels. This commit doesn't include > linux/time_types.h to avoid this issue. The reverted commit had: Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Davidlohr Bueso <dbueso@suse.de> Does that stands for this new patch? Thanks, - Arnaldo > Signed-off-by: Alistair Francis <alistair.francis@wdc.com> > Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> > Cc: Alistair Francis <alistair23@gmail.com> > Cc: Atish Patra <atish.patra@wdc.com> > Cc: Darren Hart <dvhart@infradead.org> > Cc: Davidlohr Bueso <dave@stgolabs.net> > Cc: Jiri Olsa <jolsa@redhat.com> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Namhyung Kim <namhyung@kernel.org> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: linux-riscv@lists.infradead.org > Cc: Arnaldo Carvalho de Melo <acme@redhat.com> > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > --- > tools/perf/bench/futex.h | 52 +++++++++++++++++++++++++++++++++++++--- > 1 file changed, 49 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h > index ebdc2b032afc..385d2bdfaa9f 100644 > --- a/tools/perf/bench/futex.h > +++ b/tools/perf/bench/futex.h > @@ -8,6 +8,7 @@ > #ifndef _FUTEX_H > #define _FUTEX_H > > +#include <errno.h> > #include <unistd.h> > #include <sys/syscall.h> > #include <sys/types.h> > @@ -28,7 +29,17 @@ struct bench_futex_parameters { > }; > > /** > - * futex_syscall() - SYS_futex syscall wrapper > + * This is copied from linux/time_types.h. > + * We copy this here to avoid compilation failures when running > + * on systems that don't ship with linux/time_types.h. > + */ > +struct __kernel_old_timespec { > + __kernel_old_time_t tv_sec; /* seconds */ > + long tv_nsec; /* nanoseconds */ > +}; > + > +/** > + * futex_syscall() - __NR_futex syscall wrapper > * @uaddr: address of first futex > * @op: futex op code > * @val: typically expected value of uaddr, but varies by op > @@ -49,14 +60,49 @@ static inline int > futex_syscall(volatile u_int32_t *uaddr, int op, u_int32_t val, struct timespec *timeout, > volatile u_int32_t *uaddr2, int val3, int opflags) > { > - return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); > +#if defined(__NR_futex_time64) > + if (sizeof(*timeout) != sizeof(struct __kernel_old_timespec)) { > + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, timeout, > + uaddr2, val3); > + if (ret == 0 || errno != ENOSYS) > + return ret; > + } > +#endif > + > +#if defined(__NR_futex) > + if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec)) > + return syscall(__NR_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); > + > + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) { > + struct __kernel_old_timespec ts32; > + > + ts32.tv_sec = (__kernel_long_t) timeout->tv_sec; > + ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec; > + > + return syscall(__NR_futex, uaddr, op | opflags, val, ts32, uaddr2, val3); > + } else if (!timeout) { > + return syscall(__NR_futex, uaddr, op | opflags, val, NULL, uaddr2, val3); > + } > +#endif > + > + errno = ENOSYS; > + return -1; > } > > static inline int > futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t val, int nr_requeue, > volatile u_int32_t *uaddr2, int val3, int opflags) > { > - return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); > +#if defined(__NR_futex_time64) > + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, nr_requeue, > + uaddr2, val3); > + if (ret == 0 || errno != ENOSYS) > + return ret; > +#endif > + > +#if defined(__NR_futex) > + return syscall(__NR_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); > +#endif > } > > /** > -- > 2.31.1
Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > From: Alistair Francis <alistair.francis@wdc.com> > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > time_t and as such don't have the SYS_futex syscall. This patch will > allow us to use the SYS_futex_time64 syscall on those platforms. > > This also converts the futex calls to be y2038 safe (when built for a > 5.1+ kernel). > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > The original commit was reverted as including linux/time_types.h would > fail to compile on older kernels. This commit doesn't include > linux/time_types.h to avoid this issue. 10 9.99 alpine:3.12 : FAIL gcc version 9.3.0 (Alpine 9.3.0) In file included from bench/futex-hash.c:29: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' 37 | __kernel_old_time_t tv_sec; /* seconds */ | ^~~~~~~~~~~~~~~~~~~ In file included from bench/futex-wake.c:25: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' 37 | __kernel_old_time_t tv_sec; /* seconds */ | ^~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-5.16.0-rc4/tools/build/Makefile.build:139: bench] Error 2 11 114.27 alpine:3.13 : Ok gcc (Alpine 10.2.1_pre1) 10.2.1 20201203 , Alpine clang version 10.0.1 12 100.12 alpine:3.14 : Ok gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424 , Alpine clang version 11.1.0 13 101.06 alpine:3.15 : Ok gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027 , Alpine clang version 12.0.1 14 101.96 alpine:edge : Ok gcc (Alpine 11.2.1_git20211128) 11.2.1 20211128 , Alpine clang version 12.0.1 15 6.98 alt:p8 : FAIL gcc version 5.3.1 20151207 (ALT p8 5.3.1-alt3.M80P.1) (GCC) In file included from bench/futex-hash.c:29:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^ In file included from bench/futex-wake.c:25:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^ In file included from bench/futex-wake-parallel.c:31:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^ make[3]: *** [bench] Error 2 16 73.65 alt:p9 : Ok x86_64-alt-linux-gcc (GCC) 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) , clang version 10.0.0 17 72.34 alt:sisyphus : Ok x86_64-alt-linux-gcc (GCC) 11.2.1 20210911 (ALT Sisyphus 11.2.1-alt1) , ALT Linux Team clang version 12.0.1 18 7.58 amazonlinux:1 : FAIL gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) In file included from bench/futex-hash.c:29:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ In file included from bench/futex-wake.c:25:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ make[3]: *** [bench] Error 2 19 8.28 amazonlinux:2 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC) In file included from bench/futex-hash.c:29:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ make[3]: *** [bench] Error 2 20 79.16 centos:8 : Ok gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) , clang version 11.0.1 (Red Hat 11.0.1-1.module_el8.4.0+966+2995ef20) Still building on the other containers. - Arnaldo
Em Fri, Dec 10, 2021 at 10:36:30AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > > From: Alistair Francis <alistair.francis@wdc.com> > > > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > > time_t and as such don't have the SYS_futex syscall. This patch will > > allow us to use the SYS_futex_time64 syscall on those platforms. > > > > This also converts the futex calls to be y2038 safe (when built for a > > 5.1+ kernel). > > > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > > > The original commit was reverted as including linux/time_types.h would > > fail to compile on older kernels. This commit doesn't include > > linux/time_types.h to avoid this issue. > > 10 9.99 alpine:3.12 : FAIL gcc version 9.3.0 (Alpine 9.3.0) > In file included from bench/futex-hash.c:29: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > 37 | __kernel_old_time_t tv_sec; /* seconds */ > | ^~~~~~~~~~~~~~~~~~~ > In file included from bench/futex-wake.c:25: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > 37 | __kernel_old_time_t tv_sec; /* seconds */ > | ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [/git/perf-5.16.0-rc4/tools/build/Makefile.build:139: bench] Error 2 > 11 114.27 alpine:3.13 : Ok gcc (Alpine 10.2.1_pre1) 10.2.1 20201203 , Alpine clang version 10.0.1 > 12 100.12 alpine:3.14 : Ok gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424 , Alpine clang version 11.1.0 > 13 101.06 alpine:3.15 : Ok gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027 , Alpine clang version 12.0.1 > 14 101.96 alpine:edge : Ok gcc (Alpine 11.2.1_git20211128) 11.2.1 20211128 , Alpine clang version 12.0.1 > 15 6.98 alt:p8 : FAIL gcc version 5.3.1 20151207 (ALT p8 5.3.1-alt3.M80P.1) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > In file included from bench/futex-wake.c:25:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > In file included from bench/futex-wake-parallel.c:31:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > make[3]: *** [bench] Error 2 > 16 73.65 alt:p9 : Ok x86_64-alt-linux-gcc (GCC) 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) , clang version 10.0.0 > 17 72.34 alt:sisyphus : Ok x86_64-alt-linux-gcc (GCC) 11.2.1 20210911 (ALT Sisyphus 11.2.1-alt1) , ALT Linux Team clang version 12.0.1 > 18 7.58 amazonlinux:1 : FAIL gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > In file included from bench/futex-wake.c:25:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [bench] Error 2 > 19 8.28 amazonlinux:2 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [bench] Error 2 > 20 79.16 centos:8 : Ok gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) , clang version 11.0.1 (Red Hat 11.0.1-1.module_el8.4.0+966+2995ef20) > > > Still building on the other containers. Some more: 21 94.54 centos:stream : Ok gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-3) , clang version 12.0.1 (Red Hat 12.0.1-2.module_el8.6.0+937+1cafe22c) 22 48.51 clearlinux:latest : Ok gcc (Clear Linux OS for Intel Architecture) 11.2.1 20211202 releases/gcc-11.2.0-549-g2d5be1fca0 , clang version 11.1.0 23 7.38 debian:9 : FAIL gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) In file included from bench/futex-wake.c:25:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ In file included from bench/futex-hash.c:29:0: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ /git/perf-5.16.0-rc4/tools/build/Makefile.build:139: recipe for target 'bench' failed make[3]: *** [bench] Error 2 24 7.08 debian:10 : FAIL gcc version 8.3.0 (Debian 8.3.0-6) In file included from bench/futex-hash.c:29: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ In file included from bench/futex-wake.c:25: bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' __kernel_old_time_t tv_sec; /* seconds */ ^~~~~~~~~~~~~~~~~~~ make[3]: *** [/git/perf-5.16.0-rc4/tools/build/Makefile.build:139: bench] Error 2 25 79.95 debian:11 : Ok gcc (Debian 10.2.1-6) 10.2.1 20210110 , Debian clang version 11.0.1-2
On Fri, Dec 10, 2021 at 2:44 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > Em Fri, Dec 10, 2021 at 10:36:30AM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > > > From: Alistair Francis <alistair.francis@wdc.com> > > > > > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > > > time_t and as such don't have the SYS_futex syscall. This patch will > > > allow us to use the SYS_futex_time64 syscall on those platforms. > > > > > > This also converts the futex calls to be y2038 safe (when built for a > > > 5.1+ kernel). > > > > > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > > > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > > > > > The original commit was reverted as including linux/time_types.h would > > > fail to compile on older kernels. This commit doesn't include > > > linux/time_types.h to avoid this issue. > > > > 10 9.99 alpine:3.12 : FAIL gcc version 9.3.0 (Alpine 9.3.0) > > In file included from bench/futex-hash.c:29: > > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > > 37 | __kernel_old_time_t tv_sec; /* seconds */ > > | ^~~~~~~~~~~~~~~~~~~ > > In file included from bench/futex-wake.c:25: It looks like we need to add include/uapi/linux/time_types.h to tools/include/linux/ and update tools/include/linux/types.h in order to address this. Arnd
Em Fri, Dec 10, 2021 at 03:23:42PM +0100, Arnd Bergmann escreveu: > On Fri, Dec 10, 2021 at 2:44 PM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > Em Fri, Dec 10, 2021 at 10:36:30AM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > > > > From: Alistair Francis <alistair.francis@wdc.com> > > > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > > > > time_t and as such don't have the SYS_futex syscall. This patch will > > > > allow us to use the SYS_futex_time64 syscall on those platforms. > > > > This also converts the futex calls to be y2038 safe (when built for a > > > > 5.1+ kernel). > > > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > > > > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > > > The original commit was reverted as including linux/time_types.h would > > > > fail to compile on older kernels. This commit doesn't include > > > > linux/time_types.h to avoid this issue. > > > 10 9.99 alpine:3.12 : FAIL gcc version 9.3.0 (Alpine 9.3.0) > > > In file included from bench/futex-hash.c:29: > > > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > > > 37 | __kernel_old_time_t tv_sec; /* seconds */ > > > | ^~~~~~~~~~~~~~~~~~~ > > > In file included from bench/futex-wake.c:25: > It looks like we need to add include/uapi/linux/time_types.h to > tools/include/linux/ and update tools/include/linux/types.h > in order to address this. And make sure it is found before the system ones, yes, that would fix the issues. I'll try to do it these days. - Arnaldo
On Fri, Dec 10, 2021 at 11:36 PM Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> wrote: > > Em Fri, Dec 10, 2021 at 09:58:52AM +1000, Alistair Francis escreveu: > > From: Alistair Francis <alistair.francis@wdc.com> > > > > Some 32-bit architectures (such are 32-bit RISC-V) only have a 64-bit > > time_t and as such don't have the SYS_futex syscall. This patch will > > allow us to use the SYS_futex_time64 syscall on those platforms. > > > > This also converts the futex calls to be y2038 safe (when built for a > > 5.1+ kernel). > > > > This is a revert of commit ba4026b09d83acf56c040b6933eac7916c27e728 > > "Revert "perf bench futex: Add support for 32-bit systems with 64-bit time_t"". > > > > The original commit was reverted as including linux/time_types.h would > > fail to compile on older kernels. This commit doesn't include > > linux/time_types.h to avoid this issue. > > 10 9.99 alpine:3.12 : FAIL gcc version 9.3.0 (Alpine 9.3.0) > In file included from bench/futex-hash.c:29: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > 37 | __kernel_old_time_t tv_sec; /* seconds */ > | ^~~~~~~~~~~~~~~~~~~ > In file included from bench/futex-wake.c:25: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > 37 | __kernel_old_time_t tv_sec; /* seconds */ > | ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [/git/perf-5.16.0-rc4/tools/build/Makefile.build:139: bench] Error 2 > 11 114.27 alpine:3.13 : Ok gcc (Alpine 10.2.1_pre1) 10.2.1 20201203 , Alpine clang version 10.0.1 > 12 100.12 alpine:3.14 : Ok gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424 , Alpine clang version 11.1.0 > 13 101.06 alpine:3.15 : Ok gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027 , Alpine clang version 12.0.1 > 14 101.96 alpine:edge : Ok gcc (Alpine 11.2.1_git20211128) 11.2.1 20211128 , Alpine clang version 12.0.1 > 15 6.98 alt:p8 : FAIL gcc version 5.3.1 20151207 (ALT p8 5.3.1-alt3.M80P.1) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > In file included from bench/futex-wake.c:25:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > In file included from bench/futex-wake-parallel.c:31:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^ > make[3]: *** [bench] Error 2 > 16 73.65 alt:p9 : Ok x86_64-alt-linux-gcc (GCC) 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) , clang version 10.0.0 > 17 72.34 alt:sisyphus : Ok x86_64-alt-linux-gcc (GCC) 11.2.1 20210911 (ALT Sisyphus 11.2.1-alt1) , ALT Linux Team clang version 12.0.1 > 18 7.58 amazonlinux:1 : FAIL gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > In file included from bench/futex-wake.c:25:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [bench] Error 2 > 19 8.28 amazonlinux:2 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC) > In file included from bench/futex-hash.c:29:0: > bench/futex.h:37:2: error: unknown type name '__kernel_old_time_t' > __kernel_old_time_t tv_sec; /* seconds */ > ^~~~~~~~~~~~~~~~~~~ > make[3]: *** [bench] Error 2 > 20 79.16 centos:8 : Ok gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) , clang version 11.0.1 (Red Hat 11.0.1-1.module_el8.4.0+966+2995ef20) Is there a way I can reproduce this failure? Alistair > > > Still building on the other containers. > > - Arnaldo
diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h index ebdc2b032afc..385d2bdfaa9f 100644 --- a/tools/perf/bench/futex.h +++ b/tools/perf/bench/futex.h @@ -8,6 +8,7 @@ #ifndef _FUTEX_H #define _FUTEX_H +#include <errno.h> #include <unistd.h> #include <sys/syscall.h> #include <sys/types.h> @@ -28,7 +29,17 @@ struct bench_futex_parameters { }; /** - * futex_syscall() - SYS_futex syscall wrapper + * This is copied from linux/time_types.h. + * We copy this here to avoid compilation failures when running + * on systems that don't ship with linux/time_types.h. + */ +struct __kernel_old_timespec { + __kernel_old_time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +/** + * futex_syscall() - __NR_futex syscall wrapper * @uaddr: address of first futex * @op: futex op code * @val: typically expected value of uaddr, but varies by op @@ -49,14 +60,49 @@ static inline int futex_syscall(volatile u_int32_t *uaddr, int op, u_int32_t val, struct timespec *timeout, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); +#if defined(__NR_futex_time64) + if (sizeof(*timeout) != sizeof(struct __kernel_old_timespec)) { + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, timeout, + uaddr2, val3); + if (ret == 0 || errno != ENOSYS) + return ret; + } +#endif + +#if defined(__NR_futex) + if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec)) + return syscall(__NR_futex, uaddr, op | opflags, val, timeout, uaddr2, val3); + + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) { + struct __kernel_old_timespec ts32; + + ts32.tv_sec = (__kernel_long_t) timeout->tv_sec; + ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec; + + return syscall(__NR_futex, uaddr, op | opflags, val, ts32, uaddr2, val3); + } else if (!timeout) { + return syscall(__NR_futex, uaddr, op | opflags, val, NULL, uaddr2, val3); + } +#endif + + errno = ENOSYS; + return -1; } static inline int futex_syscall_nr_requeue(volatile u_int32_t *uaddr, int op, u_int32_t val, int nr_requeue, volatile u_int32_t *uaddr2, int val3, int opflags) { - return syscall(SYS_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); +#if defined(__NR_futex_time64) + int ret = syscall(__NR_futex_time64, uaddr, op | opflags, val, nr_requeue, + uaddr2, val3); + if (ret == 0 || errno != ENOSYS) + return ret; +#endif + +#if defined(__NR_futex) + return syscall(__NR_futex, uaddr, op | opflags, val, nr_requeue, uaddr2, val3); +#endif } /**