From: Oleg Nesterov <oleg@redhat.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
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@fomichev.me>, Hao Luo <haoluo@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCHv4 02/14] uprobe: Add support for session consumer
Date: Sun, 22 Sep 2024 17:27:23 +0200 [thread overview]
Message-ID: <20240922152722.GA12833@redhat.com> (raw)
In-Reply-To: <Zul7UCsftY_ZX6wT@krava>
Damn, sorry for delay :/
And sorry, still can't understand, see below...
On 09/17, Jiri Olsa wrote:
>
> On Tue, Sep 17, 2024 at 02:03:17PM +0200, Oleg Nesterov wrote:
> >
> > To me this code should do:
> >
> > if (!uc->ret_handler || UPROBE_HANDLER_REMOVE || UPROBE_HANDLER_IGNORE)
> > continue;
> >
> > if (!ri)
> > ri = alloc_return_instance();
> >
> > if (rc == UPROBE_HANDLER_IWANTMYCOOKIE)
> > ri = push_consumer(...);
> >
> > And,
> >
> > > handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs)
> > ...
> > > list_for_each_entry_srcu(uc, &uprobe->consumers, cons_node,
> > > srcu_read_lock_held(&uprobes_srcu)) {
> > > + ric = return_consumer_find(ri, &ric_idx, uc->id);
> > > + if (ric && ric->rc == UPROBE_HANDLER_IGNORE)
> > > + continue;
> > > if (uc->ret_handler)
> > > - uc->ret_handler(uc, ri->func, regs);
> > > + uc->ret_handler(uc, ri->func, regs, ric ? &ric->cookie : NULL);
> > > }
> >
> > the UPROBE_HANDLER_IGNORE check above and the new ric->rc member should die,
> >
> > if (!uc->ret_handler)
> > continue;
> >
> > ric = return_consumer_find(...);
> > uc->ret_handler(..., ric ? &ric->cookie : NULL);
> >
> > as we have already discussed, the session ret_handler(data) can simply do
> >
> > // my ->handler() wasn't called or it didn't return
> > // UPROBE_HANDLER_IWANTMYCOOKIE
> > if (!data)
> > return;
> >
> > at the start.
> >
> > Could you explain why this can't work?
>
> I'll try ;-) it's for the case when consumer does not use UPROBE_HANDLER_IWANTMYCOOKIE
>
> let's have 2 consumers on single uprobe, consumer-A returning UPROBE_HANDLER_IGNORE
> and the consumer-B returning zero, so we want the return uprobe installed, but we
> want just consumer-B to be executed
>
> - so uprobe gets installed and handle_uretprobe_chain goes over all consumers
> calling ret_handler callback
>
> - but we don't know consumer-A needs to be ignored, and it does not
> expect cookie so we have no way to find out it needs to be ignored
How does this differ from the case when consumer-A returns _REMOVE but another
consumer returns 0?
But what I really can't understand is
and it does not
expect cookie so we have no way to find out it needs to be ignored
If we change the code as I suggested above, push_consumer() won't be called
if consumer-A returns UPROBE_HANDLER_IGNORE.
This means that handle_uretprobe_chain() -> return_consumer_find() will
return NULL, so handle_uretprobe_chain() won't pass the valid cookie to
consumer-A's ret_handler callback, it will pass data => NULL.
So, again, why can't consumer-A's ret_handler callback do
// my ->handler() wasn't called or it didn't return
// UPROBE_HANDLER_IWANTMYCOOKIE
if (!data)
return;
at the start?
Why the UPROBE_HANDLER_IGNORE case is more problematic than the
UPROBE_HANDLER_REMOVE case?
Oleg.
next prev parent reply other threads:[~2024-09-22 15:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 8:50 [PATCHv4 00/14] uprobe, bpf: Add session support Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 01/14] uprobe: Add data pointer to consumer handlers Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 02/14] uprobe: Add support for session consumer Jiri Olsa
2024-09-17 12:03 ` Oleg Nesterov
2024-09-17 12:51 ` Jiri Olsa
2024-09-22 15:27 ` Oleg Nesterov [this message]
2024-09-23 8:05 ` Jiri Olsa
2024-09-23 10:05 ` Oleg Nesterov
2024-09-23 11:02 ` Jiri Olsa
2024-09-23 12:13 ` Oleg Nesterov
2024-09-17 12:22 ` Oleg Nesterov
2024-09-17 8:50 ` [PATCHv4 03/14] bpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 04/14] bpf: Add support for uprobe multi session context Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 05/14] bpf: Allow return values 0 and 1 for uprobe/kprobe session Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 06/14] libbpf: Fix uretprobe.multi.s programs auto attachment Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 07/14] libbpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 08/14] selftests/bpf: Add uprobe session test Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 09/14] selftests/bpf: Add uprobe session cookie test Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 10/14] selftests/bpf: Add uprobe session recursive test Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 11/14] selftests/bpf: Add uprobe session verifier test for return value Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 12/14] selftests/bpf: Add kprobe " Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 13/14] selftests/bpf: Add uprobe session single consumer test Jiri Olsa
2024-09-17 8:50 ` [PATCHv4 14/14] selftests/bpf: Add consumers stress test on single uprobe Jiri Olsa
2024-09-23 8:34 ` [PATCHv4 00/14] uprobe, bpf: Add session support patchwork-bot+netdevbpf
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=20240922152722.GA12833@redhat.com \
--to=oleg@redhat.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=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=olsajiri@gmail.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--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 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).