linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.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>, LKML <linux-kernel@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 4/8] libbpf hashmap: Localize static hashmap__* symbols
Date: Fri, 15 May 2020 07:53:33 -0700	[thread overview]
Message-ID: <CAP-5=fXtXgnb4nrVtsoxQ6vj8YtzPicFsad6+jB5UUFqMzg4mw@mail.gmail.com> (raw)
In-Reply-To: <20200515142917.GT5583@kernel.org>

On Fri, May 15, 2020 at 7:29 AM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
> Em Fri, May 15, 2020 at 11:17:07AM +0200, Jiri Olsa escreveu:
> > On Thu, May 14, 2020 at 11:56:20PM -0700, Ian Rogers wrote:
> > > Localize the hashmap__* symbols in libbpf.a. To allow for a version in
> > > libapi.
> > >
> > > Before:
> > > $ nm libbpf.a
> > > ...
> > > 000000000002088a t hashmap_add_entry
> > > 000000000001712a t hashmap__append
> > > 0000000000020aa3 T hashmap__capacity
> > > 000000000002099c T hashmap__clear
> > > 00000000000208b3 t hashmap_del_entry
> > > 0000000000020fc1 T hashmap__delete
> > > 0000000000020f29 T hashmap__find
> > > 0000000000020c6c t hashmap_find_entry
> > > 0000000000020a61 T hashmap__free
> > > 0000000000020b08 t hashmap_grow
> > > 00000000000208dd T hashmap__init
> > > 0000000000020d35 T hashmap__insert
> > > 0000000000020ab5 t hashmap_needs_to_grow
> > > 0000000000020947 T hashmap__new
> > > 0000000000000775 t hashmap__set
> > > 00000000000212f8 t hashmap__set
> > > 0000000000020a91 T hashmap__size
> > > ...
> > >
> > > After:
> > > $ nm libbpf.a
> > > ...
> > > 000000000002088a t hashmap_add_entry
> > > 000000000001712a t hashmap__append
> > > 0000000000020aa3 t hashmap__capacity
> > > 000000000002099c t hashmap__clear
> > > 00000000000208b3 t hashmap_del_entry
> > > 0000000000020fc1 t hashmap__delete
> > > 0000000000020f29 t hashmap__find
> > > 0000000000020c6c t hashmap_find_entry
> > > 0000000000020a61 t hashmap__free
> > > 0000000000020b08 t hashmap_grow
> > > 00000000000208dd t hashmap__init
> > > 0000000000020d35 t hashmap__insert
> > > 0000000000020ab5 t hashmap_needs_to_grow
> > > 0000000000020947 t hashmap__new
> > > 0000000000000775 t hashmap__set
> > > 00000000000212f8 t hashmap__set
> > > 0000000000020a91 t hashmap__size
> > > ...
> >
> > I think this will break bpf selftests which use hashmap,
> > we need to find some other way to include this
> >
> > either to use it from libbpf directly, or use the api version
> > only if the libbpf is not compiled in perf, we could use
> > following to detect that:
> >
> >       CFLAGS += -DHAVE_LIBBPF_SUPPORT
> >       $(call detected,CONFIG_LIBBPF)
>
> And have it in tools/perf/util/ instead?
>
>
> - Arnaldo

*sigh*

$ make -C tools/testing/selftests/bpf test_hashmap
make: Entering directory
'/usr/local/google/home/irogers/kernel-trees/kernel.org/tip/tools/testing/s
elftests/bpf'
 BINARY   test_hashmap
/usr/bin/ld: /tmp/ccEGGNw5.o: in function `test_hashmap_generic':
/usr/local/google/home/irogers/kernel-trees/kernel.org/tip/tools/testing/selftests/bpf/test_hashmap.
c:61: undefined reference to `hashmap__new'
...

My preference was to make hashmap a sharable API in tools, to benefit
not just perf but say things like libsymbol, libperf, etc. Moving it
into perf and using conditional compilation is kinda gross but having
libbpf tests depend on libapi also isn't ideal I guess. It is tempting
to just cut a hashmap from fresh cloth to avoid this and to share
among tools/. I don't know if the bpf folks have opinions?

I'll do a v2 using conditional compilation to see how bad it looks.

Thanks,
Ian

  reply	other threads:[~2020-05-15 14:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15  6:56 [PATCH 0/8] Copy hashmap to libapi, use in perf expr Ian Rogers
2020-05-15  6:56 ` [PATCH 1/8] libbpf: Fix memory leak and possible double-free in hashmap__clear Ian Rogers
2020-05-15  6:56 ` [PATCH 2/8] libbpf hashmap: Remove unused #include Ian Rogers
2020-05-15  6:56 ` [PATCH 3/8] libbpf hashmap: Fix signedness warnings Ian Rogers
2020-05-15  6:56 ` [PATCH 4/8] libbpf hashmap: Localize static hashmap__* symbols Ian Rogers
2020-05-15  9:17   ` Jiri Olsa
2020-05-15 14:29     ` Arnaldo Carvalho de Melo
2020-05-15 14:53       ` Ian Rogers [this message]
2020-05-15 16:31         ` Arnaldo Carvalho de Melo
2020-05-15 16:59           ` Ian Rogers
2020-05-15  6:56 ` [PATCH 5/8] tools lib/api: Copy libbpf hashmap to libapi Ian Rogers
2020-05-15  6:56 ` [PATCH 6/8] perf test: Provide a subtest callback to ask for the reason for skipping a subtest Ian Rogers
2020-05-15  6:56 ` [PATCH 7/8] perf test: Improve pmu event metric testing Ian Rogers
2020-05-15  6:56 ` [PATCH 8/8] perf expr: Migrate expr ids table to a hashmap Ian Rogers

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='CAP-5=fXtXgnb4nrVtsoxQ6vj8YtzPicFsad6+jB5UUFqMzg4mw@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andriin@fb.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eranian@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).