linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Avi Kivity <avi@scylladb.com>
Cc: linux-perf-users@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: Infinite recursion in `perf record`
Date: Tue, 17 May 2022 18:17:02 -0300	[thread overview]
Message-ID: <YoQQzm3b1kGkEeVQ@kernel.org> (raw)
In-Reply-To: <9f21cc03-f411-828d-7817-5d9570d43ba1@scylladb.com>

Em Tue, May 17, 2022 at 05:59:17PM +0300, Avi Kivity escreveu:
> 
> On 17/05/2022 17.52, Arnaldo Carvalho de Melo wrote:
> > Em Mon, May 16, 2022 at 06:22:35PM +0300, Avi Kivity escreveu:
> > > In bpf-event.c we have:
> > > 
> > > 
> > > struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
> > > {
> > >         struct btf *btf;
> > > #pragma GCC diagnostic push
> > > #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> > >         int err = btf__get_from_id(id, &btf);
> > > #pragma GCC diagnostic pop
> > > 
> > >         return err ? ERR_PTR(err) : btf;
> > > }
> > > 
> > > and in btf.c we have:
> > > int btf__get_from_id(__u32 id, struct btf **btf)
> > > {
> > >          struct btf *res;
> > >          int err;
> > > 
> > >          *btf = NULL;
> > >          res = btf__load_from_kernel_by_id(id);
> > >          err = libbpf_get_error(res);
> > > 
> > >          if (err)
> > >                  return libbpf_err(err);
> > > 
> > >          *btf = res;
> > >          return 0;
> > > }
> > > 
> > > Obviously, if the first weak symbol isn't overridden we get into an infinite
> > > recursion, which is what I see immediately on running perf record:
> > So the intent was to be able to dynamicly link with older and newer
> > libbpf versions, as btf__get_from_id() is being deprecated and
> > btf__load_from_kernel_by_id() isn't available in older libbpf versions.
> > 
> > This is all only when linking with the system's libbpf, not with the one
> > in tools/lib/bpf/, when perf does a static link.
> > 
> > So I think (will check) that your build is using LIBBPF_DYNAMIC=1, and
> > while there is a test build for that in 'make -C tools/perf build-test'.
> > 
> >           make_libbpf_dynamic_O: make LIBBPF_DYNAMIC=1
> > 
> > It will cover testing just with the libbpf-devel installed on the
> > tester's machine/container.
> > 
> > I couldn't find the perf build log, the link you provided:
> > 
> > https://kojipkgs.fedoraproject.org//packages/kernel/5.17.6/300.fc36/data/logs/x86_64/build.log
> 
> 
> This link should work:

> https://kojipkgs.fedoraproject.org//packages/kernel-tools/5.17.6/300.fc36/data/logs/x86_64/build.log

Thanks, I'll check.
 
> > is for the kernel, not tools/perf.
> > 
> > I agree with Ian I should have done this using ifdef, a
> > tools/build/feature check that tries to build a test app linking against
> > libbpf-devel with btf__load_from_kernel_by_id(), if it is there, then
> > use it directly, if not, implement it in terms of btf__get_from_id().
> > 
> > I'll try to use my unbroken fingers to do that 8-)
 
> Thanks, I hope it doesn't cause more damage.

Hopefully not :-)

- Arnaldo

      reply	other threads:[~2022-05-17 21:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 15:22 Infinite recursion in `perf record` Avi Kivity
2022-05-16 22:04 ` Ian Rogers
2022-05-17 13:23   ` Avi Kivity
2022-05-17 14:52 ` Arnaldo Carvalho de Melo
2022-05-17 14:59   ` Avi Kivity
2022-05-17 21:17     ` Arnaldo Carvalho de Melo [this message]

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=YoQQzm3b1kGkEeVQ@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=avi@scylladb.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /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).