From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>, Kajol Jain <kjain@linux.ibm.com>,
Andi Kleen <ak@linux.intel.com>,
John Garry <john.garry@huawei.com>,
Jin Yao <yao.jin@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Kim Phillips <kim.phillips@amd.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Leo Yan <leo.yan@linaro.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v3 7/7] perf expr: Migrate expr ids table to a hashmap
Date: Mon, 18 May 2020 12:45:05 -0300 [thread overview]
Message-ID: <20200518154505.GE24211@kernel.org> (raw)
In-Reply-To: <20200515221732.44078-8-irogers@google.com>
Em Fri, May 15, 2020 at 03:17:32PM -0700, Ian Rogers escreveu:
> Use a hashmap between a char* string and a double* value. While bpf's
> hashmap entries are size_t in size, we can't guarantee sizeof(size_t) >=
> sizeof(double). Avoid a memory allocation when gathering ids by making 0.0
> a special value encoded as NULL.
>
> Original map suggestion by Andi Kleen:
> https://lore.kernel.org/lkml/20200224210308.GQ160988@tassilo.jf.intel.com/
> and seconded by Jiri Olsa:
> https://lore.kernel.org/lkml/20200423112915.GH1136647@krava/
I'm having trouble here when building it with:
make -C tools/perf O=/tmp/build/perf
CC /tmp/build/perf/tests/expr.o
INSTALL trace_plugins
CC /tmp/build/perf/util/metricgroup.o
In file included from /home/acme/git/perf/tools/lib/bpf/hashmap.h:18,
from /home/acme/git/perf/tools/perf/util/expr.h:6,
from tests/expr.c:3:
/home/acme/git/perf/tools/lib/bpf/libbpf_internal.h:63: error: "pr_info" redefined [-Werror]
63 | #define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
|
In file included from tests/expr.c:2:
/home/acme/git/perf/tools/perf/util/debug.h:24: note: this is the location of the previous definition
It looks like libbpf's hashmap.h is being used instead of the one in
tools/perf/util/, yeah, as intended, but then since I don't have the
fixes you added to the BPF tree, the build fails, if I instead
unconditionally use
#include "util/hashmap.h"
It works. Please ack.
I.e. with the patch below, further tests:
[acme@five perf]$ perf -vv | grep -i bpf
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
[acme@five perf]$ nm ~/bin/perf | grep -i libbpf_ | wc -l
39
[acme@five perf]$ nm ~/bin/perf | grep -i hashmap_ | wc -l
17
[acme@five perf]$
Explicitely building without LIBBPF:
[acme@five perf]$ perf -vv | grep -i bpf
bpf: [ OFF ] # HAVE_LIBBPF_SUPPORT
[acme@five perf]$
[acme@five perf]$ nm ~/bin/perf | grep -i libbpf_ | wc -l
0
[acme@five perf]$ nm ~/bin/perf | grep -i hashmap_ | wc -l
9
[acme@five perf]$
Works,
- Arnaldo
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index d60a8feaf50b..8a2c1074f90f 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -2,11 +2,14 @@
#ifndef PARSE_CTX_H
#define PARSE_CTX_H 1
-#ifdef HAVE_LIBBPF_SUPPORT
-#include <bpf/hashmap.h>
-#else
-#include "hashmap.h"
-#endif
+// 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
+#include "util/hashmap.h"
+//#endif
struct expr_parse_ctx {
struct hashmap ids;
next prev parent reply other threads:[~2020-05-18 15:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 22:17 [PATCH v3 0/7] Copy hashmap to tools/perf/util, use in perf expr Ian Rogers
2020-05-15 22:17 ` [PATCH v3 1/7] libbpf: Fix memory leak and possible double-free in hashmap__clear Ian Rogers
2020-05-15 22:17 ` [PATCH v3 2/7] libbpf hashmap: Remove unused #include Ian Rogers
2020-05-15 22:17 ` [PATCH v3 3/7] libbpf hashmap: Fix signedness warnings Ian Rogers
2020-05-15 22:17 ` [PATCH v3 4/7] tools lib/api: Copy libbpf hashmap to tools/perf/util Ian Rogers
2020-05-15 22:17 ` [PATCH v3 5/7] perf test: Provide a subtest callback to ask for the reason for skipping a subtest Ian Rogers
2020-05-15 22:17 ` [PATCH v3 6/7] perf test: Improve pmu event metric testing Ian Rogers
2020-05-19 19:06 ` Arnaldo Carvalho de Melo
2020-05-19 20:15 ` Ian Rogers
2020-05-20 1:15 ` Arnaldo Carvalho de Melo
2020-05-20 2:34 ` Arnaldo Carvalho de Melo
2020-05-15 22:17 ` [PATCH v3 7/7] perf expr: Migrate expr ids table to a hashmap Ian Rogers
2020-05-18 15:45 ` Arnaldo Carvalho de Melo [this message]
2020-05-18 16:03 ` Ian Rogers
2020-05-18 16:06 ` Arnaldo Carvalho de Melo
2020-05-18 16:11 ` Arnaldo Carvalho de Melo
2020-05-18 16:29 ` Ian Rogers
2020-05-19 19:28 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200518154505.GE24211@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=john.fastabend@gmail.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=kan.liang@linux.intel.com \
--cc=kim.phillips@amd.com \
--cc=kjain@linux.ibm.com \
--cc=kpsingh@chromium.org \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yao.jin@linux.intel.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).