From: Menglong Dong <menglong.dong@linux.dev>
To: Menglong Dong <menglong8.dong@gmail.com>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, davem@davemloft.net, dsahern@kernel.org,
tglx@linutronix.de, mingo@redhat.com, jiang.biao@linux.dev,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com, bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v10 00/12] bpf: fsession support
Date: Thu, 22 Jan 2026 10:49:35 +0800 [thread overview]
Message-ID: <2026435.PYKUYFuaPT@7940hx> (raw)
In-Reply-To: <CAEf4BzZX+hDww=MvMrqx3h9uKdB+Sef8rVMxrvxcm+9jj7MUjg@mail.gmail.com>
On 2026/1/22 08:09 Andrii Nakryiko <andrii.nakryiko@gmail.com> write:
> On Thu, Jan 15, 2026 at 3:23 AM Menglong Dong <menglong8.dong@gmail.com> wrote:
> >
> > Hi, all.
> >
> > In this version, I followed Andrii's suggestions in v9, and did many
> > adjustment.
> >
> > overall
> > -------
> > Sometimes, we need to hook both the entry and exit of a function with
> > TRACING. Therefore, we need define a FENTRY and a FEXIT for the target
> > function, which is not convenient.
> >
> > Therefore, we add a tracing session support for TRACING. Generally
> > speaking, it's similar to kprobe session, which can hook both the entry
> > and exit of a function with a single BPF program.
> >
> > We allow the usage of bpf_get_func_ret() to get the return value in the
> > fentry of the tracing session, as it will always get "0", which is safe
> > enough and is OK.
> >
> > Session cookie is also supported with the kfunc bpf_session_cookie().
> > In order to limit the stack usage, we limit the maximum number of cookies
> > to 4.
> >
> > kfunc design
> > ------------
> > In order to keep consistency with existing kfunc, we don't introduce new
> > kfunc for fsession. Instead, we reuse the existing kfunc
> > bpf_session_cookie() and bpf_session_is_return().
> >
> > The prototype of bpf_session_cookie() and bpf_session_is_return() don't
> > satisfy our needs, so we change their prototype by adding the argument
> > "void *ctx" to them.
> >
> > We inline bpf_session_cookie() and bpf_session_is_return() for fsession
> > in the verifier directly. Therefore, we don't need to introduce new
> > functions for them.
> >
> > architecture
> > ------------
> > The fsession stuff is arch related, so the -EOPNOTSUPP will be returned if
> > it is not supported yet by the arch. In this series, we only support
> > x86_64. And later, other arch will be implemented.
> >
> > Changes v9 -> v10:
> > * 1st patch: some small adjustment, such as use switch in
> > bpf_prog_has_trampoline()
> > * 2nd patch: some adjustment to the commit log and comment
> > * 3rd patch:
> > - drop the declaration of bpf_session_is_return() and
> > bpf_session_cookie()
> > - use vmlinux.h instead of bpf_kfuncs.h in uprobe_multi_session.c,
> > kprobe_multi_session_cookie.c and uprobe_multi_session_cookie.c
> > * 4th patch:
> > - some adjustment to the comment and commit log
> > - rename the prefix from BPF_TRAMP_M_ tp BPF_TRAMP_SHIFT_
>
> This is minor nit, but I think BPF_TRAMP_IS_RETURN_SHIFT and
> BPF_TRAMP_COOKIE_INDEX_SHIFT (note added INDEX, because that's what we
> store, not the cookie itself) makes more sense naming-wise and is more
> natural to read. Consider updating this.
Yeah, looks nice.
>
> > - remove the definition of BPF_TRAMP_M_NR_ARGS
> > - check the program type in bpf_session_filter()
> > * 5th patch: some adjustment to the commit log
> > * 6th patch:
> > - add the "reg" to the function arguments of emit_store_stack_imm64()
> > - use the positive offset in emit_store_stack_imm64()
> > * 7th patch:
> > - use "|" for func_meta instead of "+"
> > - pass the "func_meta_off" to invoke_bpf() explicitly, instead of
> > computing it with "stack_size + 8"
> > - pass the "cookie_off" to invoke_bpf() instead of computing the current
> > cookie index with "func_meta"
> > * 8th patch:
> > - split the modification to bpftool to a separate patch
> > * v9: https://lore.kernel.org/bpf/20260110141115.537055-1-dongml2@chinatelecom.cn/
> >
>
> Overall this looks great, I was actually trying to apply and push it
> despite those minor nits I left. But unfortunately there is some
> conflict, so you'll have to rebase and resend. Hopefully just one last
> time :)
Haha, sounds great! I'll follow your comment and rebase, and
send the next version later.
Thanks you the review ;)
>
> > Changes v8 -> v9:
> > * remove the definition of bpf_fsession_cookie and bpf_fsession_is_return
> > in the 4th and 5th patch
> > * rename emit_st_r0_imm64() to emit_store_stack_imm64() in the 6th patch
> > * v8: https://lore.kernel.org/bpf/20260108022450.88086-1-dongml2@chinatelecom.cn/
> >
[...]
> >
>
prev parent reply other threads:[~2026-01-22 2:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:22 [PATCH bpf-next v10 00/12] bpf: fsession support Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 01/12] bpf: add " Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 02/12] bpf: use the least significant byte for the nr_args in trampoline Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 03/12] bpf: change prototype of bpf_session_{cookie,is_return} Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 04/12] bpf: support fsession for bpf_session_is_return Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 05/12] bpf: support fsession for bpf_session_cookie Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 06/12] bpf,x86: introduce emit_store_stack_imm64() for trampoline Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 07/12] bpf,x86: add fsession support for x86_64 Menglong Dong
2026-01-22 0:06 ` Andrii Nakryiko
2026-01-22 0:22 ` Andrii Nakryiko
2026-01-22 2:41 ` Menglong Dong
2026-01-22 16:57 ` Andrii Nakryiko
2026-01-15 11:22 ` [PATCH bpf-next v10 08/12] libbpf: add fsession support Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 09/12] bpftool: " Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 10/12] selftests/bpf: add testcases for fsession Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 11/12] selftests/bpf: add testcases for fsession cookie Menglong Dong
2026-01-22 0:07 ` Andrii Nakryiko
2026-01-22 2:18 ` Menglong Dong
2026-01-15 11:22 ` [PATCH bpf-next v10 12/12] selftests/bpf: test fsession mixed with fentry and fexit Menglong Dong
2026-01-22 0:09 ` [PATCH bpf-next v10 00/12] bpf: fsession support Andrii Nakryiko
2026-01-22 2:49 ` Menglong Dong [this message]
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=2026435.PYKUYFuaPT@7940hx \
--to=menglong.dong@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hpa@zytor.com \
--cc=jiang.biao@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong8.dong@gmail.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yonghong.song@linux.dev \
/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.