Skip to contentSkip to conversation

perf tool: build related fixes

PATCH Applied Ian Rogers 4 participants 17 messages Mar 6, 2020 – May 15, 2020

Subsystems (2)
lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

cover perf tool: build related fixes

These patches better enable a build of perf when not using the regular Makefiles, in my case using bazel.

Ian Rogers (3):
tools: fix off-by 1 relative directory includes
libperf: avoid redefining _GNU_SOURCE in test
tools/perf: build fixes for arch_errno_names.sh

 tools/include/uapi/asm/errno.h              | 14 +++++-----
 tools/lib/perf/tests/test-evlist.c          |  2 ++
 tools/perf/arch/arm64/util/arm-spe.c        | 20 +++++++-------
 tools/perf/arch/arm64/util/perf_regs.c      |  2 +-
 tools/perf/arch/powerpc/util/perf_regs.c    |  4 +--
 tools/perf/arch/x86/util/auxtrace.c         | 14 +++++-----
 tools/perf/arch/x86/util/event.c            | 12 ++++-----
 tools/perf/arch/x86/util/header.c           |  4 +--
 tools/perf/arch/x86/util/intel-bts.c        | 24 ++++++++---------
 tools/perf/arch/x86/util/intel-pt.c         | 30 ++++++++++-----------
 tools/perf/arch/x86/util/machine.c          |  6 ++---
 tools/perf/arch/x86/util/perf_regs.c        |  8 +++---
 tools/perf/arch/x86/util/pmu.c              |  6 ++---
 tools/perf/trace/beauty/arch_errno_names.sh |  4 +--
 14 files changed, 76 insertions(+), 74 deletions(-)
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
author reviewer
#1 lore raw

PATCH 1/3 tools: fix off-by 1 relative directory includes

This is currently working due to extra include paths in the build.

---
 tools/include/uapi/asm/errno.h           | 14 +++++------
 tools/perf/arch/arm64/util/arm-spe.c     | 20 ++++++++--------
 tools/perf/arch/arm64/util/perf_regs.c   |  2 +-
 tools/perf/arch/powerpc/util/perf_regs.c |  4 ++--
 tools/perf/arch/x86/util/auxtrace.c      | 14 +++++------
 tools/perf/arch/x86/util/event.c         | 12 +++++-----
 tools/perf/arch/x86/util/header.c        |  4 ++--
 tools/perf/arch/x86/util/intel-bts.c     | 24 +++++++++----------
 tools/perf/arch/x86/util/intel-pt.c      | 30 ++++++++++++------------
 tools/perf/arch/x86/util/machine.c       |  6 ++---
 tools/perf/arch/x86/util/perf_regs.c     |  8 +++----
 tools/perf/arch/x86/util/pmu.c           |  6 ++---
 12 files changed, 72 insertions(+), 72 deletions(-)
tools/include/uapi/asm/errno.h +7 -7
index ce3c5945a1c4..637189ec1ab9 100644
@@ -1,18 +1,18 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #if defined(__i386__) || defined(__x86_64__)
-#include "../../arch/x86/include/uapi/asm/errno.h"
+#include "../../../arch/x86/include/uapi/asm/errno.h"
 #elif defined(__powerpc__)
-#include "../../arch/powerpc/include/uapi/asm/errno.h"
+#include "../../../arch/powerpc/include/uapi/asm/errno.h"
 #elif defined(__sparc__)
-#include "../../arch/sparc/include/uapi/asm/errno.h"
+#include "../../../arch/sparc/include/uapi/asm/errno.h"
 #elif defined(__alpha__)
-#include "../../arch/alpha/include/uapi/asm/errno.h"
+#include "../../../arch/alpha/include/uapi/asm/errno.h"
 #elif defined(__mips__)
-#include "../../arch/mips/include/uapi/asm/errno.h"
+#include "../../../arch/mips/include/uapi/asm/errno.h"
 #elif defined(__ia64__)
-#include "../../arch/ia64/include/uapi/asm/errno.h"
+#include "../../../arch/ia64/include/uapi/asm/errno.h"
 #elif defined(__xtensa__)
-#include "../../arch/xtensa/include/uapi/asm/errno.h"
+#include "../../../arch/xtensa/include/uapi/asm/errno.h"
 #else
 #include <asm-generic/errno.h>
 #endif
tools/perf/arch/arm64/util/arm-spe.c +10 -10
index 8d6821d9c3f6..27653be24447 100644
@@ -11,17 +11,17 @@
 #include <linux/zalloc.h>
 #include <time.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/session.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/session.h"
 #include <internal/lib.h> // page_size
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/arm-spe.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/arm-spe.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/arm64/util/perf_regs.c +1 -1
index 2864e2e3776d..2833e101a7c6 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "../../util/perf_regs.h"
+#include "../../../util/perf_regs.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG_END
tools/perf/arch/powerpc/util/perf_regs.c +2 -2
index e9c436eeffc9..0a5242900248 100644
@@ -4,8 +4,8 @@
 #include <regex.h>
 #include <linux/zalloc.h>
 
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
 
 #include <linux/kernel.h>
 
tools/perf/arch/x86/util/auxtrace.c +7 -7
index 7abc9fd4cbec..3da506e13f49 100644
@@ -7,13 +7,13 @@
 #include <errno.h>
 #include <stdbool.h>
 
-#include "../../util/header.h"
-#include "../../util/debug.h"
-#include "../../util/pmu.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/evlist.h"
+#include "../../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/pmu.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/evlist.h"
 
 static
 struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
