All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Song Liu <song@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, linux-perf-users@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>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpf: Return error for missed kprobe multi bpf program execution
Date: Wed, 8 Jan 2025 12:38:48 +0100	[thread overview]
Message-ID: <Z35jyGWboftcEPRF@krava> (raw)
In-Reply-To: <CAPhsuW5p9C+0oLbec=bxZPvoEuPpAbDzbyPRD95ucBP=7HbO8A@mail.gmail.com>

On Mon, Jan 06, 2025 at 02:26:22PM -0800, Song Liu wrote:
> On Mon, Jan 6, 2025 at 9:50 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > When kprobe multi bpf program can't be executed due to recursion check,
> > we currently return 0 (success) to fprobe layer where it's ignored for
> > standard kprobe multi probes.
> >
> > For kprobe session the success return value will make fprobe layer to
> > install return probe and try to execute it as well.
> >
> > But the return session probe should not get executed, because the entry
> > part did not run. FWIW the return probe bpf program most likely won't get
> > executed, because its recursion check will likely fail as well, but we
> > don't need to run it in the first place.. also we can make this clear
> > and obvious.
> >
> > It also affects missed counts for kprobe session program execution, which
> > are now doubled (extra count for not executed return probe).
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  kernel/trace/bpf_trace.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> > index 48db147c6c7d..1f3d4b72a3f2 100644
> > --- a/kernel/trace/bpf_trace.c
> > +++ b/kernel/trace/bpf_trace.c
> > @@ -2797,7 +2797,7 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,
> >
> >         if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
> >                 bpf_prog_inc_misses_counter(link->link.prog);
> > -               err = 0;
> > +               err = 1;
> 
> nit: Shall we return -EBUSY or some other error code?

it's processed in __fprobe_handler and it's treated as bool, so technically
it does not matter.. but I'd rather keep the 0/1 return values in here,
because it's what the session program is forced to return

thanks,
jirka

  reply	other threads:[~2025-01-08 11:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06 17:50 [PATCH bpf-next 1/2] bpf: Return error for missed kprobe multi bpf program execution Jiri Olsa
2025-01-06 17:50 ` [PATCH bpf-next 2/2] selftests/bpf: Add kprobe session recursion check test Jiri Olsa
2025-01-06 22:26 ` [PATCH bpf-next 1/2] bpf: Return error for missed kprobe multi bpf program execution Song Liu
2025-01-08 11:38   ` Jiri Olsa [this message]
2025-01-08 20:56     ` Song Liu
2025-01-06 22:42 ` Masami Hiramatsu
2025-01-08 17:50 ` 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=Z35jyGWboftcEPRF@krava \
    --to=olsajiri@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=linux-perf-users@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --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.