perf tools: optional compile time test_attr__* depenency for perf-sys.h
Subsystems (4)
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
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.
--- tools/perf/perf-sys.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/perf-sys.h +4 -2
@@ -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
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.houtside 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 tosys_perf_event_open()toperf-sys.h"), all users ofperf-sys.hwill depend ontest_attr__enabledandtest_attr__open.
Quoted 5 lines
This commit enables a user to define
HAVE_ATTR_TESTto zero in order to omit the test dependency.Fixes 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")Signed-off-by Björn Töpel <[email protected]>
Arnaldo Carvalho de Melo
AppliedRe: [PATCH 1/2] perf tools: Make usage of test_attr__* optional for perf-sys.h
In reply to Björn TöpelEm 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.houtside 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 tosys_perf_event_open()toperf-sys.h"), all users ofperf-sys.hwill depend ontest_attr__enabledandtest_attr__open.This commit enables a user to define
HAVE_ATTR_TESTto 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")Signed-off-by Björn Töpel <[email protected]>--- tools/perf/perf-sys.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/perf/perf-sys.h +4
-2@@ -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
[tip: perf/core] perf tools: Make usage of test_attr__* optional for perf-sys.h
In reply to Björn TöpelThe 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.
--- tools/perf/perf-sys.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/perf-sys.h +4 -2
@@ -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
PATCH 2/2 samples/bpf: fix build by setting HAVE_ATTR_TEST to zero
In reply to Björn TöpelFrom: 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
@@ -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
Re: [PATCH 2/2] samples/bpf: fix build by setting HAVE_ATTR_TEST to zero
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 setHAVE_ATTR_TESTto zero.Signed-off-by Björn Töpel <[email protected]>
KP Singh
Tested-byRe: [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 setHAVE_ATTR_TESTto zero.Signed-off-by Björn Töpel <[email protected]>Acked-by Song Liu <[email protected]>
Arnaldo Carvalho de Melo
AppliedRe: [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
Tested-by KP Singh <[email protected]>I can confirm that
samples/bpfare 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 setHAVE_ATTR_TESTto zero.Signed-off-by Björn Töpel <[email protected]>Acked-by Song Liu <[email protected]>
Thanks, applied.
- Arnaldo
[tip: perf/core] samples/bpf: fix build by setting HAVE_ATTR_TEST to zero
In reply to Björn TöpelThe 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
@@ -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