tools/perf/arch/x86/util/event.c +6 -6
index ac45015cc6ba..047dc00eafa6 100644
@@ -3,12 +3,12 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
-#include "../../util/event.h"
-#include "../../util/synthetic-events.h"
-#include "../../util/machine.h"
-#include "../../util/tool.h"
-#include "../../util/map.h"
-#include "../../util/debug.h"
+#include "../../../util/event.h"
+#include "../../../util/synthetic-events.h"
+#include "../../../util/machine.h"
+#include "../../../util/tool.h"
+#include "../../../util/map.h"
+#include "../../../util/debug.h"
 
 #if defined(__x86_64__)
 
tools/perf/arch/x86/util/header.c +2 -2
index aa6deb463bf3..578c8c568ffd 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 #include <regex.h>
 
-#include "../../util/debug.h"
-#include "../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/header.h"
 
 static inline void
 cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
tools/perf/arch/x86/util/intel-bts.c +12 -12
index 26cee1052179..09f93800bffd 100644
@@ -11,18 +11,18 @@
 #include <linux/log2.h>
 #include <linux/zalloc.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/mmap.h"
-#include "../../util/session.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/record.h"
-#include "../../util/tsc.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-bts.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/record.h"
+#include "../../../util/tsc.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-bts.h"
 #include <internal/lib.h> // page_size
 
 #define KiB(x) ((x) * 1024)
tools/perf/arch/x86/util/intel-pt.c +15 -15
index 7eea4fd7ce58..1643aed8c4c8 100644
@@ -13,23 +13,23 @@
 #include <linux/zalloc.h>
 #include <cpuid.h>
 
-#include "../../util/session.h"
-#include "../../util/event.h"
-#include "../../util/evlist.h"
-#include "../../util/evsel.h"
-#include "../../util/evsel_config.h"
-#include "../../util/cpumap.h"
-#include "../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/event.h"
+#include "../../../util/evlist.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evsel_config.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/mmap.h"
 #include <subcmd/parse-options.h>
-#include "../../util/parse-events.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/target.h"
-#include "../../util/tsc.h"
+#include "../../../util/parse-events.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/target.h"
+#include "../../../util/tsc.h"
 #include <internal/lib.h> // page_size
-#include "../../util/intel-pt.h"
+#include "../../../util/intel-pt.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/x86/util/machine.c +3 -3
index e17e080e76f4..31679c35d493 100644
@@ -5,9 +5,9 @@
 #include <stdlib.h>
 
 #include <internal/lib.h> // page_size
-#include "../../util/machine.h"
-#include "../../util/map.h"
-#include "../../util/symbol.h"
+#include "../../../util/machine.h"
+#include "../../../util/map.h"
+#include "../../../util/symbol.h"
 #include <linux/ctype.h>
 
 #include <symbol/kallsyms.h>
tools/perf/arch/x86/util/perf_regs.c +4 -4
index c218b83e063b..fca81b39b09f 100644
@@ -5,10 +5,10 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 
-#include "../../perf-sys.h"
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
-#include "../../util/event.h"
+#include "../../../perf-sys.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
+#include "../../../util/event.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG(AX, PERF_REG_X86_AX),
tools/perf/arch/x86/util/pmu.c +3 -3
index e33ef5bc31c5..d48d608517fd 100644
@@ -4,9 +4,9 @@
 #include <linux/stddef.h>
 #include <linux/perf_event.h>
 
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/pmu.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/pmu.h"
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
 {
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
#2 lore raw

Re: [PATCH 1/3] tools: fix off-by 1 relative directory includes

Quoted 1 line · Ian Rogers

This is currently working due to extra include paths in the build.

if you're fixing this, why not remove that extra include path then?

jirka

author reviewer
#3 lore raw

Re: [PATCH 1/3] tools: fix off-by 1 relative directory includes

Quoted 5 lines · Jiri Olsa
Quoted 1 line · Ian Rogers

This is currently working due to extra include paths in the build.

if you're fixing this, why not remove that extra include path then?

TL;DR it is complicated, but the include paths are all currently necessary I believe and doing this way is necessary due to how header files may be copied out of the kernel.

The current build uses multiple -Is to ensure the correct version of a file is included, for example there are 27 files called bitops.h and 29 called bitsperlong.h. In
Google we're using libraries and bazel build files:
https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library
and there's no way to say if you depend on this library then you need this include path. We've tried to make perf this way but having tied ourselves in knots we decided instead to emulate the include path behaviour by rewriting includes when we import code using copybara:
https://github.com/google/copybara
We are able when doing this to prioritize the include paths we rewrite so that a local directory version of a header is preferred over say one in tools/lib/perf and perhaps tools/perf. Having full include paths isn't really an option upstream as the same header file may be copied into a libc project that has a different directory layout. As we have absolute include paths at the time of building we need relative include paths to be correct. Upstream -Is allow the build to find the file but it is a bit of a quirk of the C preprocessor, so fixing these off-by 1s feels like value add both for us and upstream. For upstream to do anything different I think is going to be a significant rewrite of how the Makefile build works and I'm not sure what the result would look like.

Thanks!
Ian

Quoted 2 lines

jirka

#4 lore raw

Re: [PATCH 1/3] tools: fix off-by 1 relative directory includes

Em Fri, Mar 06, 2020 at 08:47:51AM -0800, Ian Rogers escreveu:

Quoted 10 lines · Jiri Olsa
Quoted 5 lines · Ian Rogers
Quoted 1 line

This is currently working due to extra include paths in the build.

if you're fixing this, why not remove that extra include path then?

TL;DR it is complicated, but the include paths are all currently necessary I believe and doing this way is necessary due to how header files may be copied out of the kernel.

TL;DR response: yeah, lets make incremental fixes to this, like applying this patch :)

- Arnaldo

Quoted 28 lines

The current build uses multiple -Is to ensure the correct version of a file is included, for example there are 27 files called bitops.h and 29 called bitsperlong.h. In
Google we're using libraries and bazel build files:
https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library
and there's no way to say if you depend on this library then you need this include path. We've tried to make perf this way but having tied ourselves in knots we decided instead to emulate the include path behaviour by rewriting includes when we import code using copybara:
https://github.com/google/copybara
We are able when doing this to prioritize the include paths we rewrite so that a local directory version of a header is preferred over say one in tools/lib/perf and perhaps tools/perf. Having full include paths isn't really an option upstream as the same header file may be copied into a libc project that has a different directory layout. As we have absolute include paths at the time of building we need relative include paths to be correct. Upstream -Is allow the build to find the file but it is a bit of a quirk of the C preprocessor, so fixing these off-by 1s feels like value add both for us and upstream. For upstream to do anything different I think is going to be a significant rewrite of how the Makefile build works and I'm not sure what the result would look like.

Thanks!
Ian

Quoted 2 lines

jirka

Signature · 1 line
- Arnaldo
#5 lore raw

Re: [PATCH 1/3] tools: fix off-by 1 relative directory includes

In reply to Ian Rogers

Em Thu, Mar 05, 2020 at 11:11:08PM -0800, Ian Rogers escreveu:

Quoted 1 line

This is currently working due to extra include paths in the build.

Thanks, applied and added this to the cset commit log:

    Committer testing:
    
      $ cd tools/include/uapi/asm/
    
    Before this patch:
    
      $ ls -la ../../arch/x86/include/uapi/asm/errno.h
      ls: cannot access '../../arch/x86/include/uapi/asm/errno.h': No such file or directory
      $
    
    After this patch;
    
      $ ls -la ../../../arch/x86/include/uapi/asm/errno.h
      -rw-rw-r--. 1 acme acme 31 Feb 20 12:42 ../../../arch/x86/include/uapi/asm/errno.h
      $
    
    Check that that is still under tools/, i.e. hasn't escaped into the main
    kernel sources:
    
      $ cd ../../../arch/x86/include/uapi/asm/
      $ pwd
      /home/acme/git/perf/tools/arch/x86/include/uapi/asm
      $
    
    Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Quoted 301 lines
---
 tools/include/uapi/asm/errno.h           | 14 +++++------
 tools/perf/arch/arm64/util/arm-spe.c     | 20 ++++++++--------
 tools/perf/arch/arm64/util/perf_regs.c   |  2 +-
 tools/perf/arch/powerpc/util/perf_regs.c |  4 ++--
 tools/perf/arch/x86/util/auxtrace.c      | 14 +++++------
 tools/perf/arch/x86/util/event.c         | 12 +++++-----
 tools/perf/arch/x86/util/header.c        |  4 ++--
 tools/perf/arch/x86/util/intel-bts.c     | 24 +++++++++----------
 tools/perf/arch/x86/util/intel-pt.c      | 30 ++++++++++++------------
 tools/perf/arch/x86/util/machine.c       |  6 ++---
 tools/perf/arch/x86/util/perf_regs.c     |  8 +++----
 tools/perf/arch/x86/util/pmu.c           |  6 ++---
 12 files changed, 72 insertions(+), 72 deletions(-)
tools/include/uapi/asm/errno.h +7 -7
index ce3c5945a1c4..637189ec1ab9 100644
@@ -1,18 +1,18 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #if defined(__i386__) || defined(__x86_64__)
-#include "../../arch/x86/include/uapi/asm/errno.h"
+#include "../../../arch/x86/include/uapi/asm/errno.h"
 #elif defined(__powerpc__)
-#include "../../arch/powerpc/include/uapi/asm/errno.h"
+#include "../../../arch/powerpc/include/uapi/asm/errno.h"
 #elif defined(__sparc__)
-#include "../../arch/sparc/include/uapi/asm/errno.h"
+#include "../../../arch/sparc/include/uapi/asm/errno.h"
 #elif defined(__alpha__)
-#include "../../arch/alpha/include/uapi/asm/errno.h"
+#include "../../../arch/alpha/include/uapi/asm/errno.h"
 #elif defined(__mips__)
-#include "../../arch/mips/include/uapi/asm/errno.h"
+#include "../../../arch/mips/include/uapi/asm/errno.h"
 #elif defined(__ia64__)
-#include "../../arch/ia64/include/uapi/asm/errno.h"
+#include "../../../arch/ia64/include/uapi/asm/errno.h"
 #elif defined(__xtensa__)
-#include "../../arch/xtensa/include/uapi/asm/errno.h"
+#include "../../../arch/xtensa/include/uapi/asm/errno.h"
 #else
 #include <asm-generic/errno.h>
 #endif
