Skip to contentSkip to conversation

perf tools: optional compile time test_attr__* depenency for perf-sys.h

PATCH Applied Björn Töpel 5 participants 10 messages Oct 1, 2019 – Oct 15, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover perf tools: optional compile time test_attr__* depenency for perf-sys.h

This mini series makes it possible to disable the use of test_attr__* for perf-sys.h users outside perf. E.g., samples/bpf/ uses perf-sys.h as a syscall wrapper.

Now a user can define HAVE_ATTR_TEST to zero to avoid this, and as a nice side-effect it also fixes the samples/bpf/ build. ;-)

Björn Töpel (2):
perf tools: Make usage of test_attr__* optional for perf-sys.h samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

 samples/bpf/Makefile  | 1 +
 tools/perf/perf-sys.h | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 perf tools: Make usage of test_attr__* optional for perf-sys.h

From: Björn Töpel <[email protected]>

For users of perf-sys.h outside perf, e.g. samples/bpf/bpf_load.c, it's convenient not to depend on test_attr__*.

After commit 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h"), all users of perf-sys.h will depend on test_attr__enabled and test_attr__open.

This commit enables a user to define HAVE_ATTR_TEST to zero in order to omit the test dependency.

Fixes 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")
---
 tools/perf/perf-sys.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/perf-sys.h +4 -2
index 63e4349a772a..15e458e150bd 100644
@@ -15,7 +15,9 @@ void test_attr__init(void);
 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 		     int fd, int group_fd, unsigned long flags);
 
-#define HAVE_ATTR_TEST
+#ifndef HAVE_ATTR_TEST
+#define HAVE_ATTR_TEST 1
+#endif
 
 static inline int
 sys_perf_event_open(struct perf_event_attr *attr,
@@ -27,7 +29,7 @@ sys_perf_event_open(struct perf_event_attr *attr,
 	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
 		     group_fd, flags);
 
-#ifdef HAVE_ATTR_TEST
+#if HAVE_ATTR_TEST
 	if (unlikely(test_attr__enabled))
 		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
 #endif
Signature · 1 line
2.20.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] perf tools: Make usage of test_attr__* optional for perf-sys.h

Quoted 10 lines · Björn Töpel

From: Björn Töpel <[email protected]>

For users of perf-sys.h outside perf, e.g. samples/bpf/bpf_load.c, it's convenient not to depend on test_attr__*.

After commit 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h"), all users of perf-sys.h will depend on test_attr__enabled and test_attr__open.

Quoted 5 lines

This commit enables a user to define HAVE_ATTR_TEST to zero in order to omit the test dependency.

Fixes 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")
#3 lore raw

Re: [PATCH 1/2] perf tools: Make usage of test_attr__* optional for perf-sys.h

In reply to Björn Töpel

Em Tue, Oct 01, 2019 at 01:33:06PM +0200, Björn Töpel escreveu:

Quoted 11 lines

From: Björn Töpel <[email protected]>

For users of perf-sys.h outside perf, e.g. samples/bpf/bpf_load.c, it's convenient not to depend on test_attr__*.

After commit 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h"), all users of perf-sys.h will depend on test_attr__enabled and test_attr__open.

This commit enables a user to define HAVE_ATTR_TEST to zero in order to omit the test dependency.

Woah, I wasn't expecting tools/perf/ stuff to be included from outside tools/perf/, so thanks for fixing that odd user.

Applied.

- Arnaldo

Quoted 32 lines
Fixes 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")
---
 tools/perf/perf-sys.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/perf-sys.h +4 -2
index 63e4349a772a..15e458e150bd 100644
@@ -15,7 +15,9 @@ void test_attr__init(void);
 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 		     int fd, int group_fd, unsigned long flags);
 
