From: Jiri Olsa <olsajiri@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: Re: [RFC/PATCH bpf-next 01/20] bpf: Add multi uprobe link
Date: Tue, 25 Apr 2023 11:54:57 +0200 [thread overview]
Message-ID: <ZEejcYDRbxDGebAr@krava> (raw)
In-Reply-To: <20230424221120.h3vdmuehxi33st4n@dhcp-172-26-102-232.dhcp.thefacebook.com>
On Mon, Apr 24, 2023 at 03:11:20PM -0700, Alexei Starovoitov wrote:
> On Mon, Apr 24, 2023 at 06:04:28PM +0200, Jiri Olsa wrote:
> > +
> > +static int uprobe_prog_run(struct bpf_uprobe *uprobe,
> > + unsigned long entry_ip,
> > + struct pt_regs *regs)
> > +{
> > + struct bpf_uprobe_multi_link *link = uprobe->link;
> > + struct bpf_uprobe_multi_run_ctx run_ctx = {
> > + .entry_ip = entry_ip,
> > + };
> > + struct bpf_run_ctx *old_run_ctx;
> > + int err;
> > +
> > + preempt_disable();
>
> preempt_disable? Which year is this? :)
> Let's allow sleepable from the start.
> See bpf_prog_run_array_sleepable.
ok, we should probably add also 'multi.uprobe.s' section so the program
gets loaded with the BPF_F_SLEEPABLE flag.. or maybe we can enable that
by default for 'multi.uprobe' section
>
> Other than this the set looks great.
>
> > +
> > + if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
> > + err = 0;
> > + goto out;
> > + }
> > +
> > + rcu_read_lock();
> > + old_run_ctx = bpf_set_run_ctx(&run_ctx.run_ctx);
> > + err = bpf_prog_run(link->link.prog, regs);
> > + bpf_reset_run_ctx(old_run_ctx);
> > + rcu_read_unlock();
> > +
> > + out:
> > + __this_cpu_dec(bpf_prog_active);
> > + preempt_enable();
> > + return err;
> ...
> > + struct path path;
> > + char *name;
> > +
> > + name = strndup_user(upath, PATH_MAX);
> > + if (IS_ERR(name)) {
> > + err = PTR_ERR(name);
> > + goto error;
> > + }
> > + err = kern_path(name, LOOKUP_FOLLOW, &path);
> > + kfree(name);
> > + if (err)
> > + goto error;
> > + if (!d_is_reg(path.dentry)) {
> > + err = -EINVAL;
> > + path_put(&path);
> > + goto error;
> > + }
> > + inode = d_real_inode(path.dentry);
> > + path_put(&path);
>
> inode won't disappear between here and its use in uprobe_register_refctr ?
ugh, that's bug.. will fix
thanks,
jirka
>
> > + }
> > + old_upath = upath;
> > +
> > + uprobes[i].inode = inode;
> > + uprobes[i].offset = offset;
> > + uprobes[i].ref_ctr_offset = ref_ctr_offset;
> > + uprobes[i].link = link;
> > +
> > + if (flags & BPF_F_UPROBE_MULTI_RETURN)
> > + uprobes[i].consumer.ret_handler = uprobe_multi_link_ret_handler;
> > + else
> > + uprobes[i].consumer.handler = uprobe_multi_link_handler;
> > + }
> > +
> > + link->cnt = cnt;
> > + link->uprobes = uprobes;
> > +
> > + bpf_link_init(&link->link, BPF_LINK_TYPE_UPROBE_MULTI,
> > + &bpf_uprobe_multi_link_lops, prog);
> > +
> > + err = bpf_link_prime(&link->link, &link_primer);
> > + if (err)
> > + goto error;
> > +
> > + for (i = 0; i < cnt; i++) {
> > + err = uprobe_register_refctr(uprobes[i].inode, uprobes[i].offset,
> > + uprobes[i].ref_ctr_offset,
> > + &uprobes[i].consumer);
next prev parent reply other threads:[~2023-04-25 9:55 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 16:04 [RFC/PATCH bpf-next 00/20] bpf: Add multi uprobe link Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 01/20] " Jiri Olsa
2023-04-24 22:11 ` Alexei Starovoitov
2023-04-25 9:54 ` Jiri Olsa [this message]
2023-04-26 19:01 ` Andrii Nakryiko
2023-04-27 13:15 ` Jiri Olsa
2023-04-25 23:56 ` Yonghong Song
2023-04-26 7:37 ` Jiri Olsa
2023-04-26 19:00 ` Andrii Nakryiko
2023-04-27 13:14 ` Jiri Olsa
2023-04-26 19:17 ` Andrii Nakryiko
2023-04-27 13:15 ` Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 02/20] bpf: Add cookies support for uprobe_multi link Jiri Olsa
2023-04-26 0:03 ` Yonghong Song
2023-04-26 19:13 ` Andrii Nakryiko
2023-04-27 12:58 ` Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 03/20] bpf: Add bpf_get_func_ip helper support for uprobe link Jiri Olsa
2023-04-26 19:11 ` Andrii Nakryiko
2023-04-27 12:45 ` Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 04/20] libbpf: Update uapi bpf.h tools header Jiri Olsa
2023-04-26 19:14 ` Andrii Nakryiko
2023-04-27 12:58 ` Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 05/20] libbpf: Add uprobe_multi attach type and link names Jiri Olsa
2023-04-26 19:14 ` Andrii Nakryiko
2023-04-24 16:04 ` [RFC/PATCH bpf-next 06/20] libbpf: Factor elf_for_each_symbol function Jiri Olsa
2023-04-26 19:27 ` Andrii Nakryiko
2023-04-27 13:23 ` Jiri Olsa
2023-04-27 22:28 ` Andrii Nakryiko
2023-04-24 16:04 ` [RFC/PATCH bpf-next 07/20] libbpf: Add elf_find_multi_func_offset function Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 08/20] libbpf: Add elf_find_patern_func_offset function Jiri Olsa
2023-04-26 19:24 ` Andrii Nakryiko
2023-04-27 13:21 ` Jiri Olsa
2023-04-27 22:29 ` Andrii Nakryiko
2023-04-24 16:04 ` [RFC/PATCH bpf-next 09/20] libbpf: Add bpf_link_create support for multi uprobes Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 10/20] libbpf: Add bpf_program__attach_uprobe_multi_opts function Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 11/20] libbpf: Add support for uprobe.multi/uprobe.multi program sections Jiri Olsa
2023-04-26 19:31 ` Andrii Nakryiko
2023-04-24 16:04 ` [RFC/PATCH bpf-next 12/20] libbpf: Add uprobe multi link support to bpf_program__attach_usdt Jiri Olsa
2023-04-26 19:32 ` Andrii Nakryiko
2023-04-24 16:04 ` [RFC/PATCH bpf-next 13/20] selftests/bpf: Add uprobe_multi skel test Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 14/20] selftests/bpf: Add uprobe_multi api test Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 15/20] selftests/bpf: Add uprobe_multi link test Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 16/20] selftests/bpf: Add uprobe_multi test program Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 17/20] selftests/bpf: Add uprobe_multi bench test Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 18/20] selftests/bpf: Add usdt_multi test program Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 19/20] selftests/bpf: Add usdt_multi bench test Jiri Olsa
2023-04-24 16:04 ` [RFC/PATCH bpf-next 20/20] selftests/bpf: Add uprobe_multi cookie test Jiri Olsa
2023-04-26 19:09 ` [RFC/PATCH bpf-next 00/20] bpf: Add multi uprobe link Andrii Nakryiko
2023-04-27 12:44 ` Jiri Olsa
2023-04-27 22:24 ` Andrii Nakryiko
2023-04-28 10:55 ` Jiri Olsa
2023-04-28 21:19 ` Andrii Nakryiko
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=ZEejcYDRbxDGebAr@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.