From: Jiri Olsa <jolsa@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
Martin KaFai Lau <kafai@fb.com>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
David Miller <davem@redhat.com>,
bjorn.topel@intel.com
Subject: Re: [PATCH 5/5] bpf: Allow to resolve bpf trampoline in unwind
Date: Tue, 7 Jan 2020 14:15:54 +0100 [thread overview]
Message-ID: <20200107131554.GJ290055@krava> (raw)
In-Reply-To: <fab5466e-95e7-8abf-c416-6a6f7b7151ba@iogearbox.net>
On Tue, Jan 07, 2020 at 09:30:12AM +0100, Daniel Borkmann wrote:
> On 1/7/20 12:46 AM, Alexei Starovoitov wrote:
> > On Sun, Dec 29, 2019 at 03:37:40PM +0100, Jiri Olsa wrote:
> > > When unwinding the stack we need to identify each
> > > address to successfully continue. Adding latch tree
> > > to keep trampolines for quick lookup during the
> > > unwind.
> > >
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ...
> > > +bool is_bpf_trampoline(void *addr)
> > > +{
> > > + return latch_tree_find(addr, &tree, &tree_ops) != NULL;
> > > +}
> > > +
> > > struct bpf_trampoline *bpf_trampoline_lookup(u64 key)
> > > {
> > > struct bpf_trampoline *tr;
> > > @@ -65,6 +98,7 @@ struct bpf_trampoline *bpf_trampoline_lookup(u64 key)
> > > for (i = 0; i < BPF_TRAMP_MAX; i++)
> > > INIT_HLIST_HEAD(&tr->progs_hlist[i]);
> > > tr->image = image;
> > > + latch_tree_insert(&tr->tnode, &tree, &tree_ops);
> >
> > Thanks for the fix. I was thinking to apply it, but then realized that bpf
> > dispatcher logic has the same issue.
> > Could you generalize the fix for both?
> > May be bpf_jit_alloc_exec_page() can do latch_tree_insert() ?
> > and new version of bpf_jit_free_exec() is needed that will do latch_tree_erase().
> > Wdyt?
>
> Also this patch is buggy since your latch lookup happens under RCU, but
> I don't see anything that waits a grace period once you remove from the
> tree. Instead you free the trampoline right away.
thanks, did not think of that.. will (try to) fix ;-)
>
> On a different question, given we have all the kallsym infrastructure
> for BPF already in place, did you look into whether it's feasible to
> make it a bit more generic to also cover JITed buffers from trampolines?
>
hum, it did not occur to me that we want to see it in kallsyms,
but sure.. how about: bpf_trampoline_<key> ?
key would be taken from bpf_trampoline::key as function's BTF id
jirka
next prev parent reply other threads:[~2020-01-07 13:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-29 14:37 [RFC 0/5] bpf: Add trampoline helpers Jiri Olsa
2019-12-29 14:37 ` [PATCH 1/5] bpf: Allow non struct type for btf ctx access Jiri Olsa
2020-01-06 21:36 ` Yonghong Song
2020-01-07 12:13 ` Jiri Olsa
2020-01-07 15:50 ` Jiri Olsa
2020-01-07 17:55 ` Yonghong Song
2020-01-07 18:28 ` Yonghong Song
2020-01-08 14:38 ` Jiri Olsa
2019-12-29 14:37 ` [PATCH 2/5] bpf: Add bpf_perf_event_output_kfunc Jiri Olsa
2020-01-06 23:27 ` Alexei Starovoitov
2020-01-07 12:25 ` Jiri Olsa
2020-01-07 22:13 ` Alexei Starovoitov
2020-01-08 10:24 ` Jiri Olsa
2019-12-29 14:37 ` [PATCH 3/5] bpf: Add bpf_get_stackid_kfunc Jiri Olsa
2019-12-29 14:37 ` [PATCH 4/5] bpf: Add bpf_get_stack_kfunc Jiri Olsa
2019-12-29 14:37 ` [PATCH 5/5] bpf: Allow to resolve bpf trampoline in unwind Jiri Olsa
2020-01-06 23:46 ` Alexei Starovoitov
2020-01-07 8:30 ` Daniel Borkmann
2020-01-07 13:15 ` Jiri Olsa [this message]
2020-01-07 19:30 ` Daniel Borkmann
2020-01-07 13:05 ` Jiri Olsa
2020-01-07 13:30 ` Björn Töpel
2020-01-13 9:43 ` Jiri Olsa
2020-01-13 12:21 ` Björn Töpel
2020-01-13 12:31 ` Björn Töpel
2020-01-13 12:37 ` Jiri Olsa
2020-02-03 19:58 ` Jiri Olsa
2020-02-03 20:27 ` Björn Töpel
2020-02-03 20:45 ` Toke Høiland-Jørgensen
2020-02-04 8:18 ` 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=20200107131554.GJ290055@krava \
--to=jolsa@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@redhat.com \
--cc=jakub.kicinski@netronome.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--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).