tools/perf/arch/arm64/util/arm-spe.c +10 -10
index 8d6821d9c3f6..27653be24447 100644
@@ -11,17 +11,17 @@
 #include <linux/zalloc.h>
 #include <time.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/session.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/session.h"
 #include <internal/lib.h> // page_size
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/arm-spe.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/arm-spe.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/arm64/util/perf_regs.c +1 -1
index 2864e2e3776d..2833e101a7c6 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "../../util/perf_regs.h"
+#include "../../../util/perf_regs.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG_END
tools/perf/arch/powerpc/util/perf_regs.c +2 -2
index e9c436eeffc9..0a5242900248 100644
@@ -4,8 +4,8 @@
 #include <regex.h>
 #include <linux/zalloc.h>
 
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
 
 #include <linux/kernel.h>
 
tools/perf/arch/x86/util/auxtrace.c +7 -7
index 7abc9fd4cbec..3da506e13f49 100644
@@ -7,13 +7,13 @@
 #include <errno.h>
 #include <stdbool.h>
 
-#include "../../util/header.h"
-#include "../../util/debug.h"
-#include "../../util/pmu.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/evlist.h"
+#include "../../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/pmu.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/evlist.h"
 
 static
 struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
tools/perf/arch/x86/util/event.c +6 -6
index ac45015cc6ba..047dc00eafa6 100644
@@ -3,12 +3,12 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
-#include "../../util/event.h"
-#include "../../util/synthetic-events.h"
-#include "../../util/machine.h"
-#include "../../util/tool.h"
-#include "../../util/map.h"
-#include "../../util/debug.h"
+#include "../../../util/event.h"
+#include "../../../util/synthetic-events.h"
+#include "../../../util/machine.h"
+#include "../../../util/tool.h"
+#include "../../../util/map.h"
+#include "../../../util/debug.h"
 
 #if defined(__x86_64__)
 
tools/perf/arch/x86/util/header.c +2 -2
index aa6deb463bf3..578c8c568ffd 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 #include <regex.h>
 
-#include "../../util/debug.h"
-#include "../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/header.h"
 
 static inline void
 cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
tools/perf/arch/x86/util/intel-bts.c +12 -12
index 26cee1052179..09f93800bffd 100644
@@ -11,18 +11,18 @@
 #include <linux/log2.h>
 #include <linux/zalloc.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/mmap.h"
-#include "../../util/session.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/record.h"
-#include "../../util/tsc.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-bts.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/record.h"
+#include "../../../util/tsc.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-bts.h"
 #include <internal/lib.h> // page_size
 
 #define KiB(x) ((x) * 1024)
tools/perf/arch/x86/util/intel-pt.c +15 -15
index 7eea4fd7ce58..1643aed8c4c8 100644
@@ -13,23 +13,23 @@
 #include <linux/zalloc.h>
 #include <cpuid.h>
 
-#include "../../util/session.h"
-#include "../../util/event.h"
-#include "../../util/evlist.h"
-#include "../../util/evsel.h"
-#include "../../util/evsel_config.h"
-#include "../../util/cpumap.h"
-#include "../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/event.h"
+#include "../../../util/evlist.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evsel_config.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/mmap.h"
 #include <subcmd/parse-options.h>
-#include "../../util/parse-events.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/target.h"
-#include "../../util/tsc.h"
+#include "../../../util/parse-events.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/target.h"
+#include "../../../util/tsc.h"
 #include <internal/lib.h> // page_size
-#include "../../util/intel-pt.h"
+#include "../../../util/intel-pt.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/x86/util/machine.c +3 -3
index e17e080e76f4..31679c35d493 100644
@@ -5,9 +5,9 @@
 #include <stdlib.h>
 
 #include <internal/lib.h> // page_size
-#include "../../util/machine.h"
-#include "../../util/map.h"
-#include "../../util/symbol.h"
+#include "../../../util/machine.h"
+#include "../../../util/map.h"
+#include "../../../util/symbol.h"
 #include <linux/ctype.h>
 
 #include <symbol/kallsyms.h>
tools/perf/arch/x86/util/perf_regs.c +4 -4
index c218b83e063b..fca81b39b09f 100644
@@ -5,10 +5,10 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 
-#include "../../perf-sys.h"
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
-#include "../../util/event.h"
+#include "../../../perf-sys.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
+#include "../../../util/event.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG(AX, PERF_REG_X86_AX),
tools/perf/arch/x86/util/pmu.c +3 -3
index e33ef5bc31c5..d48d608517fd 100644
@@ -4,9 +4,9 @@
 #include <linux/stddef.h>
 #include <linux/perf_event.h>
 
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/pmu.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/pmu.h"
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
 {
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
Signature · 1 line
- Arnaldo
merge bot Applied
#6 lore raw

[tip: perf/urgent] tools: Fix off-by 1 relative directory includes

In reply to Ian Rogers
The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     441b62acd9c809e87bab45ad1d82b1b3b77cb4f0
Gitweb:        https://git.kernel.org/tip/441b62acd9c809e87bab45ad1d82b1b3b77cb4f0
Author:        Ian Rogers <[email protected]>
AuthorDate:    Thu, 05 Mar 2020 23:11:08 -08:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Fri, 06 Mar 2020 08:36:46 -03:00

tools: Fix off-by 1 relative directory includes

This is currently working due to extra include paths in the build.

Committer testing:

  $ cd tools/include/uapi/asm/

Before this patch:

  $ ls -la ../../arch/x86/include/uapi/asm/errno.h
  ls: cannot access '../../arch/x86/include/uapi/asm/errno.h': No such file or directory
  $

After this patch;

  $ ls -la ../../../arch/x86/include/uapi/asm/errno.h
  -rw-rw-r--. 1 acme acme 31 Feb 20 12:42 ../../../arch/x86/include/uapi/asm/errno.h
  $

Check that that is still under tools/, i.e. hasn't escaped into the main kernel sources:

  $ cd ../../../arch/x86/include/uapi/asm/
  $ pwd
  /home/acme/git/perf/tools/arch/x86/include/uapi/asm
  $
Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alexios Zavras <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Igor Lubashev <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Wei Li <[email protected]>
---
 tools/include/uapi/asm/errno.h           | 14 +++++------
 tools/perf/arch/arm64/util/arm-spe.c     | 20 +++++++--------
 tools/perf/arch/arm64/util/perf_regs.c   |  2 +-
 tools/perf/arch/powerpc/util/perf_regs.c |  4 +--
 tools/perf/arch/x86/util/auxtrace.c      | 14 +++++------
 tools/perf/arch/x86/util/event.c         | 12 ++++-----
 tools/perf/arch/x86/util/header.c        |  4 +--
 tools/perf/arch/x86/util/intel-bts.c     | 24 +++++++++---------
 tools/perf/arch/x86/util/intel-pt.c      | 30 +++++++++++------------
 tools/perf/arch/x86/util/machine.c       |  6 ++---
 tools/perf/arch/x86/util/perf_regs.c     |  8 +++---
 tools/perf/arch/x86/util/pmu.c           |  6 ++---
 12 files changed, 72 insertions(+), 72 deletions(-)
tools/include/uapi/asm/errno.h +7 -7
index ce3c594..637189e 100644
@@ -1,18 +1,18 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #if defined(__i386__) || defined(__x86_64__)
-#include "../../arch/x86/include/uapi/asm/errno.h"
+#include "../../../arch/x86/include/uapi/asm/errno.h"
 #elif defined(__powerpc__)
-#include "../../arch/powerpc/include/uapi/asm/errno.h"
+#include "../../../arch/powerpc/include/uapi/asm/errno.h"
 #elif defined(__sparc__)
-#include "../../arch/sparc/include/uapi/asm/errno.h"
+#include "../../../arch/sparc/include/uapi/asm/errno.h"
 #elif defined(__alpha__)
-#include "../../arch/alpha/include/uapi/asm/errno.h"
+#include "../../../arch/alpha/include/uapi/asm/errno.h"
 #elif defined(__mips__)
-#include "../../arch/mips/include/uapi/asm/errno.h"
+#include "../../../arch/mips/include/uapi/asm/errno.h"
 #elif defined(__ia64__)
-#include "../../arch/ia64/include/uapi/asm/errno.h"
+#include "../../../arch/ia64/include/uapi/asm/errno.h"
 #elif defined(__xtensa__)
-#include "../../arch/xtensa/include/uapi/asm/errno.h"
+#include "../../../arch/xtensa/include/uapi/asm/errno.h"
 #else
 #include <asm-generic/errno.h>
 #endif
tools/perf/arch/arm64/util/arm-spe.c +10 -10
index 8d6821d..27653be 100644
@@ -11,17 +11,17 @@
 #include <linux/zalloc.h>
 #include <time.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/session.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/session.h"
 #include <internal/lib.h> // page_size
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/arm-spe.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/arm-spe.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/arm64/util/perf_regs.c +1 -1
index 2864e2e..2833e10 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "../../util/perf_regs.h"
+#include "../../../util/perf_regs.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG_END
tools/perf/arch/powerpc/util/perf_regs.c +2 -2
index e9c436e..0a52429 100644
@@ -4,8 +4,8 @@
 #include <regex.h>
 #include <linux/zalloc.h>
 
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
 
 #include <linux/kernel.h>
 
tools/perf/arch/x86/util/auxtrace.c +7 -7
index 7abc9fd..3da506e 100644
@@ -7,13 +7,13 @@
 #include <errno.h>
 #include <stdbool.h>
 
-#include "../../util/header.h"
-#include "../../util/debug.h"
-#include "../../util/pmu.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/evlist.h"
+#include "../../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/pmu.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/evlist.h"
 
 static
 struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
tools/perf/arch/x86/util/event.c +6 -6
index ac45015..047dc00 100644
@@ -3,12 +3,12 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
-#include "../../util/event.h"
-#include "../../util/synthetic-events.h"
-#include "../../util/machine.h"
-#include "../../util/tool.h"
-#include "../../util/map.h"
-#include "../../util/debug.h"
+#include "../../../util/event.h"
+#include "../../../util/synthetic-events.h"
+#include "../../../util/machine.h"
+#include "../../../util/tool.h"
+#include "../../../util/map.h"
+#include "../../../util/debug.h"
 
 #if defined(__x86_64__)
 
tools/perf/arch/x86/util/header.c +2 -2
index aa6deb4..578c8c5 100644
@@ -7,8 +7,8 @@
 #include <string.h>
 #include <regex.h>
 
-#include "../../util/debug.h"
-#include "../../util/header.h"
+#include "../../../util/debug.h"
+#include "../../../util/header.h"
 
 static inline void
 cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
tools/perf/arch/x86/util/intel-bts.c +12 -12
index 26cee10..09f9380 100644
@@ -11,18 +11,18 @@
 #include <linux/log2.h>
 #include <linux/zalloc.h>
 
-#include "../../util/cpumap.h"
-#include "../../util/event.h"
-#include "../../util/evsel.h"
-#include "../../util/evlist.h"
-#include "../../util/mmap.h"
-#include "../../util/session.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/record.h"
-#include "../../util/tsc.h"
-#include "../../util/auxtrace.h"
-#include "../../util/intel-bts.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/event.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evlist.h"
+#include "../../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/record.h"
+#include "../../../util/tsc.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/intel-bts.h"
 #include <internal/lib.h> // page_size
 
 #define KiB(x) ((x) * 1024)
tools/perf/arch/x86/util/intel-pt.c +15 -15
index 7eea4fd..1643aed 100644
@@ -13,23 +13,23 @@
 #include <linux/zalloc.h>
 #include <cpuid.h>
 
-#include "../../util/session.h"
-#include "../../util/event.h"
-#include "../../util/evlist.h"
-#include "../../util/evsel.h"
-#include "../../util/evsel_config.h"
-#include "../../util/cpumap.h"
-#include "../../util/mmap.h"
+#include "../../../util/session.h"
+#include "../../../util/event.h"
+#include "../../../util/evlist.h"
+#include "../../../util/evsel.h"
+#include "../../../util/evsel_config.h"
+#include "../../../util/cpumap.h"
+#include "../../../util/mmap.h"
 #include <subcmd/parse-options.h>
-#include "../../util/parse-events.h"
-#include "../../util/pmu.h"
-#include "../../util/debug.h"
-#include "../../util/auxtrace.h"
-#include "../../util/record.h"
-#include "../../util/target.h"
-#include "../../util/tsc.h"
+#include "../../../util/parse-events.h"
+#include "../../../util/pmu.h"
+#include "../../../util/debug.h"
+#include "../../../util/auxtrace.h"
+#include "../../../util/record.h"
+#include "../../../util/target.h"
+#include "../../../util/tsc.h"
 #include <internal/lib.h> // page_size
-#include "../../util/intel-pt.h"
+#include "../../../util/intel-pt.h"
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/x86/util/machine.c +3 -3
index e17e080..31679c3 100644
@@ -5,9 +5,9 @@
 #include <stdlib.h>
 
 #include <internal/lib.h> // page_size
-#include "../../util/machine.h"
-#include "../../util/map.h"
-#include "../../util/symbol.h"
+#include "../../../util/machine.h"
+#include "../../../util/map.h"
+#include "../../../util/symbol.h"
 #include <linux/ctype.h>
 
 #include <symbol/kallsyms.h>
tools/perf/arch/x86/util/perf_regs.c +4 -4
index c218b83..fca81b3 100644
@@ -5,10 +5,10 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 
-#include "../../perf-sys.h"
-#include "../../util/perf_regs.h"
-#include "../../util/debug.h"
-#include "../../util/event.h"
+#include "../../../perf-sys.h"
+#include "../../../util/perf_regs.h"
+#include "../../../util/debug.h"
+#include "../../../util/event.h"
 
 const struct sample_reg sample_reg_masks[] = {
 	SMPL_REG(AX, PERF_REG_X86_AX),
tools/perf/arch/x86/util/pmu.c +3 -3
index e33ef5b..d48d608 100644
@@ -4,9 +4,9 @@
 #include <linux/stddef.h>
 #include <linux/perf_event.h>
 
-#include "../../util/intel-pt.h"
-#include "../../util/intel-bts.h"
-#include "../../util/pmu.h"
+#include "../../../util/intel-pt.h"
+#include "../../../util/intel-bts.h"
+#include "../../../util/pmu.h"
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
 {
author reviewer
#7 lore raw

PATCH 2/3 libperf: avoid redefining _GNU_SOURCE in test

In reply to Ian Rogers

_GNU_SOURCE needs to be globally defined to pick up features like asprintf. Add a guard against redefinition in this test.

---
 tools/lib/perf/tests/test-evlist.c | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/perf/tests/test-evlist.c +2 -0
index 6d8ebe0c2504..5a5ff104b668 100644
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
+#endif
 #include <sched.h>
 #include <stdio.h>
 #include <stdarg.h>
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
#8 lore raw

Re: [PATCH 2/3] libperf: avoid redefining _GNU_SOURCE in test

Em Thu, Mar 05, 2020 at 11:11:09PM -0800, Ian Rogers escreveu:

Quoted 2 lines

_GNU_SOURCE needs to be globally defined to pick up features like asprintf. Add a guard against redefinition in this test.

Humm, so you're completely sure that the Makefiles that drive the build of this file don't set _GNU_SOURCE? I.e. some explanation in the cset log message about that would help in processing the patch,

- Arnaldo

Quoted 20 lines
---
 tools/lib/perf/tests/test-evlist.c | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/perf/tests/test-evlist.c +2 -0
index 6d8ebe0c2504..5a5ff104b668 100644
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
+#endif
 #include <sched.h>
 #include <stdio.h>
 #include <stdarg.h>
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
Signature · 1 line
- Arnaldo
author reviewer
#9 lore raw

Re: [PATCH 2/3] libperf: avoid redefining _GNU_SOURCE in test

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 05, 2020 at 11:11:09PM -0800, Ian Rogers escreveu:

Quoted 2 lines

_GNU_SOURCE needs to be globally defined to pick up features like asprintf. Add a guard against redefinition in this test.

Humm, so you're completely sure that the Makefiles that drive the build of this file don't set _GNU_SOURCE? I.e. some explanation in the cset log message about that would help in processing the patch,

The convention on _GNU_SOURCE isn't very clear. For our builds we set _GNU_SOURCE globally hence needing this patch. This patch won't interfere with a Makefile setting. Here is some of the inconsistency:

tools/perf: sets _GNU_SOURCE:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/tools/perf/Makefile.config#n309

tools/lib/perf: doesn't set _GNU_SOURCE <-- I'm inconsistent in setting _GNU_SOURCE when building files here
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/tools/lib/perf/Makefile

tools/lib/subcmd: sets _GNU_SOURCE
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/tools/lib/subcmd/Makefile#n43

Some #defines of _GNU_SOURCE are already guarded to avoid redefinition:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/tools/lib/bpf/libbpf.c#n13

Some code explicitly undefines _GNU_SOURCE:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/tools/lib/str_error_r.c#n2

I don't think this patch hurts, I'm not sure it adds value. I think there's a wider cleanup necessary here but I'm not sure what that would look like.

Thanks,
Ian

Quoted 26 lines

- Arnaldo

Quoted 18 lines
---
 tools/lib/perf/tests/test-evlist.c | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/perf/tests/test-evlist.c +2 -1
index 6d8ebe0c2504..5a5ff104b668 100644
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE // needed for sched.h to get sched_[gs]etaffinity and CPU_(ZERO,SET)
+#endif
 #include <sched.h>
 #include <stdio.h>
 #include <stdarg.h>
--
Quoted 2 lines

2.25.1.481.gfbce0eb801-goog

--

- Arnaldo

author reviewer
#10 lore raw

PATCH 3/3 tools/perf: build fixes for arch_errno_names.sh

In reply to Ian Rogers

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

---
 tools/perf/trace/beauty/arch_errno_names.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +2 -2
index 22c9fc900c84..9f9ea45cddc4 100755
@@ -57,7 +57,7 @@ process_arch()
 	local arch="$1"
 	local asm_errno=$(asm_errno_file "$arch")
 
-	$gcc $include_path -E -dM -x c $asm_errno \
+	$gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
 		|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
 		|awk '{ print $2","$3; }' \
 		|sort -t, -k2 -nu \
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d arch/$arch && archlist="$archlist $arch"
+	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
#11 lore raw

Re: [PATCH 3/3] tools/perf: build fixes for arch_errno_names.sh

Em Thu, Mar 05, 2020 at 11:11:10PM -0800, Ian Rogers escreveu:

Quoted 4 lines

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

Hendrik and Thomas, can you please take a look at this and provide a Reviewed-by tag?

Thanks,

- Arnaldo

Quoted 30 lines
---
 tools/perf/trace/beauty/arch_errno_names.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +2 -2
index 22c9fc900c84..9f9ea45cddc4 100755
@@ -57,7 +57,7 @@ process_arch()
 	local arch="$1"
 	local asm_errno=$(asm_errno_file "$arch")
 
-	$gcc $include_path -E -dM -x c $asm_errno \
+	$gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
 		|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
 		|awk '{ print $2","$3; }' \
 		|sort -t, -k2 -nu \
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d arch/$arch && archlist="$archlist $arch"
+	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
Signature · 1 line
- Arnaldo
author reviewer
#12 lore raw

Re: [PATCH 3/3] tools/perf: build fixes for arch_errno_names.sh

Quoted 9 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 05, 2020 at 11:11:10PM -0800, Ian Rogers escreveu:

Quoted 4 lines

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

Hendrik and Thomas, can you please take a look at this and provide a Reviewed-by tag?

Ping.

Quoted 38 lines

Thanks,

- Arnaldo

Quoted 28 lines
---
 tools/perf/trace/beauty/arch_errno_names.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +2 -3
index 22c9fc900c84..9f9ea45cddc4 100755
@@ -57,7 +57,7 @@ process_arch()
      local arch="$1"
      local asm_errno=$(asm_errno_file "$arch")
 
-     $gcc $include_path -E -dM -x c $asm_errno \
+     $gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
              |grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
              |awk '{ print $2","$3; }' \
              |sort -t, -k2 -nu \
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-     test -d arch/$arch && archlist="$archlist $arch"
+     test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
--
Quoted 2 lines

2.25.1.481.gfbce0eb801-goog

--

- Arnaldo

#13 lore raw

Re: [PATCH 3/3] tools/perf: build fixes for arch_errno_names.sh

In reply to Ian Rogers

Em Thu, Mar 05, 2020 at 11:11:10PM -0800, Ian Rogers escreveu:

Quoted 4 lines

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

I've looked at this and split this part in a separate patch, and applied it locally, please take a look, now looking at the other bit of the patch.

- Arnaldo

Quoted 11 lines
---
 tools/perf/trace/beauty/arch_errno_names.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +0 -0
index 22c9fc900c84..9f9ea45cddc4 100755

tools/perf/trace/beauty/arch_errno_names.sh EoHEADER · line 97

Quoted 8 lines
tools/perf/trace/beauty/arch_errno_names.sh +1 -1
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d arch/$arch && archlist="$archlist $arch"
+	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do

commit 1b59e3b7bfc6183d3dc9f119e1875f9607d29d96

Author: Ian Rogers <[email protected]>
Date:   Thu Mar 5 23:11:10 2020 -0800

perf trace: Fix the selection for architectures to generate the errno name tables

Make the architecture test directory agree with the code comment.

Committer notes:

This was split from a larger patch.

The code was assuming the developer always worked from tools/perf/, so make sure we do the test -d having $toolsdir/perf/arch/$arch, to match the intent expressed in the comment, just above that loop.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alexios Zavras <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Igor Lubashev <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Wei Li <[email protected]>
tools/perf/trace/beauty/arch_errno_names.sh +1 -1
index 22c9fc900c84..f8c44a85650b 100755
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d arch/$arch && archlist="$archlist $arch"
+	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
author reviewer
#14 lore raw

Re: [PATCH 3/3] tools/perf: build fixes for arch_errno_names.sh

Quoted 10 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 05, 2020 at 11:11:10PM -0800, Ian Rogers escreveu:

Quoted 4 lines

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

I've looked at this and split this part in a separate patch, and applied it locally, please take a look, now looking at the other bit of the patch.

This bit looks good. The CFLAGS change is something I need to deal with a directory layout change in our build system.

Thanks,
Ian

Quoted 70 lines

- Arnaldo

Quoted 10 lines
---
 tools/perf/trace/beauty/arch_errno_names.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +0 -0
index 22c9fc900c84..9f9ea45cddc4 100755

tools/perf/trace/beauty/arch_errno_names.sh EoHEADER

Quoted 9 lines
tools/perf/trace/beauty/arch_errno_names.sh +1 -2
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-     test -d arch/$arch && archlist="$archlist $arch"
+     test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
--

commit 1b59e3b7bfc6183d3dc9f119e1875f9607d29d96

Author: Ian Rogers <[email protected]>
Date:   Thu Mar 5 23:11:10 2020 -0800

perf trace: Fix the selection for architectures to generate the errno name tables

Make the architecture test directory agree with the code comment.

Committer notes:

This was split from a larger patch.

The code was assuming the developer always worked from tools/perf/, so make sure we do the test -d having $toolsdir/perf/arch/$arch, to match the intent expressed in the comment, just above that loop.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alexios Zavras <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Igor Lubashev <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Wei Li <[email protected]>
tools/perf/trace/beauty/arch_errno_names.sh +1 -1
index 22c9fc900c84..f8c44a85650b 100755
@@ -91,7 +91,7 @@ EoHEADER
 # in tools/perf/arch
 archlist=""
 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-       test -d arch/$arch && archlist="$archlist $arch"
+       test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
 done
 
 for arch in x86 $archlist generic; do
#15 lore raw

Re: [PATCH 3/3] tools/perf: build fixes for arch_errno_names.sh

Em Thu, May 14, 2020 at 10:54:49AM -0700, Ian Rogers escreveu:

Quoted 9 lines
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Thu, Mar 05, 2020 at 11:11:10PM -0800, Ian Rogers escreveu:

Quoted 4 lines

Allow the CC compiler to accept a CFLAGS environment variable. Make the architecture test directory agree with the code comment. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

Quoted 7 lines
Quoted 3 lines

I've looked at this and split this part in a separate patch, and applied it locally, please take a look, now looking at the other bit of the patch.

This bit looks good. The CFLAGS change is something I need to deal with a directory layout change in our build system.

I added that one as well, as a separate patch, this one:

commit 6e136ceba23c087b1e1b846914e425706d492a3a

Author: Ian Rogers <[email protected]>
Date:   Thu Mar 5 23:11:10 2020 -0800

perf beauty: Allow the CC used in the arch errno names script to acccept CFLAGS

Allow the CC compiler to accept a CFLAGS environment variable. This doesn't change the code generated but makes it easier to integrate running the shell script in build systems like bazel.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alexios Zavras <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Igor Lubashev <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Wei Li <[email protected]>
[ split from a larger patch ]
tools/perf/trace/beauty/arch_errno_names.sh +1 -1
index f8c44a85650b..9f9ea45cddc4 100755
@@ -57,7 +57,7 @@ process_arch()
 	local arch="$1"
 	local asm_errno=$(asm_errno_file "$arch")
 
-	$gcc $include_path -E -dM -x c $asm_errno \
+	$gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
 		|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
 		|awk '{ print $2","$3; }' \
 		|sort -t, -k2 -nu \
Acked-by on the v1 series
#16 lore raw
In reply to Ian Rogers
Quoted 7 lines · Ian Rogers

These patches better enable a build of perf when not using the regular Makefiles, in my case using bazel.

Ian Rogers (3):
tools: fix off-by 1 relative directory includes
libperf: avoid redefining _GNU_SOURCE in test
tools/perf: build fixes for arch_errno_names.sh

thanks,
jirka

Quoted 20 lines
 tools/include/uapi/asm/errno.h              | 14 +++++-----
 tools/lib/perf/tests/test-evlist.c          |  2 ++
 tools/perf/arch/arm64/util/arm-spe.c        | 20 +++++++-------
 tools/perf/arch/arm64/util/perf_regs.c      |  2 +-
 tools/perf/arch/powerpc/util/perf_regs.c    |  4 +--
 tools/perf/arch/x86/util/auxtrace.c         | 14 +++++-----
 tools/perf/arch/x86/util/event.c            | 12 ++++-----
 tools/perf/arch/x86/util/header.c           |  4 +--
 tools/perf/arch/x86/util/intel-bts.c        | 24 ++++++++---------
 tools/perf/arch/x86/util/intel-pt.c         | 30 ++++++++++-----------
 tools/perf/arch/x86/util/machine.c          |  6 ++---
 tools/perf/arch/x86/util/perf_regs.c        |  8 +++---
 tools/perf/arch/x86/util/pmu.c              |  6 ++---
 tools/perf/trace/beauty/arch_errno_names.sh |  4 +--
 14 files changed, 76 insertions(+), 74 deletions(-)
Signature · 1 line
2.25.1.481.gfbce0eb801-goog