public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Menglong Dong <menglong.dong@linux.dev>
To: ast@kernel.org, andrii@kernel.org,
	Menglong Dong <menglong8.dong@gmail.com>
Cc: 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 v7 00/11] bpf: fsession support
Date: Wed, 07 Jan 2026 14:59:23 +0800	[thread overview]
Message-ID: <2815019.mvXUDI8C0e@7940hx> (raw)
In-Reply-To: <20260107064352.291069-1-dongml2@chinatelecom.cn>

On 2026/1/7 14:43 Menglong Dong <menglong8.dong@gmail.com> write:
> Hi, all.
> 
> No changes in this version, just a rebase to deal with conflicts.

Ah, this message is not correct. Pls see the change log part for
the changes of this version, which is:

Changes since v6:
* change the prototype of bpf_session_cookie() and bpf_session_is_return(),
  and reuse them instead of introduce new kfunc for fsession.

> 
> 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 introduce the function bpf_fsession_is_return() and
> bpf_fsession_cookie(), and change the calling to bpf_session_cookie() and
> bpf_session_is_return() to them in verifier for fsession.
> 
> 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 since v6:
> * change the prototype of bpf_session_cookie() and bpf_session_is_return(),
>   and reuse them instead of introduce new kfunc for fsession.
> 
> Changes since v5:
> * No changes in this version, just a rebase to deal with conflicts.
> 
> Changes since v4:
> * use fsession terminology consistently in all patches
> * 1st patch:
>   - use more explicit way in __bpf_trampoline_link_prog()
> * 4th patch:
>   - remove "cookie_cnt" in struct bpf_trampoline
> * 6th patch:
>   - rename nr_regs to func_md
>   - define cookie_off in a new line
> * 7th patch:
>   - remove the handling of BPF_TRACE_SESSION in legacy fallback path for
>     BPF_RAW_TRACEPOINT_OPEN
> 
> Changes since v3:
> * instead of adding a new hlist to progs_hlist in trampoline, add the bpf
>   program to both the fentry hlist and the fexit hlist.
> * introduce the 2nd patch to reuse the nr_args field in the stack to
>   store all the information we need(except the session cookies).
> * limit the maximum number of cookies to 4.
> * remove the logic to skip fexit if the fentry return non-zero.
> 
> Changes since v2:
> * squeeze some patches:
>   - the 2 patches for the kfunc bpf_tracing_is_exit() and
>     bpf_fsession_cookie() are merged into the second patch.
>   - the testcases for fsession are also squeezed.
> 
> * fix the CI error by move the testcase for bpf_get_func_ip to
>   fsession_test.c
> 
> Changes since v1:
> * session cookie support.
>   In this version, session cookie is implemented, and the kfunc
>   bpf_fsession_cookie() is added.
> 
> * restructure the layout of the stack.
>   In this version, the session stuff that stored in the stack is changed,
>   and we locate them after the return value to not break
>   bpf_get_func_ip().
> 
> * testcase enhancement.
>   Some nits in the testcase that suggested by Jiri is fixed. Meanwhile,
>   the testcase for get_func_ip and session cookie is added too.
> 
> Menglong Dong (11):
>   bpf: add fsession support
>   bpf: use last 8-bits for the nr_args in trampoline
>   bpf: change prototype of bpf_session_{cookie,is_return}
>   bpf: support fsession for bpf_session_is_return
>   bpf: support fsession for bpf_session_cookie
>   bpf,x86: introduce emit_st_r0_imm64() for trampoline
>   bpf,x86: add fsession support for x86_64
>   libbpf: add fsession support
>   selftests/bpf: add testcases for fsession
>   selftests/bpf: add testcases for fsession cookie
>   selftests/bpf: test fsession mixed with fentry and fexit
> 
>  arch/x86/net/bpf_jit_comp.c                   |  48 ++++-
>  include/linux/bpf.h                           |  40 ++++
>  include/uapi/linux/bpf.h                      |   1 +
>  kernel/bpf/btf.c                              |   2 +
>  kernel/bpf/syscall.c                          |  18 +-
>  kernel/bpf/trampoline.c                       |  53 ++++-
>  kernel/bpf/verifier.c                         |  79 +++++--
>  kernel/trace/bpf_trace.c                      |  50 +++--
>  net/bpf/test_run.c                            |   1 +
>  net/core/bpf_sk_storage.c                     |   1 +
>  tools/bpf/bpftool/common.c                    |   1 +
>  tools/include/uapi/linux/bpf.h                |   1 +
>  tools/lib/bpf/bpf.c                           |   1 +
>  tools/lib/bpf/libbpf.c                        |   3 +
>  tools/testing/selftests/bpf/bpf_kfuncs.h      |   4 +-
>  .../selftests/bpf/prog_tests/fsession_test.c  | 115 ++++++++++
>  .../bpf/prog_tests/tracing_failure.c          |   2 +-
>  .../selftests/bpf/progs/fsession_test.c       | 198 ++++++++++++++++++
>  .../bpf/progs/kprobe_multi_session_cookie.c   |  12 +-
>  .../bpf/progs/uprobe_multi_session.c          |   4 +-
>  .../bpf/progs/uprobe_multi_session_cookie.c   |  12 +-
>  .../progs/uprobe_multi_session_recursive.c    |   8 +-
>  22 files changed, 583 insertions(+), 71 deletions(-)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/fsession_test.c
>  create mode 100644 tools/testing/selftests/bpf/progs/fsession_test.c
> 
> -- 
> 2.52.0
> 
> 
> 





      parent reply	other threads:[~2026-01-07  6:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  6:43 [PATCH bpf-next v7 00/11] bpf: fsession support Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 01/11] bpf: add " Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 02/11] bpf: use last 8-bits for the nr_args in trampoline Menglong Dong
2026-01-07  7:11   ` bot+bpf-ci
2026-01-07  7:50     ` Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 03/11] bpf: change prototype of bpf_session_{cookie,is_return} Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 04/11] bpf: support fsession for bpf_session_is_return Menglong Dong
2026-01-07  7:11   ` bot+bpf-ci
2026-01-07  7:45     ` Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 05/11] bpf: support fsession for bpf_session_cookie Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 06/11] bpf,x86: introduce emit_st_r0_imm64() for trampoline Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 07/11] bpf,x86: add fsession support for x86_64 Menglong Dong
2026-01-07  7:11   ` bot+bpf-ci
2026-01-07  7:55     ` Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 08/11] libbpf: add fsession support Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 09/11] selftests/bpf: add testcases for fsession Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 10/11] selftests/bpf: add testcases for fsession cookie Menglong Dong
2026-01-07  6:43 ` [PATCH bpf-next v7 11/11] selftests/bpf: test fsession mixed with fentry and fexit Menglong Dong
2026-01-07  6:59 ` 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=2815019.mvXUDI8C0e@7940hx \
    --to=menglong.dong@linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox