From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>,
Ian Rogers <irogers@google.com>,
"linux-perf-use." <linux-perf-users@vger.kernel.org>,
Christy Lee <christylee@fb.com>,
Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH 1/3] perf/bpf: Remove prologue generation
Date: Mon, 14 Feb 2022 09:33:21 +0100 [thread overview]
Message-ID: <YgoT0aUdxOfRSJ/s@krava> (raw)
In-Reply-To: <CAEf4BzZO7ZZZv5bdUYY2Fzp0m05gWE9o62Y8=uAuJmUmWsD_hw@mail.gmail.com>
On Sun, Feb 13, 2022 at 09:57:15PM -0800, Andrii Nakryiko wrote:
> On Sun, Feb 13, 2022 at 7:02 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Thu, Feb 10, 2022 at 09:28:51PM -0800, Andrii Nakryiko wrote:
> > > On Thu, Feb 10, 2022 at 1:31 PM Jiri Olsa <olsajiri@gmail.com> wrote:
> > > >
> > > > On Thu, Feb 10, 2022 at 04:18:10PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > > Em Sun, Jan 23, 2022 at 11:19:30PM +0100, Jiri Olsa escreveu:
> > > > > > Removing code for ebpf program prologue generation.
> > > > > >
> > > > > > The prologue code was used to get data for extra arguments specified
> > > > > > in program section name, like:
> > > > > >
> > > > > > SEC("lock_page=__lock_page page->flags")
> > > > > > int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
> > > > > > {
> > > > > > return 1;
> > > > > > }
> > > > > >
> > > > > > This code is using deprecated libbpf API and blocks its removal.
> > > > > >
> > > > > > This feature was not documented and broken for some time without
> > > > > > anyone complaining, also original authors are not responding,
> > > > > > so I'm removing it.
> > > > >
> > > > > So, the example below breaks, how hard would be to move the deprecated
> > > > > APIs to perf like was done in some other cases?
> > > > >
> > >
> > > Just copy/pasting libbpf code won't work. But there are three parts:
> > >
> > > 1. bpf_(program|map|object)__set_priv(). There is no equivalent API,
> > > but perf can maintain this private data by building hashmap where the
> > > key is bpf_object/bpf_map/bpf_program pointer itself. Annoying but
> > > very straightforward to replace.
> > >
> > > 2. For prologue generation, bpf_program__set_prep() doesn't have a
> > > direct equivalent. But program cloning and adjustment of the code can
> > > be achieved through bpf_program__insns()/bpf_program__insn_cnt() API
> > > to load one "prototype" program, gets its underlying insns and clone
> > > programs as necessary. After that, bpf_prog_load() would be used to
> > > load those cloned programs into kernel.
> >
> > hm, I can't see how to clone a program.. so we need to end up with
> > several copies of the single program defined in the object.. I can
> > get its intructions with bpf_program__insns, but how do I add more
> > programs with these instructions customized/prefixed?
>
> You can't add those clones back to bpf_object, of course. But after
> grabbing (and modifying) instructions, you can use bpf_prog_load()
> low-level API to create BPF programs and get their FDs back. You'll
> have to keep track of those prog FDs separately from libbpf' struct
> bpf_object.
ok so loaded on the side with bpf_prog_load
thanks,
jirka
next prev parent reply other threads:[~2022-02-14 8:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-23 22:19 [PATCH 1/3] perf/bpf: Remove prologue generation Jiri Olsa
2022-01-23 22:19 ` [PATCH 2/3] perf/bpf: Remove special bpf config support Jiri Olsa
2022-01-23 22:19 ` [PATCH 3/3] perf tests: Remove bpf prologue generation test Jiri Olsa
2022-01-24 20:24 ` [PATCH 1/3] perf/bpf: Remove prologue generation Andrii Nakryiko
2022-02-02 1:01 ` Andrii Nakryiko
2022-02-02 10:08 ` Arnaldo Carvalho de Melo
2022-02-02 17:21 ` Andrii Nakryiko
2022-02-10 19:18 ` Arnaldo Carvalho de Melo
2022-02-10 21:30 ` Jiri Olsa
2022-02-11 5:28 ` Andrii Nakryiko
2022-02-13 15:02 ` Jiri Olsa
2022-02-14 5:57 ` Andrii Nakryiko
2022-02-14 8:33 ` Jiri Olsa [this message]
2022-02-14 6:02 ` Andrii Nakryiko
2022-02-14 8:16 ` Jiri Olsa
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=YgoT0aUdxOfRSJ/s@krava \
--to=olsajiri@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christylee@fb.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--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).