perf hashmap: Tidy hashmap dependency
Ian Rogers
reviewerPATCH 1/1 perf hashmap: Tidy hashmap dependency
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/[email protected]/
Signed-off-by Ian Rogers <[email protected]>
--- 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(-)
tools/perf/util/bpf-loader.c +5 -1
@@ -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>
tools/perf/util/evsel.c +5 -1
@@ -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"
tools/perf/util/expr.h +4 -7
@@ -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 ;
tools/perf/util/stat.c +5 -1
@@ -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)
Signature · 1 line
2.37.2.609.g9ff673ca1a-goog
Em Tue, Aug 23, 2022 at 10:06:04PM -0700, Ian Rogers escreveu:
Quoted 5 lines
When libbpf is present the build uses definitions in libbpf
hashmap.c, however, libbpf'shashmap.hwasn't being used. Switch to using the correcthashmap.hdependent on the defineHAVE_LIBBPF_SUPPORT. This was the original intent in:
https://lore.kernel.org/lkml/[email protected]/
Thanks, applied.
- Arnaldo
Quoted 84 lines
Signed-off-by Ian Rogers <[email protected]>--- 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(-)tools/perf/util/bpf-loader.c +5
-1@@ -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> tools/perf/util/evsel.c +5
-1@@ -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" tools/perf/util/expr.h +4
-7@@ -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 ;tools/perf/util/stat.c +5
-1@@ -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)Signature · 1 line
2.37.2.609.g9ff673ca1a-goog
Signature · 1 line
- Arnaldo