* [PATCH] perf hashmap: Tidy hashmap dependency
@ 2022-08-24 5:06 Ian Rogers
2022-08-24 13:30 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2022-08-24 5:06 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
linux-perf-users, linux-kernel
Cc: Stephane Eranian, Ian Rogers
When libbpf is present the build uses definitions in libbpf hashmap.c,
however, libbpf's hashmap.h wasn't being used. Switch to using the
correct hashmap.h dependent on the define HAVE_LIBBPF_SUPPORT. This
was the original intent in:
https://lore.kernel.org/lkml/20200515221732.44078-8-irogers@google.com/
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/bpf-loader.c | 6 +++++-
tools/perf/util/evsel.c | 6 +++++-
tools/perf/util/expr.h | 11 ++++-------
tools/perf/util/stat.c | 6 +++++-
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index e2052f4fed33..d657594894cf 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -27,7 +27,11 @@
#include "util.h"
#include "llvm-utils.h"
#include "c++/clang-c.h"
-#include "hashmap.h"
+#ifdef HAVE_LIBBPF_SUPPORT
+#include <bpf/hashmap.h>
+#else
+#include "util/hashmap.h"
+#endif
#include "asm/bug.h"
#include <internal/xyarray.h>
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4852089e1d79..14846b7edb17 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -46,7 +46,11 @@
#include "string2.h"
#include "memswap.h"
#include "util.h"
-#include "hashmap.h"
+#ifdef HAVE_LIBBPF_SUPPORT
+#include <bpf/hashmap.h>
+#else
+#include "util/hashmap.h"
+#endif
#include "pmu-hybrid.h"
#include "off_cpu.h"
#include "../perf-sys.h"
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index bd2116983bbb..0403a92d9dcc 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -2,14 +2,11 @@
#ifndef PARSE_CTX_H
#define PARSE_CTX_H 1
-// There are fixes that need to land upstream before we can use libbpf's headers,
-// for now use our copy unconditionally, since the data structures at this point
-// are exactly the same, no problem.
-//#ifdef HAVE_LIBBPF_SUPPORT
-//#include <bpf/hashmap.h>
-//#else
+#ifdef HAVE_LIBBPF_SUPPORT
+#include <bpf/hashmap.h>
+#else
#include "util/hashmap.h"
-//#endif
+#endif
struct metric_ref;
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 0882b4754fcf..ce5e9e372fc4 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -14,7 +14,11 @@
#include "evlist.h"
#include "evsel.h"
#include "thread_map.h"
-#include "hashmap.h"
+#ifdef HAVE_LIBBPF_SUPPORT
+#include <bpf/hashmap.h>
+#else
+#include "util/hashmap.h"
+#endif
#include <linux/zalloc.h>
void update_stats(struct stats *stats, u64 val)
--
2.37.2.609.g9ff673ca1a-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf hashmap: Tidy hashmap dependency
2022-08-24 5:06 [PATCH] perf hashmap: Tidy hashmap dependency Ian Rogers
@ 2022-08-24 13:30 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-08-24 13:30 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, linux-perf-users, linux-kernel,
Stephane Eranian
Em Tue, Aug 23, 2022 at 10:06:04PM -0700, Ian Rogers escreveu:
> When libbpf is present the build uses definitions in libbpf hashmap.c,
> however, libbpf's hashmap.h wasn't being used. Switch to using the
> correct hashmap.h dependent on the define HAVE_LIBBPF_SUPPORT. This
> was the original intent in:
> https://lore.kernel.org/lkml/20200515221732.44078-8-irogers@google.com/
Thanks, applied.
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/bpf-loader.c | 6 +++++-
> tools/perf/util/evsel.c | 6 +++++-
> tools/perf/util/expr.h | 11 ++++-------
> tools/perf/util/stat.c | 6 +++++-
> 4 files changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
> index e2052f4fed33..d657594894cf 100644
> --- a/tools/perf/util/bpf-loader.c
> +++ b/tools/perf/util/bpf-loader.c
> @@ -27,7 +27,11 @@
> #include "util.h"
> #include "llvm-utils.h"
> #include "c++/clang-c.h"
> -#include "hashmap.h"
> +#ifdef HAVE_LIBBPF_SUPPORT
> +#include <bpf/hashmap.h>
> +#else
> +#include "util/hashmap.h"
> +#endif
> #include "asm/bug.h"
>
> #include <internal/xyarray.h>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 4852089e1d79..14846b7edb17 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -46,7 +46,11 @@
> #include "string2.h"
> #include "memswap.h"
> #include "util.h"
> -#include "hashmap.h"
> +#ifdef HAVE_LIBBPF_SUPPORT
> +#include <bpf/hashmap.h>
> +#else
> +#include "util/hashmap.h"
> +#endif
> #include "pmu-hybrid.h"
> #include "off_cpu.h"
> #include "../perf-sys.h"
> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
> index bd2116983bbb..0403a92d9dcc 100644
> --- a/tools/perf/util/expr.h
> +++ b/tools/perf/util/expr.h
> @@ -2,14 +2,11 @@
> #ifndef PARSE_CTX_H
> #define PARSE_CTX_H 1
>
> -// There are fixes that need to land upstream before we can use libbpf's headers,
> -// for now use our copy unconditionally, since the data structures at this point
> -// are exactly the same, no problem.
> -//#ifdef HAVE_LIBBPF_SUPPORT
> -//#include <bpf/hashmap.h>
> -//#else
> +#ifdef HAVE_LIBBPF_SUPPORT
> +#include <bpf/hashmap.h>
> +#else
> #include "util/hashmap.h"
> -//#endif
> +#endif
>
> struct metric_ref;
>
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index 0882b4754fcf..ce5e9e372fc4 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -14,7 +14,11 @@
> #include "evlist.h"
> #include "evsel.h"
> #include "thread_map.h"
> -#include "hashmap.h"
> +#ifdef HAVE_LIBBPF_SUPPORT
> +#include <bpf/hashmap.h>
> +#else
> +#include "util/hashmap.h"
> +#endif
> #include <linux/zalloc.h>
>
> void update_stats(struct stats *stats, u64 val)
> --
> 2.37.2.609.g9ff673ca1a-goog
--
- Arnaldo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-24 13:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 5:06 [PATCH] perf hashmap: Tidy hashmap dependency Ian Rogers
2022-08-24 13:30 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).