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(-)
--
2.20.1
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")
Signed-off-by: Björn Töpel <[email protected]>
---
tools/perf/perf-sys.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 63e4349a772a..15e458e150bd 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -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
--
2.20.1
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.
Signed-off-by: Björn Töpel <[email protected]>
---
samples/bpf/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1d9be26b4edd..42b571cde177 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -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
--
2.20.1
On Tue, Oct 1, 2019 at 4:35 AM Björn Töpel <[email protected]> wrote:
>
> 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")
> Signed-off-by: Björn Töpel <[email protected]>
Acked-by: Song Liu <[email protected]>
On Tue, Oct 1, 2019 at 4:36 AM Björn Töpel <[email protected]> wrote:
>
> 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.
>
> Signed-off-by: Björn Töpel <[email protected]>
Acked-by: Song Liu <[email protected]>
Tested-by: KP Singh <[email protected]>
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
On Wed, Oct 2, 2019 at 11:00 PM Song Liu <[email protected]> wrote:
>
> On Tue, Oct 1, 2019 at 4:36 AM Björn Töpel <[email protected]> wrote:
> >
> > 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.
> >
> > Signed-off-by: Björn Töpel <[email protected]>
>
> Acked-by: Song Liu <[email protected]>
Em Tue, Oct 01, 2019 at 01:33:06PM +0200, Bj?rn T?pel escreveu:
> 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
> 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(-)
>
> diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
> index 63e4349a772a..15e458e150bd 100644
> --- a/tools/perf/perf-sys.h
> +++ b/tools/perf/perf-sys.h
> @@ -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
> --
> 2.20.1
--
- Arnaldo
Em Thu, Oct 03, 2019 at 02:19:42AM +0200, KP Singh escreveu:
> Tested-by: KP Singh <[email protected]>
>
> 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
>
> On Wed, Oct 2, 2019 at 11:00 PM Song Liu <[email protected]> wrote:
> >
> > On Tue, Oct 1, 2019 at 4:36 AM Bj?rn T?pel <[email protected]> wrote:
> > >
> > > 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.
> > >
> > > Signed-off-by: Bj?rn T?pel <[email protected]>
> >
> > Acked-by: Song Liu <[email protected]>
Thanks, applied.
- Arnaldo
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")
Signed-off-by: Björn Töpel <[email protected]>
Acked-by: Song Liu <[email protected]>
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]>
Cc: [email protected]
Cc: [email protected]
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/perf-sys.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 63e4349..15e458e 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -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
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.
Signed-off-by: Björn Töpel <[email protected]>
Tested-by: KP Singh <[email protected]>
Acked-by: Song Liu <[email protected]>
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]>
Cc: [email protected]
Cc: [email protected]
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
samples/bpf/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1d9be26..42b571c 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -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