-#define HAVE_ATTR_TEST
+#ifndef HAVE_ATTR_TEST
+#define HAVE_ATTR_TEST 1
+#endif
 
 static inline int
 sys_perf_event_open(struct perf_event_attr *attr,
@@ -27,7 +29,7 @@ sys_perf_event_open(struct perf_event_attr *attr,
 	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
 		     group_fd, flags);
 
-#ifdef HAVE_ATTR_TEST
+#if HAVE_ATTR_TEST
 	if (unlikely(test_attr__enabled))
 		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
 #endif
Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo
merge bot Applied
#4 lore raw

[tip: perf/core] perf tools: Make usage of test_attr__* optional for perf-sys.h

In reply to Björn Töpel
The following commit has been merged into the perf/core branch of tip:

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

Commit-ID:     06f84d1989b7e58d56fa2e448664585749d41221
Gitweb:        https://git.kernel.org/tip/06f84d1989b7e58d56fa2e448664585749d41221
Author:        Björn Töpel <[email protected]>
AuthorDate:    Tue, 01 Oct 2019 13:33:06 +02:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 07 Oct 2019 12:22:17 -03:00

perf tools: Make usage of test_attr__* optional for perf-sys.h

For users of perf-sys.h outside perf, e.g. samples/bpf/bpf_load.c, it's convenient not to depend on test_attr__*.

After commit 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h"), all users of perf-sys.h will depend on test_attr__enabled and test_attr__open.

This commit enables a user to define HAVE_ATTR_TEST to zero in order to omit the test dependency.

Fixes 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")
Cc Adrian Hunter <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/perf-sys.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/perf-sys.h +4 -2
index 63e4349..15e458e 100644
@@ -15,7 +15,9 @@ void test_attr__init(void);
 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 		     int fd, int group_fd, unsigned long flags);
 
-#define HAVE_ATTR_TEST
+#ifndef HAVE_ATTR_TEST
+#define HAVE_ATTR_TEST 1
+#endif
 
 static inline int
 sys_perf_event_open(struct perf_event_attr *attr,
@@ -27,7 +29,7 @@ sys_perf_event_open(struct perf_event_attr *attr,
 	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
 		     group_fd, flags);
 
-#ifdef HAVE_ATTR_TEST
+#if HAVE_ATTR_TEST
 	if (unlikely(test_attr__enabled))
 		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
 #endif
#5 lore raw

PATCH 2/2 samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

In reply to Björn Töpel

From: Björn Töpel <[email protected]>

To remove that test_attr__{enabled/open} are used by perf-sys.h, we set HAVE_ATTR_TEST to zero.

---
 samples/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)
samples/bpf/Makefile +1 -0
index 1d9be26b4edd..42b571cde177 100644
@@ -176,6 +176,7 @@ KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf
+KBUILD_HOSTCFLAGS += -DHAVE_ATTR_TEST=0
 
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
 
Signature · 1 line
2.20.1
Tested-by
#7 lore raw

Re: [PATCH 2/2] samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

I can confirm that samples/bpf are building for me now (x86_64, clang-8) after applying this series and:

* https://lore.kernel.org/bpf/CAPhsuW5c9v0OnU4g+eYkPjBCuNMjC_69pFhzr=nTfDMAy4bK6w@mail.gmail.com
* https://lore.kernel.org/bpf/[email protected]/

on the current bpf-next/master.

- KP

Quoted 11 lines · Song Liu
Quoted 7 lines · Björn Töpel

From: Björn Töpel <[email protected]>

To remove that test_attr__{enabled/open} are used by perf-sys.h, we set HAVE_ATTR_TEST to zero.

#8 lore raw

Re: [PATCH 2/2] samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

Em Thu, Oct 03, 2019 at 02:19:42AM +0200, KP Singh escreveu:

Quoted 8 lines

I can confirm that samples/bpf are building for me now (x86_64, clang-8) after applying this series and:

* https://lore.kernel.org/bpf/CAPhsuW5c9v0OnU4g+eYkPjBCuNMjC_69pFhzr=nTfDMAy4bK6w@mail.gmail.com
* https://lore.kernel.org/bpf/[email protected]/

Quoted 17 lines

on the current bpf-next/master.

- KP

Quoted 11 lines · Song Liu
Quoted 7 lines · Björn Töpel

From: Björn Töpel <[email protected]>

To remove that test_attr__{enabled/open} are used by perf-sys.h, we set HAVE_ATTR_TEST to zero.

Thanks, applied.

- Arnaldo

merge bot Applied
#9 lore raw

[tip: perf/core] samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

In reply to Björn Töpel
The following commit has been merged into the perf/core branch of tip:

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

Commit-ID:     fce9501aec6bdda45ef3a5e365a5e0de7de7fe2d
Gitweb:        https://git.kernel.org/tip/fce9501aec6bdda45ef3a5e365a5e0de7de7fe2d
Author:        Björn Töpel <[email protected]>
AuthorDate:    Tue, 01 Oct 2019 13:33:07 +02:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 07 Oct 2019 12:22:18 -03:00

samples/bpf: fix build by setting HAVE_ATTR_TEST to zero

To remove that test_attr__{enabled/open} are used by perf-sys.h, we set HAVE_ATTR_TEST to zero.

---
 samples/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)
samples/bpf/Makefile +1 -0
index 1d9be26..42b571c 100644
@@ -176,6 +176,7 @@ KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf
+KBUILD_HOSTCFLAGS += -DHAVE_ATTR_TEST=0
 
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable