* [PATCH] perf tools: avoid sample_reg_masks being const + weak @ 2019-09-27 21:10 Ian Rogers 2019-09-27 21:43 ` [PATCH v2] " Ian Rogers 0 siblings, 1 reply; 13+ messages in thread From: Ian Rogers @ 2019-09-27 21:10 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel Cc: Stephane Eranian, Ian Rogers Being const + weak breaks with some compilers that constant-propagate from the weak symbol. This behavior is outside of the specification, but in LLVM is chosen to match GCC's behavior. LLVM's implementation was set in this patch: https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 A const + weak symbol is set to be weak_odr: https://llvm.org/docs/LangRef.html ODR is one definition rule, and given there is one constant definition constant-propagation is possible. It is possible to get this code to miscompile with LLVM when applying link time optimization. As compilers become more aggressive, this is likely to break in more instances. Move the definition of sample_reg_masks to the conditional part of perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the weak symbol. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/parse-regs-options.c | 4 ++++ tools/perf/util/perf_regs.c | 4 ---- tools/perf/util/perf_regs.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c index ef46c2848808..a6a776597df8 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -46,18 +46,22 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) if (!strcmp(s, "?")) { fprintf(stderr, "available registers: "); +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if (r->mask & mask) fprintf(stderr, "%s ", r->name); } +#endif fputc('\n', stderr); /* just printing available regs */ return -1; } +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if ((r->mask & mask) && !strcasecmp(s, r->name)) break; } +#endif if (!r->name) { ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", s, intr ? "-I" : "--user-regs="); diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index 2774cec1f15f..5ee47ae1509c 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -3,10 +3,6 @@ #include "perf_regs.h" #include "event.h" -const struct sample_reg __weak sample_reg_masks[] = { - SMPL_REG_END -}; - int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, char **new_op __maybe_unused) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 47fe34e5f7d5..e014c2c038f4 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,8 +15,6 @@ struct sample_reg { #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } #define SMPL_REG_END { .name = NULL } -extern const struct sample_reg sample_reg_masks[]; - enum { SDT_ARG_VALID = 0, SDT_ARG_SKIP, @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); uint64_t arch__user_reg_mask(void); #ifdef HAVE_PERF_REGS_SUPPORT +extern const struct sample_reg sample_reg_masks[]; + #include <perf_regs.h> #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-27 21:10 [PATCH] perf tools: avoid sample_reg_masks being const + weak Ian Rogers @ 2019-09-27 21:43 ` Ian Rogers 2019-09-29 21:05 ` Jiri Olsa 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers 0 siblings, 2 replies; 13+ messages in thread From: Ian Rogers @ 2019-09-27 21:43 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel Cc: Stephane Eranian, Ian Rogers Being const + weak breaks with some compilers that constant-propagate from the weak symbol. This behavior is outside of the specification, but in LLVM is chosen to match GCC's behavior. LLVM's implementation was set in this patch: https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 A const + weak symbol is set to be weak_odr: https://llvm.org/docs/LangRef.html ODR is one definition rule, and given there is one constant definition constant-propagation is possible. It is possible to get this code to miscompile with LLVM when applying link time optimization. As compilers become more aggressive, this is likely to break in more instances. Move the definition of sample_reg_masks to the conditional part of perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the weak symbol. Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/parse-regs-options.c | 8 ++++++-- tools/perf/util/perf_regs.c | 4 ---- tools/perf/util/perf_regs.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c index ef46c2848808..e687497b3aac 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -13,7 +13,7 @@ static int __parse_regs(const struct option *opt, const char *str, int unset, bool intr) { uint64_t *mode = (uint64_t *)opt->value; - const struct sample_reg *r; + const struct sample_reg *r = NULL; char *s, *os = NULL, *p; int ret = -1; uint64_t mask; @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) if (!strcmp(s, "?")) { fprintf(stderr, "available registers: "); +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if (r->mask & mask) fprintf(stderr, "%s ", r->name); } +#endif fputc('\n', stderr); /* just printing available regs */ return -1; } +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if ((r->mask & mask) && !strcasecmp(s, r->name)) break; } - if (!r->name) { +#endif + if (!r || !r->name) { ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", s, intr ? "-I" : "--user-regs="); goto error; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index 2774cec1f15f..5ee47ae1509c 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -3,10 +3,6 @@ #include "perf_regs.h" #include "event.h" -const struct sample_reg __weak sample_reg_masks[] = { - SMPL_REG_END -}; - int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, char **new_op __maybe_unused) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 47fe34e5f7d5..e014c2c038f4 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,8 +15,6 @@ struct sample_reg { #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } #define SMPL_REG_END { .name = NULL } -extern const struct sample_reg sample_reg_masks[]; - enum { SDT_ARG_VALID = 0, SDT_ARG_SKIP, @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); uint64_t arch__user_reg_mask(void); #ifdef HAVE_PERF_REGS_SUPPORT +extern const struct sample_reg sample_reg_masks[]; + #include <perf_regs.h> #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-27 21:43 ` [PATCH v2] " Ian Rogers @ 2019-09-29 21:05 ` Jiri Olsa 2019-09-30 10:39 ` Arnaldo Carvalho de Melo 2019-09-30 12:23 ` Arnaldo Carvalho de Melo 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers 1 sibling, 2 replies; 13+ messages in thread From: Jiri Olsa @ 2019-09-29 21:05 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel, Stephane Eranian On Fri, Sep 27, 2019 at 02:43:41PM -0700, Ian Rogers wrote: > Being const + weak breaks with some compilers that constant-propagate > from the weak symbol. This behavior is outside of the specification, but > in LLVM is chosen to match GCC's behavior. > > LLVM's implementation was set in this patch: > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > A const + weak symbol is set to be weak_odr: > https://llvm.org/docs/LangRef.html > ODR is one definition rule, and given there is one constant definition > constant-propagation is possible. It is possible to get this code to > miscompile with LLVM when applying link time optimization. As compilers > become more aggressive, this is likely to break in more instances. > > Move the definition of sample_reg_masks to the conditional part of > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > weak symbol. > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > > Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Jiri Olsa <jolsa@kernel.org> thanks, jirka > --- > tools/perf/util/parse-regs-options.c | 8 ++++++-- > tools/perf/util/perf_regs.c | 4 ---- > tools/perf/util/perf_regs.h | 4 ++-- > 3 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c > index ef46c2848808..e687497b3aac 100644 > --- a/tools/perf/util/parse-regs-options.c > +++ b/tools/perf/util/parse-regs-options.c > @@ -13,7 +13,7 @@ static int > __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > { > uint64_t *mode = (uint64_t *)opt->value; > - const struct sample_reg *r; > + const struct sample_reg *r = NULL; > char *s, *os = NULL, *p; > int ret = -1; > uint64_t mask; > @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > > if (!strcmp(s, "?")) { > fprintf(stderr, "available registers: "); > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if (r->mask & mask) > fprintf(stderr, "%s ", r->name); > } > +#endif > fputc('\n', stderr); > /* just printing available regs */ > return -1; > } > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if ((r->mask & mask) && !strcasecmp(s, r->name)) > break; > } > - if (!r->name) { > +#endif > + if (!r || !r->name) { > ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", > s, intr ? "-I" : "--user-regs="); > goto error; > diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c > index 2774cec1f15f..5ee47ae1509c 100644 > --- a/tools/perf/util/perf_regs.c > +++ b/tools/perf/util/perf_regs.c > @@ -3,10 +3,6 @@ > #include "perf_regs.h" > #include "event.h" > > -const struct sample_reg __weak sample_reg_masks[] = { > - SMPL_REG_END > -}; > - > int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, > char **new_op __maybe_unused) > { > diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h > index 47fe34e5f7d5..e014c2c038f4 100644 > --- a/tools/perf/util/perf_regs.h > +++ b/tools/perf/util/perf_regs.h > @@ -15,8 +15,6 @@ struct sample_reg { > #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } > #define SMPL_REG_END { .name = NULL } > > -extern const struct sample_reg sample_reg_masks[]; > - > enum { > SDT_ARG_VALID = 0, > SDT_ARG_SKIP, > @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); > uint64_t arch__user_reg_mask(void); > > #ifdef HAVE_PERF_REGS_SUPPORT > +extern const struct sample_reg sample_reg_masks[]; > + > #include <perf_regs.h> > > #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) > -- > 2.23.0.444.g18eeb5a265-goog > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-29 21:05 ` Jiri Olsa @ 2019-09-30 10:39 ` Arnaldo Carvalho de Melo 2019-09-30 12:23 ` Arnaldo Carvalho de Melo 1 sibling, 0 replies; 13+ messages in thread From: Arnaldo Carvalho de Melo @ 2019-09-30 10:39 UTC (permalink / raw) To: Jiri Olsa Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel, Stephane Eranian Em Sun, Sep 29, 2019 at 11:05:14PM +0200, Jiri Olsa escreveu: > On Fri, Sep 27, 2019 at 02:43:41PM -0700, Ian Rogers wrote: > > Being const + weak breaks with some compilers that constant-propagate > > from the weak symbol. This behavior is outside of the specification, but > > in LLVM is chosen to match GCC's behavior. > > > > LLVM's implementation was set in this patch: > > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > > A const + weak symbol is set to be weak_odr: > > https://llvm.org/docs/LangRef.html > > ODR is one definition rule, and given there is one constant definition > > constant-propagation is possible. It is possible to get this code to > > miscompile with LLVM when applying link time optimization. As compilers > > become more aggressive, this is likely to break in more instances. > > > > Move the definition of sample_reg_masks to the conditional part of > > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > > weak symbol. > > > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > Acked-by: Jiri Olsa <jolsa@kernel.org> Thanks, applied. - Arnaldo ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-29 21:05 ` Jiri Olsa 2019-09-30 10:39 ` Arnaldo Carvalho de Melo @ 2019-09-30 12:23 ` Arnaldo Carvalho de Melo 2019-09-30 12:42 ` Jiri Olsa 1 sibling, 1 reply; 13+ messages in thread From: Arnaldo Carvalho de Melo @ 2019-09-30 12:23 UTC (permalink / raw) To: Ian Rogers Cc: Jiri Olsa, Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel, Stephane Eranian Em Sun, Sep 29, 2019 at 11:05:14PM +0200, Jiri Olsa escreveu: > On Fri, Sep 27, 2019 at 02:43:41PM -0700, Ian Rogers wrote: > > Being const + weak breaks with some compilers that constant-propagate > > from the weak symbol. This behavior is outside of the specification, but > > in LLVM is chosen to match GCC's behavior. > > > > LLVM's implementation was set in this patch: > > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > > A const + weak symbol is set to be weak_odr: > > https://llvm.org/docs/LangRef.html > > ODR is one definition rule, and given there is one constant definition > > constant-propagation is possible. It is possible to get this code to > > miscompile with LLVM when applying link time optimization. As compilers > > become more aggressive, this is likely to break in more instances. > > > > Move the definition of sample_reg_masks to the conditional part of > > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > > weak symbol. > > > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > Acked-by: Jiri Olsa <jolsa@kernel.org> Breaks the build on arm64, I'm removing it from perf/urgent till this gets settled. LINK /tmp/build/perf/perf /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /tmp/build/perf/perf-in.o: in function `__parse_regs': /git/linux/tools/perf/util/parse-regs-options.c:39: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:47: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:60: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:50: undefined reference to `sample_reg_masks' collect2: error: ld returned 1 exit status make[2]: *** [Makefile.perf:609: /tmp/build/perf/perf] Error 1 make[1]: *** [Makefile.perf:221: sub-make] Error 2 make: *** [Makefile:70: all] Error 2 make: Leaving directory '/git/linux/tools/perf' + exit 1 [root@quaco ~]# Complete output: [root@quaco ~]# cat dm.log/debian\:experimental-x-arm64 debian:experimental-x-arm64 Downloading http://192.168.124.1/perf/perf-5.3.0.tar.xz... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1646k 100 1646k 0 0 803M 0 --:--:-- --:--:-- --:--:-- 803M d6bf2b2334abdabfe14cbc7cb161ba72b515e11d Using built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/8/lto-wrapper Target: aarch64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-19' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --disable-libphobos --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include --with-build-config=bootstrap-lto --enable-link-mutex Thread model: posix gcc version 8.3.0 (Debian 8.3.0-19) + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- EXTRA_CFLAGS= -C /git/linux/tools/perf O=/tmp/build/perf make: Entering directory '/git/linux/tools/perf' BUILD: Doing 'make -j8' parallel build HOSTCC /tmp/build/perf/fixdep.o HOSTLD /tmp/build/perf/fixdep-in.o LINK /tmp/build/perf/fixdep sh: 1: command: Illegal option -c Auto-detecting system features: ... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ OFF ] ... libaudit: [ on ] ... libbfd: [ OFF ] ... libcap: [ OFF ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ OFF ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ OFF ] ... bpf: [ on ] ... libaio: [ on ] ... libzstd: [ OFF ] ... disassembler-four-args: [ OFF ] Makefile.config:670: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev Makefile.config:724: No python interpreter was found: disables Python support - please install python-devel/python-dev Makefile.config:782: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling Makefile.config:826: No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR Makefile.config:837: No libcap found, disables capability support, please install libcap-devel/libcap-dev Makefile.config:905: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:931: No alternatives command found, you need to set JDIR= to point to the root of your Java directory GEN /tmp/build/perf/common-cmds.h PERF_VERSION = 5.3.gd6bf2b2334ab CC /tmp/build/perf/exec-cmd.o MKDIR /tmp/build/perf/fd/ CC /tmp/build/perf/fd/array.o CC /tmp/build/perf/event-parse.o CC /tmp/build/perf/core.o CC /tmp/build/perf/event-plugin.o CC /tmp/build/perf/libbpf.o CC /tmp/build/perf/trace-seq.o CC /tmp/build/perf/cpumap.o CC /tmp/build/perf/threadmap.o LD /tmp/build/perf/fd/libapi-in.o MKDIR /tmp/build/perf/fs/ CC /tmp/build/perf/fs/fs.o CC /tmp/build/perf/evsel.o MKDIR /tmp/build/perf/fs/ CC /tmp/build/perf/bpf.o CC /tmp/build/perf/fs/tracing_path.o CC /tmp/build/perf/evlist.o CC /tmp/build/perf/help.o CC /tmp/build/perf/zalloc.o CC /tmp/build/perf/xyarray.o LD /tmp/build/perf/fs/libapi-in.o CC /tmp/build/perf/lib.o CC /tmp/build/perf/cpu.o CC /tmp/build/perf/debug.o CC /tmp/build/perf/nlattr.o CC /tmp/build/perf/btf.o LD /tmp/build/perf/libperf-in.o AR /tmp/build/perf/libperf.a CC /tmp/build/perf/str_error_r.o CC /tmp/build/perf/libbpf_errno.o CC /tmp/build/perf/str_error.o CC /tmp/build/perf/netlink.o LD /tmp/build/perf/libapi-in.o CC /tmp/build/perf/bpf_prog_linfo.o AR /tmp/build/perf/libapi.a CC /tmp/build/perf/libbpf_probes.o CC /tmp/build/perf/pager.o CC /tmp/build/perf/parse-options.o CC /tmp/build/perf/parse-filter.o CC /tmp/build/perf/run-command.o CC /tmp/build/perf/xsk.o CC /tmp/build/perf/sigchain.o CC /tmp/build/perf/hashmap.o CC /tmp/build/perf/subcmd-config.o CC /tmp/build/perf/btf_dump.o CC /tmp/build/perf/parse-utils.o CC /tmp/build/perf/kbuffer-parse.o CC /tmp/build/perf/tep_strerror.o CC /tmp/build/perf/event-parse-api.o MKDIR /tmp/build/perf/pmu-events/ HOSTCC /tmp/build/perf/pmu-events/json.o GEN perf-archive GEN perf-with-kcore MKDIR /tmp/build/perf/pmu-events/ HOSTCC /tmp/build/perf/pmu-events/jsmn.o DESCEND plugins HOSTCC /tmp/build/perf/pmu-events/jevents.o LD /tmp/build/perf/libtraceevent-in.o LINK /tmp/build/perf/libtraceevent.a CC /tmp/build/perf/plugins/plugin_jbd2.o CC /tmp/build/perf/plugins/plugin_hrtimer.o CC /tmp/build/perf/plugins/plugin_kmem.o CC /tmp/build/perf/plugins/plugin_kvm.o LD /tmp/build/perf/libbpf-in.o LINK /tmp/build/perf/libbpf.a CC /tmp/build/perf/plugins/plugin_mac80211.o LD /tmp/build/perf/plugins/plugin_jbd2-in.o LD /tmp/build/perf/plugins/plugin_hrtimer-in.o CC /tmp/build/perf/plugins/plugin_sched_switch.o CC /tmp/build/perf/plugins/plugin_function.o LD /tmp/build/perf/plugins/plugin_kmem-in.o CC /tmp/build/perf/plugins/plugin_xen.o LD /tmp/build/perf/plugins/plugin_kvm-in.o LD /tmp/build/perf/plugins/plugin_mac80211-in.o CC /tmp/build/perf/plugins/plugin_scsi.o HOSTLD /tmp/build/perf/pmu-events/jevents-in.o CC /tmp/build/perf/plugins/plugin_cfg80211.o LINK /tmp/build/perf/pmu-events/jevents LD /tmp/build/perf/plugins/plugin_sched_switch-in.o LD /tmp/build/perf/plugins/plugin_function-in.o LD /tmp/build/perf/plugins/plugin_xen-in.o LINK /tmp/build/perf/plugins/plugin_jbd2.so LINK /tmp/build/perf/plugins/plugin_hrtimer.so LINK /tmp/build/perf/plugins/plugin_kmem.so GEN /tmp/build/perf/pmu-events/pmu-events.c LINK /tmp/build/perf/plugins/plugin_kvm.so LINK /tmp/build/perf/plugins/plugin_mac80211.so CC /tmp/build/perf/pmu-events/pmu-events.o LINK /tmp/build/perf/plugins/plugin_sched_switch.so LD /tmp/build/perf/plugins/plugin_cfg80211-in.o LINK /tmp/build/perf/plugins/plugin_function.so LINK /tmp/build/perf/plugins/plugin_xen.so LINK /tmp/build/perf/plugins/plugin_cfg80211.so LD /tmp/build/perf/plugins/plugin_scsi-in.o LINK /tmp/build/perf/plugins/plugin_scsi.so LD /tmp/build/perf/pmu-events/pmu-events-in.o GEN /tmp/build/perf/plugins/libtraceevent-dynamic-list CC /tmp/build/perf/builtin-bench.o CC /tmp/build/perf/builtin-annotate.o CC /tmp/build/perf/builtin-config.o CC /tmp/build/perf/builtin-diff.o CC /tmp/build/perf/builtin-evlist.o CC /tmp/build/perf/builtin-ftrace.o make[3]: Nothing to be done for '/tmp/build/perf/plugins/libtraceevent-dynamic-list'. CC /tmp/build/perf/builtin-help.o LD /tmp/build/perf/libsubcmd-in.o AR /tmp/build/perf/libsubcmd.a CC /tmp/build/perf/builtin-sched.o CC /tmp/build/perf/builtin-buildid-list.o CC /tmp/build/perf/builtin-buildid-cache.o CC /tmp/build/perf/builtin-kallsyms.o CC /tmp/build/perf/builtin-list.o CC /tmp/build/perf/builtin-record.o CC /tmp/build/perf/builtin-report.o CC /tmp/build/perf/builtin-stat.o CC /tmp/build/perf/builtin-timechart.o CC /tmp/build/perf/builtin-top.o CC /tmp/build/perf/builtin-script.o CC /tmp/build/perf/builtin-kmem.o CC /tmp/build/perf/builtin-lock.o CC /tmp/build/perf/builtin-kvm.o CC /tmp/build/perf/builtin-inject.o CC /tmp/build/perf/builtin-mem.o CC /tmp/build/perf/builtin-data.o CC /tmp/build/perf/builtin-version.o CC /tmp/build/perf/builtin-c2c.o CC /tmp/build/perf/builtin-trace.o CC /tmp/build/perf/builtin-probe.o MKDIR /tmp/build/perf/bench/ CC /tmp/build/perf/bench/sched-messaging.o MKDIR /tmp/build/perf/tests/ CC /tmp/build/perf/tests/builtin-test.o MKDIR /tmp/build/perf/util/ CC /tmp/build/perf/arch/common.o CC /tmp/build/perf/util/annotate.o MKDIR /tmp/build/perf/bench/ CC /tmp/build/perf/bench/sched-pipe.o MKDIR /tmp/build/perf/arch/arm64/util/ CC /tmp/build/perf/arch/arm64/util/header.o MKDIR /tmp/build/perf/arch/arm64/util/ CC /tmp/build/perf/arch/arm64/util/sym-handling.o CC /tmp/build/perf/bench/mem-functions.o MKDIR /tmp/build/perf/tests/ CC /tmp/build/perf/tests/parse-events.o MKDIR /tmp/build/perf/arch/arm64/tests/ CC /tmp/build/perf/arch/arm64/tests/regs_load.o MKDIR /tmp/build/perf/arch/arm64/tests/ CC /tmp/build/perf/arch/arm64/tests/dwarf-unwind.o CC /tmp/build/perf/arch/arm64/util/dwarf-regs.o CC /tmp/build/perf/arch/arm64/util/unwind-libunwind.o CC /tmp/build/perf/arch/arm64/tests/arch-tests.o MKDIR /tmp/build/perf/arch/arm64/util/../../arm/util/ CC /tmp/build/perf/arch/arm64/util/../../arm/util/pmu.o LD /tmp/build/perf/arch/arm64/tests/perf-in.o MKDIR /tmp/build/perf/arch/arm64/util/../../arm/util/ CC /tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o CC /tmp/build/perf/bench/futex-hash.o CC /tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o CC /tmp/build/perf/arch/arm64/util/arm-spe.o CC /tmp/build/perf/bench/futex-wake.o CC /tmp/build/perf/bench/futex-wake-parallel.o CC /tmp/build/perf/bench/futex-requeue.o MKDIR /tmp/build/perf/ui/ CC /tmp/build/perf/ui/setup.o LD /tmp/build/perf/arch/arm64/util/perf-in.o LD /tmp/build/perf/arch/arm64/perf-in.o LD /tmp/build/perf/arch/perf-in.o MKDIR /tmp/build/perf/scripts/perl/Perf-Trace-Util/ CC /tmp/build/perf/scripts/perl/Perf-Trace-Util/Context.o CC /tmp/build/perf/bench/futex-lock-pi.o MKDIR /tmp/build/perf/ui/ CC /tmp/build/perf/ui/helpline.o CC /tmp/build/perf/bench/epoll-wait.o CC /tmp/build/perf/ui/progress.o CC /tmp/build/perf/bench/epoll-ctl.o CC /tmp/build/perf/ui/util.o CC /tmp/build/perf/trace/beauty/clone.o CC /tmp/build/perf/ui/hist.o CC /tmp/build/perf/trace/beauty/fcntl.o CC /tmp/build/perf/trace/beauty/flock.o CC /tmp/build/perf/trace/beauty/fsmount.o CC /tmp/build/perf/trace/beauty/fspick.o CC /tmp/build/perf/bench/numa.o CC /tmp/build/perf/trace/beauty/kcmp.o CC /tmp/build/perf/trace/beauty/mount_flags.o LD /tmp/build/perf/scripts/perl/Perf-Trace-Util/perf-in.o LD /tmp/build/perf/scripts/perf-in.o CC /tmp/build/perf/perf.o CC /tmp/build/perf/trace/beauty/move_mount.o CC /tmp/build/perf/trace/beauty/pkey_alloc.o CC /tmp/build/perf/trace/beauty/arch_prctl.o CC /tmp/build/perf/trace/beauty/prctl.o CC /tmp/build/perf/trace/beauty/renameat.o MKDIR /tmp/build/perf/util/ CC /tmp/build/perf/trace/beauty/sockaddr.o CC /tmp/build/perf/util/block-range.o CC /tmp/build/perf/trace/beauty/socket.o CC /tmp/build/perf/trace/beauty/statx.o CC /tmp/build/perf/trace/beauty/sync_file_range.o CC /tmp/build/perf/util/build-id.o CC /tmp/build/perf/util/cacheline.o CC /tmp/build/perf/tests/dso-data.o CC /tmp/build/perf/util/config.o CC /tmp/build/perf/util/copyfile.o LD /tmp/build/perf/trace/beauty/perf-in.o CC /tmp/build/perf/util/ctype.o CC /tmp/build/perf/util/db-export.o CC /tmp/build/perf/util/env.o CC /tmp/build/perf/tests/attr.o CC /tmp/build/perf/util/event.o CC /tmp/build/perf/util/evlist.o LD /tmp/build/perf/bench/perf-in.o CC /tmp/build/perf/util/evsel.o CC /tmp/build/perf/util/evsel_fprintf.o CC /tmp/build/perf/util/perf_event_attr_fprintf.o CC /tmp/build/perf/tests/vmlinux-kallsyms.o CC /tmp/build/perf/util/evswitch.o CC /tmp/build/perf/tests/openat-syscall.o CC /tmp/build/perf/util/find_bit.o CC /tmp/build/perf/util/kallsyms.o CC /tmp/build/perf/util/get_current_dir_name.o CC /tmp/build/perf/util/levenshtein.o CC /tmp/build/perf/tests/openat-syscall-all-cpus.o CC /tmp/build/perf/util/llvm-utils.o CC /tmp/build/perf/util/mmap.o MKDIR /tmp/build/perf/ui/stdio/ CC /tmp/build/perf/ui/stdio/hist.o CC /tmp/build/perf/util/memswap.o BISON /tmp/build/perf/util/parse-events-bison.c util/parse-events.y:1.1-12: warning: deprecated directive, use '%define api.pure' [-Wdeprecated] 1 | %pure-parser | ^~~~~~~~~~~~ CC /tmp/build/perf/util/perf_regs.o CC /tmp/build/perf/tests/openat-syscall-tp-fields.o util/parse-events.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother] CC /tmp/build/perf/util/path.o CC /tmp/build/perf/util/print_binary.o CC /tmp/build/perf/util/rlimit.o CC /tmp/build/perf/util/argv_split.o CC /tmp/build/perf/tests/mmap-basic.o CC /tmp/build/perf/util/rbtree.o CC /tmp/build/perf/util/libstring.o CC /tmp/build/perf/util/bitmap.o CC /tmp/build/perf/util/hweight.o CC /tmp/build/perf/util/smt.o CC /tmp/build/perf/tests/perf-record.o CC /tmp/build/perf/util/strbuf.o CC /tmp/build/perf/tests/evsel-roundtrip-name.o CC /tmp/build/perf/util/string.o CC /tmp/build/perf/util/strlist.o CC /tmp/build/perf/ui/browser.o CC /tmp/build/perf/util/strfilter.o CC /tmp/build/perf/util/top.o CC /tmp/build/perf/tests/evsel-tp-sched.o CC /tmp/build/perf/tests/fdarray.o CC /tmp/build/perf/util/usage.o CC /tmp/build/perf/tests/pmu.o CC /tmp/build/perf/tests/hists_common.o CC /tmp/build/perf/util/dso.o CC /tmp/build/perf/tests/hists_link.o CC /tmp/build/perf/util/dsos.o CC /tmp/build/perf/util/symbol.o CC /tmp/build/perf/tests/hists_filter.o CC /tmp/build/perf/tests/hists_output.o MKDIR /tmp/build/perf/ui/browsers/ CC /tmp/build/perf/ui/browsers/annotate.o CC /tmp/build/perf/util/symbol_fprintf.o CC /tmp/build/perf/tests/hists_cumulate.o CC /tmp/build/perf/tests/python-use.o CC /tmp/build/perf/tests/bp_signal.o CC /tmp/build/perf/util/color.o CC /tmp/build/perf/util/color_config.o CC /tmp/build/perf/tests/bp_signal_overflow.o CC /tmp/build/perf/util/metricgroup.o CC /tmp/build/perf/util/header.o CC /tmp/build/perf/util/callchain.o MKDIR /tmp/build/perf/ui/browsers/ CC /tmp/build/perf/ui/browsers/hists.o CC /tmp/build/perf/tests/bp_account.o CC /tmp/build/perf/ui/browsers/map.o CC /tmp/build/perf/tests/wp.o CC /tmp/build/perf/ui/browsers/scripts.o CC /tmp/build/perf/tests/task-exit.o CC /tmp/build/perf/util/values.o CC /tmp/build/perf/tests/sw-clock.o CC /tmp/build/perf/tests/mmap-thread-lookup.o CC /tmp/build/perf/util/debug.o CC /tmp/build/perf/ui/browsers/header.o CC /tmp/build/perf/tests/thread-mg-share.o CC /tmp/build/perf/util/machine.o CC /tmp/build/perf/ui/browsers/res_sample.o CC /tmp/build/perf/tests/switch-tracking.o CC /tmp/build/perf/tests/keep-tracking.o CC /tmp/build/perf/util/map.o CC /tmp/build/perf/util/pstack.o CC /tmp/build/perf/util/session.o CC /tmp/build/perf/tests/code-reading.o CC /tmp/build/perf/util/sample-raw.o CC /tmp/build/perf/tests/sample-parsing.o CC /tmp/build/perf/util/s390-sample-raw.o CC /tmp/build/perf/util/syscalltbl.o CC /tmp/build/perf/tests/parse-no-sample-id-all.o CC /tmp/build/perf/util/ordered-events.o CC /tmp/build/perf/tests/kmod-path.o CC /tmp/build/perf/tests/thread-map.o CC /tmp/build/perf/util/namespaces.o CC /tmp/build/perf/util/comm.o CC /tmp/build/perf/tests/llvm.o CC /tmp/build/perf/util/thread.o CC /tmp/build/perf/util/thread_map.o CC /tmp/build/perf/util/trace-event-parse.o CC /tmp/build/perf/tests/bpf.o CC /tmp/build/perf/util/parse-events-bison.o BISON /tmp/build/perf/util/pmu-bison.c CC /tmp/build/perf/util/trace-event-read.o CC /tmp/build/perf/tests/topology.o CC /tmp/build/perf/util/trace-event-info.o CC /tmp/build/perf/util/trace-event-scripting.o CC /tmp/build/perf/util/trace-event.o CC /tmp/build/perf/util/svghelper.o CC /tmp/build/perf/tests/mem.o CC /tmp/build/perf/util/sort.o CC /tmp/build/perf/util/hist.o CC /tmp/build/perf/tests/cpumap.o CC /tmp/build/perf/util/util.o CC /tmp/build/perf/util/cpumap.o CC /tmp/build/perf/tests/stat.o CC /tmp/build/perf/util/cputopo.o CC /tmp/build/perf/tests/event_update.o CC /tmp/build/perf/util/cgroup.o CC /tmp/build/perf/util/target.o CC /tmp/build/perf/util/rblist.o CC /tmp/build/perf/tests/event-times.o CC /tmp/build/perf/util/intlist.o CC /tmp/build/perf/util/vdso.o CC /tmp/build/perf/util/counts.o CC /tmp/build/perf/util/stat.o CC /tmp/build/perf/util/stat-shadow.o CC /tmp/build/perf/util/stat-display.o CC /tmp/build/perf/tests/expr.o CC /tmp/build/perf/util/record.o LD /tmp/build/perf/ui/browsers/perf-in.o MKDIR /tmp/build/perf/ui/tui/ CC /tmp/build/perf/ui/tui/setup.o CC /tmp/build/perf/tests/backward-ring-buffer.o MKDIR /tmp/build/perf/ui/tui/ CC /tmp/build/perf/ui/tui/util.o CC /tmp/build/perf/ui/tui/helpline.o CC /tmp/build/perf/tests/sdt.o CC /tmp/build/perf/util/srcline.o CC /tmp/build/perf/ui/tui/progress.o CC /tmp/build/perf/util/srccode.o CC /tmp/build/perf/tests/is_printable_array.o LD /tmp/build/perf/ui/tui/perf-in.o LD /tmp/build/perf/ui/perf-in.o CC /tmp/build/perf/tests/bitmap.o CC /tmp/build/perf/tests/perf-hooks.o CC /tmp/build/perf/tests/clang.o CC /tmp/build/perf/util/synthetic-events.o CC /tmp/build/perf/tests/unit_number__scnprintf.o CC /tmp/build/perf/tests/mem2node.o CC /tmp/build/perf/util/data.o CC /tmp/build/perf/tests/map_groups.o CC /tmp/build/perf/util/tsc.o CC /tmp/build/perf/tests/time-utils-test.o CC /tmp/build/perf/util/cloexec.o CC /tmp/build/perf/tests/dwarf-unwind.o CC /tmp/build/perf/util/call-path.o CC /tmp/build/perf/util/rwsem.o CC /tmp/build/perf/util/thread-stack.o CC /tmp/build/perf/util/auxtrace.o MKDIR /tmp/build/perf/util/intel-pt-decoder/ CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.o MKDIR /tmp/build/perf/util/scripting-engines/ CC /tmp/build/perf/util/scripting-engines/trace-event-perl.o CC /tmp/build/perf/util/intel-pt.o CC /tmp/build/perf/tests/llvm-src-base.o CC /tmp/build/perf/tests/llvm-src-kbuild.o CC /tmp/build/perf/tests/llvm-src-prologue.o CC /tmp/build/perf/tests/llvm-src-relocation.o CC /tmp/build/perf/util/intel-bts.o LD /tmp/build/perf/tests/perf-in.o CC /tmp/build/perf/util/arm-spe.o MKDIR /tmp/build/perf/util/intel-pt-decoder/ GEN /tmp/build/perf/util/intel-pt-decoder/inat-tables.c CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-log.o CC /tmp/build/perf/util/arm-spe-pkt-decoder.o CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-decoder.o CC /tmp/build/perf/util/s390-cpumsf.o CC /tmp/build/perf/util/parse-branch-options.o CC /tmp/build/perf/util/dump-insn.o CC /tmp/build/perf/util/parse-regs-options.o CC /tmp/build/perf/util/term.o CC /tmp/build/perf/util/help-unknown-cmd.o CC /tmp/build/perf/util/mem-events.o CC /tmp/build/perf/util/vsprintf.o CC /tmp/build/perf/util/units.o CC /tmp/build/perf/util/time-utils.o BISON /tmp/build/perf/util/expr-bison.c util/expr.y:15.1-12: warning: deprecated directive, use '%define api.pure' [-Wdeprecated] 15 | %pure-parser | ^~~~~~~~~~~~ util/expr.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother LD /tmp/build/perf/util/scripting-engines/perf-in.o ] CC /tmp/build/perf/util/branch.o CC /tmp/build/perf/util/mem2node.o CC /tmp/build/perf/util/bpf-loader.o CC /tmp/build/perf/util/bpf_map.o CC /tmp/build/perf/util/bpf-prologue.o CC /tmp/build/perf/util/symbol-elf.o CC /tmp/build/perf/util/probe-file.o CC /tmp/build/perf/util/probe-event.o CC /tmp/build/perf/util/probe-finder.o CC /tmp/build/perf/util/dwarf-aux.o CC /tmp/build/perf/util/dwarf-regs.o CC /tmp/build/perf/util/unwind-libunwind-local.o CC /tmp/build/perf/util/intel-pt-decoder/intel-pt-insn-decoder.o CC /tmp/build/perf/util/unwind-libunwind.o MKDIR /tmp/build/perf/util/libunwind/ CC /tmp/build/perf/util/libunwind/arm64.o CC /tmp/build/perf/util/zlib.o CC /tmp/build/perf/util/lzma.o CC /tmp/build/perf/util/demangle-java.o CC /tmp/build/perf/util/demangle-rust.o CC /tmp/build/perf/util/jitdump.o CC /tmp/build/perf/util/genelf.o CC /tmp/build/perf/util/genelf_debug.o CC /tmp/build/perf/util/perf-hooks.o CC /tmp/build/perf/util/bpf-event.o FLEX /tmp/build/perf/util/parse-events-flex.c LD /tmp/build/perf/util/intel-pt-decoder/perf-in.o FLEX /tmp/build/perf/util/pmu-flex.c CC /tmp/build/perf/util/pmu-bison.o CC /tmp/build/perf/util/expr-bison.o CC /tmp/build/perf/util/parse-events.o CC /tmp/build/perf/util/parse-events-flex.o CC /tmp/build/perf/util/pmu.o CC /tmp/build/perf/util/pmu-flex.o LD /tmp/build/perf/util/perf-in.o LD /tmp/build/perf/perf-in.o LINK /tmp/build/perf/perf /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /tmp/build/perf/perf-in.o: in function `__parse_regs': /git/linux/tools/perf/util/parse-regs-options.c:39: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:47: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:60: undefined reference to `sample_reg_masks' /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:50: undefined reference to `sample_reg_masks' collect2: error: ld returned 1 exit status make[2]: *** [Makefile.perf:609: /tmp/build/perf/perf] Error 1 make[1]: *** [Makefile.perf:221: sub-make] Error 2 make: *** [Makefile:70: all] Error 2 make: Leaving directory '/git/linux/tools/perf' + exit 1 [root@quaco ~]# ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-30 12:23 ` Arnaldo Carvalho de Melo @ 2019-09-30 12:42 ` Jiri Olsa 2019-10-01 0:36 ` Ian Rogers 0 siblings, 1 reply; 13+ messages in thread From: Jiri Olsa @ 2019-09-30 12:42 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel, Stephane Eranian On Mon, Sep 30, 2019 at 09:23:35AM -0300, Arnaldo Carvalho de Melo wrote: SNIP > CC /tmp/build/perf/util/lzma.o > CC /tmp/build/perf/util/demangle-java.o > CC /tmp/build/perf/util/demangle-rust.o > CC /tmp/build/perf/util/jitdump.o > CC /tmp/build/perf/util/genelf.o > CC /tmp/build/perf/util/genelf_debug.o > CC /tmp/build/perf/util/perf-hooks.o > CC /tmp/build/perf/util/bpf-event.o > FLEX /tmp/build/perf/util/parse-events-flex.c > LD /tmp/build/perf/util/intel-pt-decoder/perf-in.o > FLEX /tmp/build/perf/util/pmu-flex.c > CC /tmp/build/perf/util/pmu-bison.o > CC /tmp/build/perf/util/expr-bison.o > CC /tmp/build/perf/util/parse-events.o > CC /tmp/build/perf/util/parse-events-flex.o > CC /tmp/build/perf/util/pmu.o > CC /tmp/build/perf/util/pmu-flex.o > LD /tmp/build/perf/util/perf-in.o > LD /tmp/build/perf/perf-in.o > LINK /tmp/build/perf/perf > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /tmp/build/perf/perf-in.o: in function `__parse_regs': > /git/linux/tools/perf/util/parse-regs-options.c:39: undefined reference to `sample_reg_masks' > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:47: undefined reference to `sample_reg_masks' > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:60: undefined reference to `sample_reg_masks' > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:50: undefined reference to `sample_reg_masks' argh.. I tried on power.. should have tried on arm ;-) I expected that all the archs that set NO_PERF_REGS := 0 would have sample_reg_masks defined.. all those archs did fallback to the: const struct sample_reg __weak sample_reg_masks[] = { SMPL_REG_END }; those archs are not able to use --user-regs/--intr-regs options, but for dwarf unwind we set those registers manualy, so that works so I guess we need to define empty sample_reg_masks for those archs jirka ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] perf tools: avoid sample_reg_masks being const + weak 2019-09-30 12:42 ` Jiri Olsa @ 2019-10-01 0:36 ` Ian Rogers 0 siblings, 0 replies; 13+ messages in thread From: Ian Rogers @ 2019-10-01 0:36 UTC (permalink / raw) To: Jiri Olsa Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Namhyung Kim, Andi Kleen, LKML, Stephane Eranian Apologies for that. I've addressed in v3 but only tested for riscv. There is potential for additional tidy up related to this change, let me know what would be appropriate. Thanks, Ian On Mon, Sep 30, 2019 at 5:42 AM Jiri Olsa <jolsa@redhat.com> wrote: > > On Mon, Sep 30, 2019 at 09:23:35AM -0300, Arnaldo Carvalho de Melo wrote: > > SNIP > > > CC /tmp/build/perf/util/lzma.o > > CC /tmp/build/perf/util/demangle-java.o > > CC /tmp/build/perf/util/demangle-rust.o > > CC /tmp/build/perf/util/jitdump.o > > CC /tmp/build/perf/util/genelf.o > > CC /tmp/build/perf/util/genelf_debug.o > > CC /tmp/build/perf/util/perf-hooks.o > > CC /tmp/build/perf/util/bpf-event.o > > FLEX /tmp/build/perf/util/parse-events-flex.c > > LD /tmp/build/perf/util/intel-pt-decoder/perf-in.o > > FLEX /tmp/build/perf/util/pmu-flex.c > > CC /tmp/build/perf/util/pmu-bison.o > > CC /tmp/build/perf/util/expr-bison.o > > CC /tmp/build/perf/util/parse-events.o > > CC /tmp/build/perf/util/parse-events-flex.o > > CC /tmp/build/perf/util/pmu.o > > CC /tmp/build/perf/util/pmu-flex.o > > LD /tmp/build/perf/util/perf-in.o > > LD /tmp/build/perf/perf-in.o > > LINK /tmp/build/perf/perf > > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /tmp/build/perf/perf-in.o: in function `__parse_regs': > > /git/linux/tools/perf/util/parse-regs-options.c:39: undefined reference to `sample_reg_masks' > > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:47: undefined reference to `sample_reg_masks' > > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:60: undefined reference to `sample_reg_masks' > > /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /git/linux/tools/perf/util/parse-regs-options.c:50: undefined reference to `sample_reg_masks' > > argh.. I tried on power.. should have tried on arm ;-) > > I expected that all the archs that set NO_PERF_REGS := 0 would have > sample_reg_masks defined.. all those archs did fallback to the: > > const struct sample_reg __weak sample_reg_masks[] = { > SMPL_REG_END > }; > > those archs are not able to use --user-regs/--intr-regs options, > but for dwarf unwind we set those registers manualy, so that works > > so I guess we need to define empty sample_reg_masks for those archs > > jirka ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3] perf tools: avoid sample_reg_masks being const + weak 2019-09-27 21:43 ` [PATCH v2] " Ian Rogers 2019-09-29 21:05 ` Jiri Olsa @ 2019-10-01 0:36 ` Ian Rogers 2019-10-07 20:49 ` Nick Desaulniers ` (2 more replies) 1 sibling, 3 replies; 13+ messages in thread From: Ian Rogers @ 2019-10-01 0:36 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mao Han, Kan Liang, Andi Kleen, Alexey Budankov, linux-kernel, linux-riscv, clang-built-linux Cc: Stephane Eranian, Ian Rogers Being const + weak breaks with some compilers that constant-propagate from the weak symbol. This behavior is outside of the specification, but in LLVM is chosen to match GCC's behavior. LLVM's implementation was set in this patch: https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 A const + weak symbol is set to be weak_odr: https://llvm.org/docs/LangRef.html ODR is one definition rule, and given there is one constant definition constant-propagation is possible. It is possible to get this code to miscompile with LLVM when applying link time optimization. As compilers become more aggressive, this is likely to break in more instances. Move the definition of sample_reg_masks to the conditional part of perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the weak symbol. Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but don't declare sample_regs_masks. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/arch/arm/util/Build | 2 ++ tools/perf/arch/arm/util/perf_regs.c | 6 ++++++ tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/perf_regs.c | 6 ++++++ tools/perf/arch/csky/util/Build | 2 ++ tools/perf/arch/csky/util/perf_regs.c | 6 ++++++ tools/perf/arch/riscv/util/Build | 2 ++ tools/perf/arch/riscv/util/perf_regs.c | 6 ++++++ tools/perf/arch/s390/util/Build | 1 + tools/perf/arch/s390/util/perf_regs.c | 6 ++++++ tools/perf/util/parse-regs-options.c | 8 ++++++-- tools/perf/util/perf_regs.c | 4 ---- tools/perf/util/perf_regs.h | 4 ++-- 13 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 tools/perf/arch/arm/util/perf_regs.c create mode 100644 tools/perf/arch/arm64/util/perf_regs.c create mode 100644 tools/perf/arch/csky/util/perf_regs.c create mode 100644 tools/perf/arch/riscv/util/perf_regs.c create mode 100644 tools/perf/arch/s390/util/perf_regs.c diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build index 296f0eac5e18..37fc63708966 100644 --- a/tools/perf/arch/arm/util/Build +++ b/tools/perf/arch/arm/util/Build @@ -1,3 +1,5 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm/util/perf_regs.c b/tools/perf/arch/arm/util/perf_regs.c new file mode 100644 index 000000000000..2864e2e3776d --- /dev/null +++ b/tools/perf/arch/arm/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 3cde540d2fcf..0a7782c61209 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,4 +1,5 @@ perf-y += header.o +perf-y += perf_regs.o perf-y += sym-handling.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c new file mode 100644 index 000000000000..2864e2e3776d --- /dev/null +++ b/tools/perf/arch/arm64/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build index 1160bb2332ba..7d3050134ae0 100644 --- a/tools/perf/arch/csky/util/Build +++ b/tools/perf/arch/csky/util/Build @@ -1,2 +1,4 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/csky/util/perf_regs.c b/tools/perf/arch/csky/util/perf_regs.c new file mode 100644 index 000000000000..2864e2e3776d --- /dev/null +++ b/tools/perf/arch/csky/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build index 1160bb2332ba..7d3050134ae0 100644 --- a/tools/perf/arch/riscv/util/Build +++ b/tools/perf/arch/riscv/util/Build @@ -1,2 +1,4 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/riscv/util/perf_regs.c b/tools/perf/arch/riscv/util/perf_regs.c new file mode 100644 index 000000000000..2864e2e3776d --- /dev/null +++ b/tools/perf/arch/riscv/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build index 22797f043b84..3d9d0f4f72ca 100644 --- a/tools/perf/arch/s390/util/Build +++ b/tools/perf/arch/s390/util/Build @@ -1,5 +1,6 @@ perf-y += header.o perf-y += kvm-stat.o +perf-y += perf_regs.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/s390/util/perf_regs.c b/tools/perf/arch/s390/util/perf_regs.c new file mode 100644 index 000000000000..2864e2e3776d --- /dev/null +++ b/tools/perf/arch/s390/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c index ef46c2848808..e687497b3aac 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -13,7 +13,7 @@ static int __parse_regs(const struct option *opt, const char *str, int unset, bool intr) { uint64_t *mode = (uint64_t *)opt->value; - const struct sample_reg *r; + const struct sample_reg *r = NULL; char *s, *os = NULL, *p; int ret = -1; uint64_t mask; @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) if (!strcmp(s, "?")) { fprintf(stderr, "available registers: "); +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if (r->mask & mask) fprintf(stderr, "%s ", r->name); } +#endif fputc('\n', stderr); /* just printing available regs */ return -1; } +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if ((r->mask & mask) && !strcasecmp(s, r->name)) break; } - if (!r->name) { +#endif + if (!r || !r->name) { ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", s, intr ? "-I" : "--user-regs="); goto error; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index 2774cec1f15f..5ee47ae1509c 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -3,10 +3,6 @@ #include "perf_regs.h" #include "event.h" -const struct sample_reg __weak sample_reg_masks[] = { - SMPL_REG_END -}; - int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, char **new_op __maybe_unused) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 47fe34e5f7d5..e014c2c038f4 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,8 +15,6 @@ struct sample_reg { #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } #define SMPL_REG_END { .name = NULL } -extern const struct sample_reg sample_reg_masks[]; - enum { SDT_ARG_VALID = 0, SDT_ARG_SKIP, @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); uint64_t arch__user_reg_mask(void); #ifdef HAVE_PERF_REGS_SUPPORT +extern const struct sample_reg sample_reg_masks[]; + #include <perf_regs.h> #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3] perf tools: avoid sample_reg_masks being const + weak 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers @ 2019-10-07 20:49 ` Nick Desaulniers 2019-10-08 12:31 ` Jiri Olsa 2019-10-15 5:31 ` [tip: perf/core] perf tools: Avoid 'sample_reg_masks' " tip-bot2 for Ian Rogers 2 siblings, 0 replies; 13+ messages in thread From: Nick Desaulniers @ 2019-10-07 20:49 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mao Han, Kan Liang, Andi Kleen, Alexey Budankov, LKML, linux-riscv, clang-built-linux, Stephane Eranian On Mon, Sep 30, 2019 at 5:36 PM 'Ian Rogers' via Clang Built Linux <clang-built-linux@googlegroups.com> wrote: > > Being const + weak breaks with some compilers that constant-propagate > from the weak symbol. This behavior is outside of the specification, but > in LLVM is chosen to match GCC's behavior. > > LLVM's implementation was set in this patch: > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > A const + weak symbol is set to be weak_odr: > https://llvm.org/docs/LangRef.html > ODR is one definition rule, and given there is one constant definition > constant-propagation is possible. It is possible to get this code to > miscompile with LLVM when applying link time optimization. As compilers > become more aggressive, this is likely to break in more instances. > > Move the definition of sample_reg_masks to the conditional part of > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > weak symbol. > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but > don't declare sample_regs_masks. s/sample_regs_masks/sample_reg_masks/ (otherwise I thought for a second that my grep was broken) So powerpc and x86 set `NO_PERF_REGS := 0` AND declare `const struct sample_reg sample_reg_masks[]`. From what I can tell, it makes the below architectures match the way x86 and powerpc are structured. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/arch/arm/util/Build | 2 ++ > tools/perf/arch/arm/util/perf_regs.c | 6 ++++++ > tools/perf/arch/arm64/util/Build | 1 + > tools/perf/arch/arm64/util/perf_regs.c | 6 ++++++ > tools/perf/arch/csky/util/Build | 2 ++ > tools/perf/arch/csky/util/perf_regs.c | 6 ++++++ > tools/perf/arch/riscv/util/Build | 2 ++ > tools/perf/arch/riscv/util/perf_regs.c | 6 ++++++ > tools/perf/arch/s390/util/Build | 1 + > tools/perf/arch/s390/util/perf_regs.c | 6 ++++++ > tools/perf/util/parse-regs-options.c | 8 ++++++-- > tools/perf/util/perf_regs.c | 4 ---- > tools/perf/util/perf_regs.h | 4 ++-- > 13 files changed, 46 insertions(+), 8 deletions(-) > create mode 100644 tools/perf/arch/arm/util/perf_regs.c > create mode 100644 tools/perf/arch/arm64/util/perf_regs.c > create mode 100644 tools/perf/arch/csky/util/perf_regs.c > create mode 100644 tools/perf/arch/riscv/util/perf_regs.c > create mode 100644 tools/perf/arch/s390/util/perf_regs.c > > diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build > index 296f0eac5e18..37fc63708966 100644 > --- a/tools/perf/arch/arm/util/Build > +++ b/tools/perf/arch/arm/util/Build > @@ -1,3 +1,5 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > diff --git a/tools/perf/arch/arm/util/perf_regs.c b/tools/perf/arch/arm/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/arm/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build > index 3cde540d2fcf..0a7782c61209 100644 > --- a/tools/perf/arch/arm64/util/Build > +++ b/tools/perf/arch/arm64/util/Build > @@ -1,4 +1,5 @@ > perf-y += header.o > +perf-y += perf_regs.o > perf-y += sym-handling.o > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/arm64/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build > index 1160bb2332ba..7d3050134ae0 100644 > --- a/tools/perf/arch/csky/util/Build > +++ b/tools/perf/arch/csky/util/Build > @@ -1,2 +1,4 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/csky/util/perf_regs.c b/tools/perf/arch/csky/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/csky/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build > index 1160bb2332ba..7d3050134ae0 100644 > --- a/tools/perf/arch/riscv/util/Build > +++ b/tools/perf/arch/riscv/util/Build > @@ -1,2 +1,4 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/riscv/util/perf_regs.c b/tools/perf/arch/riscv/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/riscv/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build > index 22797f043b84..3d9d0f4f72ca 100644 > --- a/tools/perf/arch/s390/util/Build > +++ b/tools/perf/arch/s390/util/Build > @@ -1,5 +1,6 @@ > perf-y += header.o > perf-y += kvm-stat.o > +perf-y += perf_regs.o > > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/s390/util/perf_regs.c b/tools/perf/arch/s390/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/s390/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c > index ef46c2848808..e687497b3aac 100644 > --- a/tools/perf/util/parse-regs-options.c > +++ b/tools/perf/util/parse-regs-options.c > @@ -13,7 +13,7 @@ static int > __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > { > uint64_t *mode = (uint64_t *)opt->value; > - const struct sample_reg *r; > + const struct sample_reg *r = NULL; > char *s, *os = NULL, *p; > int ret = -1; > uint64_t mask; > @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > > if (!strcmp(s, "?")) { > fprintf(stderr, "available registers: "); > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if (r->mask & mask) > fprintf(stderr, "%s ", r->name); > } > +#endif > fputc('\n', stderr); > /* just printing available regs */ > return -1; > } > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if ((r->mask & mask) && !strcasecmp(s, r->name)) > break; > } > - if (!r->name) { > +#endif > + if (!r || !r->name) { > ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", > s, intr ? "-I" : "--user-regs="); > goto error; > diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c > index 2774cec1f15f..5ee47ae1509c 100644 > --- a/tools/perf/util/perf_regs.c > +++ b/tools/perf/util/perf_regs.c > @@ -3,10 +3,6 @@ > #include "perf_regs.h" > #include "event.h" > > -const struct sample_reg __weak sample_reg_masks[] = { > - SMPL_REG_END > -}; > - > int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, > char **new_op __maybe_unused) > { > diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h > index 47fe34e5f7d5..e014c2c038f4 100644 > --- a/tools/perf/util/perf_regs.h > +++ b/tools/perf/util/perf_regs.h > @@ -15,8 +15,6 @@ struct sample_reg { > #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } > #define SMPL_REG_END { .name = NULL } > > -extern const struct sample_reg sample_reg_masks[]; > - > enum { > SDT_ARG_VALID = 0, > SDT_ARG_SKIP, > @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); > uint64_t arch__user_reg_mask(void); > > #ifdef HAVE_PERF_REGS_SUPPORT > +extern const struct sample_reg sample_reg_masks[]; > + > #include <perf_regs.h> > > #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) > -- > 2.23.0.444.g18eeb5a265-goog > > -- -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] perf tools: avoid sample_reg_masks being const + weak 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers 2019-10-07 20:49 ` Nick Desaulniers @ 2019-10-08 12:31 ` Jiri Olsa 2019-10-09 23:07 ` Ian Rogers 2019-10-15 5:31 ` [tip: perf/core] perf tools: Avoid 'sample_reg_masks' " tip-bot2 for Ian Rogers 2 siblings, 1 reply; 13+ messages in thread From: Jiri Olsa @ 2019-10-08 12:31 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Namhyung Kim, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mao Han, Kan Liang, Andi Kleen, Alexey Budankov, linux-kernel, linux-riscv, clang-built-linux, Stephane Eranian On Mon, Sep 30, 2019 at 05:36:23PM -0700, Ian Rogers wrote: > Being const + weak breaks with some compilers that constant-propagate > from the weak symbol. This behavior is outside of the specification, but > in LLVM is chosen to match GCC's behavior. > > LLVM's implementation was set in this patch: > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > A const + weak symbol is set to be weak_odr: > https://llvm.org/docs/LangRef.html > ODR is one definition rule, and given there is one constant definition > constant-propagation is possible. It is possible to get this code to > miscompile with LLVM when applying link time optimization. As compilers > become more aggressive, this is likely to break in more instances. is this just aprecaution or you actualy saw some breakage? > > Move the definition of sample_reg_masks to the conditional part of > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > weak symbol. > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but > don't declare sample_regs_masks. looks good to me (again ;-)), let's see if it passes Arnaldo's farm thanks, jirka > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/arch/arm/util/Build | 2 ++ > tools/perf/arch/arm/util/perf_regs.c | 6 ++++++ > tools/perf/arch/arm64/util/Build | 1 + > tools/perf/arch/arm64/util/perf_regs.c | 6 ++++++ > tools/perf/arch/csky/util/Build | 2 ++ > tools/perf/arch/csky/util/perf_regs.c | 6 ++++++ > tools/perf/arch/riscv/util/Build | 2 ++ > tools/perf/arch/riscv/util/perf_regs.c | 6 ++++++ > tools/perf/arch/s390/util/Build | 1 + > tools/perf/arch/s390/util/perf_regs.c | 6 ++++++ > tools/perf/util/parse-regs-options.c | 8 ++++++-- > tools/perf/util/perf_regs.c | 4 ---- > tools/perf/util/perf_regs.h | 4 ++-- > 13 files changed, 46 insertions(+), 8 deletions(-) > create mode 100644 tools/perf/arch/arm/util/perf_regs.c > create mode 100644 tools/perf/arch/arm64/util/perf_regs.c > create mode 100644 tools/perf/arch/csky/util/perf_regs.c > create mode 100644 tools/perf/arch/riscv/util/perf_regs.c > create mode 100644 tools/perf/arch/s390/util/perf_regs.c > > diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build > index 296f0eac5e18..37fc63708966 100644 > --- a/tools/perf/arch/arm/util/Build > +++ b/tools/perf/arch/arm/util/Build > @@ -1,3 +1,5 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > diff --git a/tools/perf/arch/arm/util/perf_regs.c b/tools/perf/arch/arm/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/arm/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build > index 3cde540d2fcf..0a7782c61209 100644 > --- a/tools/perf/arch/arm64/util/Build > +++ b/tools/perf/arch/arm64/util/Build > @@ -1,4 +1,5 @@ > perf-y += header.o > +perf-y += perf_regs.o > perf-y += sym-handling.o > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/arm64/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build > index 1160bb2332ba..7d3050134ae0 100644 > --- a/tools/perf/arch/csky/util/Build > +++ b/tools/perf/arch/csky/util/Build > @@ -1,2 +1,4 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/csky/util/perf_regs.c b/tools/perf/arch/csky/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/csky/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build > index 1160bb2332ba..7d3050134ae0 100644 > --- a/tools/perf/arch/riscv/util/Build > +++ b/tools/perf/arch/riscv/util/Build > @@ -1,2 +1,4 @@ > +perf-y += perf_regs.o > + > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/riscv/util/perf_regs.c b/tools/perf/arch/riscv/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/riscv/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build > index 22797f043b84..3d9d0f4f72ca 100644 > --- a/tools/perf/arch/s390/util/Build > +++ b/tools/perf/arch/s390/util/Build > @@ -1,5 +1,6 @@ > perf-y += header.o > perf-y += kvm-stat.o > +perf-y += perf_regs.o > > perf-$(CONFIG_DWARF) += dwarf-regs.o > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > diff --git a/tools/perf/arch/s390/util/perf_regs.c b/tools/perf/arch/s390/util/perf_regs.c > new file mode 100644 > index 000000000000..2864e2e3776d > --- /dev/null > +++ b/tools/perf/arch/s390/util/perf_regs.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "../../util/perf_regs.h" > + > +const struct sample_reg sample_reg_masks[] = { > + SMPL_REG_END > +}; > diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c > index ef46c2848808..e687497b3aac 100644 > --- a/tools/perf/util/parse-regs-options.c > +++ b/tools/perf/util/parse-regs-options.c > @@ -13,7 +13,7 @@ static int > __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > { > uint64_t *mode = (uint64_t *)opt->value; > - const struct sample_reg *r; > + const struct sample_reg *r = NULL; > char *s, *os = NULL, *p; > int ret = -1; > uint64_t mask; > @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > > if (!strcmp(s, "?")) { > fprintf(stderr, "available registers: "); > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if (r->mask & mask) > fprintf(stderr, "%s ", r->name); > } > +#endif > fputc('\n', stderr); > /* just printing available regs */ > return -1; > } > +#ifdef HAVE_PERF_REGS_SUPPORT > for (r = sample_reg_masks; r->name; r++) { > if ((r->mask & mask) && !strcasecmp(s, r->name)) > break; > } > - if (!r->name) { > +#endif > + if (!r || !r->name) { > ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", > s, intr ? "-I" : "--user-regs="); > goto error; > diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c > index 2774cec1f15f..5ee47ae1509c 100644 > --- a/tools/perf/util/perf_regs.c > +++ b/tools/perf/util/perf_regs.c > @@ -3,10 +3,6 @@ > #include "perf_regs.h" > #include "event.h" > > -const struct sample_reg __weak sample_reg_masks[] = { > - SMPL_REG_END > -}; > - > int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, > char **new_op __maybe_unused) > { > diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h > index 47fe34e5f7d5..e014c2c038f4 100644 > --- a/tools/perf/util/perf_regs.h > +++ b/tools/perf/util/perf_regs.h > @@ -15,8 +15,6 @@ struct sample_reg { > #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } > #define SMPL_REG_END { .name = NULL } > > -extern const struct sample_reg sample_reg_masks[]; > - > enum { > SDT_ARG_VALID = 0, > SDT_ARG_SKIP, > @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); > uint64_t arch__user_reg_mask(void); > > #ifdef HAVE_PERF_REGS_SUPPORT > +extern const struct sample_reg sample_reg_masks[]; > + > #include <perf_regs.h> > > #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) > -- > 2.23.0.444.g18eeb5a265-goog > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] perf tools: avoid sample_reg_masks being const + weak 2019-10-08 12:31 ` Jiri Olsa @ 2019-10-09 23:07 ` Ian Rogers 2019-10-10 12:29 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 13+ messages in thread From: Ian Rogers @ 2019-10-09 23:07 UTC (permalink / raw) To: Jiri Olsa Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin, Namhyung Kim, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mao Han, Kan Liang, Andi Kleen, Alexey Budankov, LKML, linux-riscv, clang-built-linux, Stephane Eranian On Tue, Oct 8, 2019 at 5:31 AM Jiri Olsa <jolsa@redhat.com> wrote: > > On Mon, Sep 30, 2019 at 05:36:23PM -0700, Ian Rogers wrote: > > Being const + weak breaks with some compilers that constant-propagate > > from the weak symbol. This behavior is outside of the specification, but > > in LLVM is chosen to match GCC's behavior. > > > > LLVM's implementation was set in this patch: > > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > > A const + weak symbol is set to be weak_odr: > > https://llvm.org/docs/LangRef.html > > ODR is one definition rule, and given there is one constant definition > > constant-propagation is possible. It is possible to get this code to > > miscompile with LLVM when applying link time optimization. As compilers > > become more aggressive, this is likely to break in more instances. > > is this just aprecaution or you actualy saw some breakage? We saw a breakage with clang with thinlto enabled for linking. Our compiler team had recently seen, and were surprised by, a similar issue and were able to dig out the weak ODR issue. Thanks, Ian > > Move the definition of sample_reg_masks to the conditional part of > > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > > weak symbol. > > > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > > In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but > > don't declare sample_regs_masks. > > looks good to me (again ;-)), let's see if it passes Arnaldo's farm > > thanks, > jirka > > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > --- > > tools/perf/arch/arm/util/Build | 2 ++ > > tools/perf/arch/arm/util/perf_regs.c | 6 ++++++ > > tools/perf/arch/arm64/util/Build | 1 + > > tools/perf/arch/arm64/util/perf_regs.c | 6 ++++++ > > tools/perf/arch/csky/util/Build | 2 ++ > > tools/perf/arch/csky/util/perf_regs.c | 6 ++++++ > > tools/perf/arch/riscv/util/Build | 2 ++ > > tools/perf/arch/riscv/util/perf_regs.c | 6 ++++++ > > tools/perf/arch/s390/util/Build | 1 + > > tools/perf/arch/s390/util/perf_regs.c | 6 ++++++ > > tools/perf/util/parse-regs-options.c | 8 ++++++-- > > tools/perf/util/perf_regs.c | 4 ---- > > tools/perf/util/perf_regs.h | 4 ++-- > > 13 files changed, 46 insertions(+), 8 deletions(-) > > create mode 100644 tools/perf/arch/arm/util/perf_regs.c > > create mode 100644 tools/perf/arch/arm64/util/perf_regs.c > > create mode 100644 tools/perf/arch/csky/util/perf_regs.c > > create mode 100644 tools/perf/arch/riscv/util/perf_regs.c > > create mode 100644 tools/perf/arch/s390/util/perf_regs.c > > > > diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build > > index 296f0eac5e18..37fc63708966 100644 > > --- a/tools/perf/arch/arm/util/Build > > +++ b/tools/perf/arch/arm/util/Build > > @@ -1,3 +1,5 @@ > > +perf-y += perf_regs.o > > + > > perf-$(CONFIG_DWARF) += dwarf-regs.o > > > > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > > diff --git a/tools/perf/arch/arm/util/perf_regs.c b/tools/perf/arch/arm/util/perf_regs.c > > new file mode 100644 > > index 000000000000..2864e2e3776d > > --- /dev/null > > +++ b/tools/perf/arch/arm/util/perf_regs.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "../../util/perf_regs.h" > > + > > +const struct sample_reg sample_reg_masks[] = { > > + SMPL_REG_END > > +}; > > diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build > > index 3cde540d2fcf..0a7782c61209 100644 > > --- a/tools/perf/arch/arm64/util/Build > > +++ b/tools/perf/arch/arm64/util/Build > > @@ -1,4 +1,5 @@ > > perf-y += header.o > > +perf-y += perf_regs.o > > perf-y += sym-handling.o > > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o > > diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c > > new file mode 100644 > > index 000000000000..2864e2e3776d > > --- /dev/null > > +++ b/tools/perf/arch/arm64/util/perf_regs.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "../../util/perf_regs.h" > > + > > +const struct sample_reg sample_reg_masks[] = { > > + SMPL_REG_END > > +}; > > diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build > > index 1160bb2332ba..7d3050134ae0 100644 > > --- a/tools/perf/arch/csky/util/Build > > +++ b/tools/perf/arch/csky/util/Build > > @@ -1,2 +1,4 @@ > > +perf-y += perf_regs.o > > + > > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > > diff --git a/tools/perf/arch/csky/util/perf_regs.c b/tools/perf/arch/csky/util/perf_regs.c > > new file mode 100644 > > index 000000000000..2864e2e3776d > > --- /dev/null > > +++ b/tools/perf/arch/csky/util/perf_regs.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "../../util/perf_regs.h" > > + > > +const struct sample_reg sample_reg_masks[] = { > > + SMPL_REG_END > > +}; > > diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build > > index 1160bb2332ba..7d3050134ae0 100644 > > --- a/tools/perf/arch/riscv/util/Build > > +++ b/tools/perf/arch/riscv/util/Build > > @@ -1,2 +1,4 @@ > > +perf-y += perf_regs.o > > + > > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > > diff --git a/tools/perf/arch/riscv/util/perf_regs.c b/tools/perf/arch/riscv/util/perf_regs.c > > new file mode 100644 > > index 000000000000..2864e2e3776d > > --- /dev/null > > +++ b/tools/perf/arch/riscv/util/perf_regs.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "../../util/perf_regs.h" > > + > > +const struct sample_reg sample_reg_masks[] = { > > + SMPL_REG_END > > +}; > > diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build > > index 22797f043b84..3d9d0f4f72ca 100644 > > --- a/tools/perf/arch/s390/util/Build > > +++ b/tools/perf/arch/s390/util/Build > > @@ -1,5 +1,6 @@ > > perf-y += header.o > > perf-y += kvm-stat.o > > +perf-y += perf_regs.o > > > > perf-$(CONFIG_DWARF) += dwarf-regs.o > > perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o > > diff --git a/tools/perf/arch/s390/util/perf_regs.c b/tools/perf/arch/s390/util/perf_regs.c > > new file mode 100644 > > index 000000000000..2864e2e3776d > > --- /dev/null > > +++ b/tools/perf/arch/s390/util/perf_regs.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "../../util/perf_regs.h" > > + > > +const struct sample_reg sample_reg_masks[] = { > > + SMPL_REG_END > > +}; > > diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c > > index ef46c2848808..e687497b3aac 100644 > > --- a/tools/perf/util/parse-regs-options.c > > +++ b/tools/perf/util/parse-regs-options.c > > @@ -13,7 +13,7 @@ static int > > __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > > { > > uint64_t *mode = (uint64_t *)opt->value; > > - const struct sample_reg *r; > > + const struct sample_reg *r = NULL; > > char *s, *os = NULL, *p; > > int ret = -1; > > uint64_t mask; > > @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) > > > > if (!strcmp(s, "?")) { > > fprintf(stderr, "available registers: "); > > +#ifdef HAVE_PERF_REGS_SUPPORT > > for (r = sample_reg_masks; r->name; r++) { > > if (r->mask & mask) > > fprintf(stderr, "%s ", r->name); > > } > > +#endif > > fputc('\n', stderr); > > /* just printing available regs */ > > return -1; > > } > > +#ifdef HAVE_PERF_REGS_SUPPORT > > for (r = sample_reg_masks; r->name; r++) { > > if ((r->mask & mask) && !strcasecmp(s, r->name)) > > break; > > } > > - if (!r->name) { > > +#endif > > + if (!r || !r->name) { > > ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", > > s, intr ? "-I" : "--user-regs="); > > goto error; > > diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c > > index 2774cec1f15f..5ee47ae1509c 100644 > > --- a/tools/perf/util/perf_regs.c > > +++ b/tools/perf/util/perf_regs.c > > @@ -3,10 +3,6 @@ > > #include "perf_regs.h" > > #include "event.h" > > > > -const struct sample_reg __weak sample_reg_masks[] = { > > - SMPL_REG_END > > -}; > > - > > int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, > > char **new_op __maybe_unused) > > { > > diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h > > index 47fe34e5f7d5..e014c2c038f4 100644 > > --- a/tools/perf/util/perf_regs.h > > +++ b/tools/perf/util/perf_regs.h > > @@ -15,8 +15,6 @@ struct sample_reg { > > #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } > > #define SMPL_REG_END { .name = NULL } > > > > -extern const struct sample_reg sample_reg_masks[]; > > - > > enum { > > SDT_ARG_VALID = 0, > > SDT_ARG_SKIP, > > @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); > > uint64_t arch__user_reg_mask(void); > > > > #ifdef HAVE_PERF_REGS_SUPPORT > > +extern const struct sample_reg sample_reg_masks[]; > > + > > #include <perf_regs.h> > > > > #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) > > -- > > 2.23.0.444.g18eeb5a265-goog > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] perf tools: avoid sample_reg_masks being const + weak 2019-10-09 23:07 ` Ian Rogers @ 2019-10-10 12:29 ` Arnaldo Carvalho de Melo 0 siblings, 0 replies; 13+ messages in thread From: Arnaldo Carvalho de Melo @ 2019-10-10 12:29 UTC (permalink / raw) To: Ian Rogers Cc: Jiri Olsa, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Namhyung Kim, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mao Han, Kan Liang, Andi Kleen, Alexey Budankov, LKML, linux-riscv, clang-built-linux, Stephane Eranian Em Wed, Oct 09, 2019 at 04:07:37PM -0700, Ian Rogers escreveu: > On Tue, Oct 8, 2019 at 5:31 AM Jiri Olsa <jolsa@redhat.com> wrote: > > On Mon, Sep 30, 2019 at 05:36:23PM -0700, Ian Rogers wrote: > > > Being const + weak breaks with some compilers that constant-propagate > > > from the weak symbol. This behavior is outside of the specification, but > > > in LLVM is chosen to match GCC's behavior. > > > > > > LLVM's implementation was set in this patch: > > > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 > > > A const + weak symbol is set to be weak_odr: > > > https://llvm.org/docs/LangRef.html > > > ODR is one definition rule, and given there is one constant definition > > > constant-propagation is possible. It is possible to get this code to > > > miscompile with LLVM when applying link time optimization. As compilers > > > become more aggressive, this is likely to break in more instances. > > is this just aprecaution or you actualy saw some breakage? > We saw a breakage with clang with thinlto enabled for linking. Our > compiler team had recently seen, and were surprised by, a similar > issue and were able to dig out the weak ODR issue. This is useful info, I'll add it to the commit log message. > > > Move the definition of sample_reg_masks to the conditional part of > > > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the > > > weak symbol. > > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. > > > In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but > > > don't declare sample_regs_masks. > > looks good to me (again ;-)), let's see if it passes Arnaldo's farm It passed a few of the usual places where things like this break, I'll submit it to a full set of build environments soon, together with what is sitting in acme/perf/core. Thanks, - Arnaldo ^ permalink raw reply [flat|nested] 13+ messages in thread
* [tip: perf/core] perf tools: Avoid 'sample_reg_masks' being const + weak 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers 2019-10-07 20:49 ` Nick Desaulniers 2019-10-08 12:31 ` Jiri Olsa @ 2019-10-15 5:31 ` tip-bot2 for Ian Rogers 2 siblings, 0 replies; 13+ messages in thread From: tip-bot2 for Ian Rogers @ 2019-10-15 5:31 UTC (permalink / raw) To: linux-tip-commits Cc: Ian Rogers, Nick Desaulniers, Jiri Olsa, Albert Ou, Alexander Shishkin, Alexey Budankov, Andi Kleen, clang-built-linux, Guo Ren, Kan Liang, linux-riscv, Mao Han, Mark Rutland, Namhyung Kim, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra, Stephane Eranian, Arnaldo Carvalho de Melo, Ingo Molnar, Borislav Petkov, linux-kernel The following commit has been merged into the perf/core branch of tip: Commit-ID: 42466b9f29b415c254dc4c2f4618e2a96951a406 Gitweb: https://git.kernel.org/tip/42466b9f29b415c254dc4c2f4618e2a96951a406 Author: Ian Rogers <irogers@google.com> AuthorDate: Mon, 30 Sep 2019 17:36:23 -07:00 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitterDate: Thu, 10 Oct 2019 09:29:33 -03:00 perf tools: Avoid 'sample_reg_masks' being const + weak Being const + weak breaks with some compilers that constant-propagate from the weak symbol. This behavior is outside of the specification, but in LLVM is chosen to match GCC's behavior. LLVM's implementation was set in this patch: https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646 A const + weak symbol is set to be weak_odr: https://llvm.org/docs/LangRef.html ODR is one definition rule, and given there is one constant definition constant-propagation is possible. It is possible to get this code to miscompile with LLVM when applying link time optimization. As compilers become more aggressive, this is likely to break in more instances. Move the definition of sample_reg_masks to the conditional part of perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the weak symbol. Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1. In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but don't declare sample_regs_masks. Further notes: Jiri asked: "Is this just a precaution or you actualy saw some breakage?" Ian answered: "We saw a breakage with clang with thinlto enabled for linking. Our compiler team had recently seen, and were surprised by, a similar issue and were able to dig out the weak ODR issue." Signed-off-by: Ian Rogers <irogers@google.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: clang-built-linux@googlegroups.com Cc: Guo Ren <guoren@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: linux-riscv@lists.infradead.org Cc: Mao Han <han_mao@c-sky.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lore.kernel.org/lkml/20191001003623.255186-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/arch/arm/util/Build | 2 ++ tools/perf/arch/arm/util/perf_regs.c | 6 ++++++ tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/perf_regs.c | 6 ++++++ tools/perf/arch/csky/util/Build | 2 ++ tools/perf/arch/csky/util/perf_regs.c | 6 ++++++ tools/perf/arch/riscv/util/Build | 2 ++ tools/perf/arch/riscv/util/perf_regs.c | 6 ++++++ tools/perf/arch/s390/util/Build | 1 + tools/perf/arch/s390/util/perf_regs.c | 6 ++++++ tools/perf/util/parse-regs-options.c | 8 ++++++-- tools/perf/util/perf_regs.c | 4 ---- tools/perf/util/perf_regs.h | 4 ++-- 13 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 tools/perf/arch/arm/util/perf_regs.c create mode 100644 tools/perf/arch/arm64/util/perf_regs.c create mode 100644 tools/perf/arch/csky/util/perf_regs.c create mode 100644 tools/perf/arch/riscv/util/perf_regs.c create mode 100644 tools/perf/arch/s390/util/perf_regs.c diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build index 296f0ea..37fc637 100644 --- a/tools/perf/arch/arm/util/Build +++ b/tools/perf/arch/arm/util/Build @@ -1,3 +1,5 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm/util/perf_regs.c b/tools/perf/arch/arm/util/perf_regs.c new file mode 100644 index 0000000..2864e2e --- /dev/null +++ b/tools/perf/arch/arm/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 3cde540..0a7782c 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,4 +1,5 @@ perf-y += header.o +perf-y += perf_regs.o perf-y += sym-handling.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c new file mode 100644 index 0000000..2864e2e --- /dev/null +++ b/tools/perf/arch/arm64/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build index 1160bb2..7d30501 100644 --- a/tools/perf/arch/csky/util/Build +++ b/tools/perf/arch/csky/util/Build @@ -1,2 +1,4 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/csky/util/perf_regs.c b/tools/perf/arch/csky/util/perf_regs.c new file mode 100644 index 0000000..2864e2e --- /dev/null +++ b/tools/perf/arch/csky/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build index 1160bb2..7d30501 100644 --- a/tools/perf/arch/riscv/util/Build +++ b/tools/perf/arch/riscv/util/Build @@ -1,2 +1,4 @@ +perf-y += perf_regs.o + perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/riscv/util/perf_regs.c b/tools/perf/arch/riscv/util/perf_regs.c new file mode 100644 index 0000000..2864e2e --- /dev/null +++ b/tools/perf/arch/riscv/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/arch/s390/util/Build b/tools/perf/arch/s390/util/Build index 22797f0..3d9d0f4 100644 --- a/tools/perf/arch/s390/util/Build +++ b/tools/perf/arch/s390/util/Build @@ -1,5 +1,6 @@ perf-y += header.o perf-y += kvm-stat.o +perf-y += perf_regs.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/s390/util/perf_regs.c b/tools/perf/arch/s390/util/perf_regs.c new file mode 100644 index 0000000..2864e2e --- /dev/null +++ b/tools/perf/arch/s390/util/perf_regs.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "../../util/perf_regs.h" + +const struct sample_reg sample_reg_masks[] = { + SMPL_REG_END +}; diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c index ef46c28..e687497 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -13,7 +13,7 @@ static int __parse_regs(const struct option *opt, const char *str, int unset, bool intr) { uint64_t *mode = (uint64_t *)opt->value; - const struct sample_reg *r; + const struct sample_reg *r = NULL; char *s, *os = NULL, *p; int ret = -1; uint64_t mask; @@ -46,19 +46,23 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) if (!strcmp(s, "?")) { fprintf(stderr, "available registers: "); +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if (r->mask & mask) fprintf(stderr, "%s ", r->name); } +#endif fputc('\n', stderr); /* just printing available regs */ return -1; } +#ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { if ((r->mask & mask) && !strcasecmp(s, r->name)) break; } - if (!r->name) { +#endif + if (!r || !r->name) { ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", s, intr ? "-I" : "--user-regs="); goto error; diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index 2774cec..5ee47ae 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -3,10 +3,6 @@ #include "perf_regs.h" #include "event.h" -const struct sample_reg __weak sample_reg_masks[] = { - SMPL_REG_END -}; - int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, char **new_op __maybe_unused) { diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 47fe34e..e014c2c 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h @@ -15,8 +15,6 @@ struct sample_reg { #define SMPL_REG2(n, b) { .name = #n, .mask = 3ULL << (b) } #define SMPL_REG_END { .name = NULL } -extern const struct sample_reg sample_reg_masks[]; - enum { SDT_ARG_VALID = 0, SDT_ARG_SKIP, @@ -27,6 +25,8 @@ uint64_t arch__intr_reg_mask(void); uint64_t arch__user_reg_mask(void); #ifdef HAVE_PERF_REGS_SUPPORT +extern const struct sample_reg sample_reg_masks[]; + #include <perf_regs.h> #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP)) ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-10-15 5:33 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-09-27 21:10 [PATCH] perf tools: avoid sample_reg_masks being const + weak Ian Rogers 2019-09-27 21:43 ` [PATCH v2] " Ian Rogers 2019-09-29 21:05 ` Jiri Olsa 2019-09-30 10:39 ` Arnaldo Carvalho de Melo 2019-09-30 12:23 ` Arnaldo Carvalho de Melo 2019-09-30 12:42 ` Jiri Olsa 2019-10-01 0:36 ` Ian Rogers 2019-10-01 0:36 ` [PATCH v3] " Ian Rogers 2019-10-07 20:49 ` Nick Desaulniers 2019-10-08 12:31 ` Jiri Olsa 2019-10-09 23:07 ` Ian Rogers 2019-10-10 12:29 ` Arnaldo Carvalho de Melo 2019-10-15 5:31 ` [tip: perf/core] perf tools: Avoid 'sample_reg_masks' " tip-bot2 for Ian Rogers
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox