public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Emil Tsalapatis <emil@etsalapatis.com>, bpf@vger.kernel.org
Cc: andrii@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	eddyz87@gmail.com, etsal@meta.com, ihor.solodrai@linux.dev,
	martin.lau@kernel.org, memxor@gmail.com, puranjay@kernel.org,
	song@kernel.org, yonghong.song@linux.dev
Subject: Re: [PATCH v2 01/13] bpf: Add bpf_stream_print_stack stack dumping kfunc
Date: Tue, 27 Jan 2026 19:17:49 +0000	[thread overview]
Message-ID: <8fa34825-ea90-48e7-82c8-00cf4c7375de@gmail.com> (raw)
In-Reply-To: <20260127181610.86376-2-emil@etsalapatis.com>

On 1/27/26 18:15, Emil Tsalapatis wrote:
> From: Emil Tsalapatis <etsal@meta.com>
>
> Add a new kfunc called bpf_stream_print_stack to be used by programs
> that need to print out their current BPF stack. The kfunc is essentially
> a wrapper around the existing bpf_stream_dump_stack functionality used
> to generate stack traces for error events like may_goto violations and
> BPF-side arena page faults.
>
> Signed-off-by: Emil Tsalapatis (Meta) <emil@etsalapatis.com>
> ---
>   kernel/bpf/helpers.c        |  1 +
>   kernel/bpf/stream.c         | 13 +++++++++++++
>   tools/lib/bpf/bpf_helpers.h |  2 ++
>   3 files changed, 16 insertions(+)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index b54ec0e945aa..c30a9f68af6b 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -4562,6 +4562,7 @@ BTF_ID_FLAGS(func, bpf_strncasestr);
>   BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
>   #endif
>   BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_IMPLICIT_ARGS)
> +BTF_ID_FLAGS(func, bpf_stream_print_stack, KF_IMPLICIT_ARGS)
>   BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_IMPLICIT_ARGS)
>   BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_IMPLICIT_ARGS)
>   BTF_ID_FLAGS(func, bpf_dynptr_from_file)
> diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c
> index 24730df55e69..6e2cbe5f34e7 100644
> --- a/kernel/bpf/stream.c
> +++ b/kernel/bpf/stream.c
> @@ -245,6 +245,19 @@ __bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const vo
>   	return ret;
>   }
>   
> +/* Directly trigger a stack dump from the program. */
> +__bpf_kfunc void bpf_stream_print_stack(struct bpf_prog_aux *aux)
> +{
> +	struct bpf_stream_stage ss;
> +	struct bpf_prog *prog;
> +
> +	prog = aux->main_prog_aux->prog;
> +
> +	bpf_stream_stage(ss, prog, BPF_STDERR, ({
> +		bpf_stream_dump_stack(ss);
> +	}));
> +}
> +
>   __bpf_kfunc_end_defs();
>   
>   /* Added kfunc to common_btf_ids */
> diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> index c145da05a67c..6d8ae3887618 100644
> --- a/tools/lib/bpf/bpf_helpers.h
> +++ b/tools/lib/bpf/bpf_helpers.h
> @@ -343,6 +343,8 @@ extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *a
>   /* Helper macro to print out debug messages */
>   #define bpf_printk(fmt, args...) ___bpf_pick_printk(args)(fmt, ##args)
>   
> +extern void bpf_stream_print_stack(void) __weak __ksym;
> +
Is this needed? bpf_stream_print_stack() should be available via 
vmlinux.h, shouldn't it?
>   struct bpf_iter_num;
>   
>   extern int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end) __weak __ksym;


  reply	other threads:[~2026-01-27 19:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 18:15 [PATCH v2 00/13] bpf: Add arena ASAN runtime and BPF library Emil Tsalapatis
2026-01-27 18:15 ` [PATCH v2 01/13] bpf: Add bpf_stream_print_stack stack dumping kfunc Emil Tsalapatis
2026-01-27 19:17   ` Mykyta Yatsenko [this message]
2026-01-27 23:23     ` Emil Tsalapatis
2026-01-27 23:53   ` Kumar Kartikeya Dwivedi
2026-01-27 18:15 ` [PATCH v2 02/13] bpf: Allow BPF stream kfuncs while holding a lock Emil Tsalapatis
2026-01-28  0:01   ` Kumar Kartikeya Dwivedi
2026-01-27 18:15 ` [PATCH v2 03/13] selftests: bpf: Move bpf_arena_spin_lock.h to the top level Emil Tsalapatis
2026-01-28  0:13   ` Kumar Kartikeya Dwivedi
2026-01-27 18:16 ` [PATCH v2 04/13] selftests: bpf: Make WRITE_ONCE macro in bpf_atomic.h conditional Emil Tsalapatis
2026-01-27 19:26   ` Mykyta Yatsenko
2026-01-27 23:41     ` Emil Tsalapatis
2026-01-27 23:56       ` Kumar Kartikeya Dwivedi
2026-01-27 18:16 ` [PATCH v2 05/13] selftests: bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-01-28  0:32   ` Alexei Starovoitov
2026-01-28  0:42   ` Kumar Kartikeya Dwivedi
2026-01-27 18:16 ` [PATCH v2 06/13] selftests: bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-01-28  2:27   ` Alexei Starovoitov
2026-01-27 18:16 ` [PATCH v2 07/13] selftests: bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-01-27 18:38   ` bot+bpf-ci
2026-01-27 18:45     ` Emil Tsalapatis
2026-01-27 18:16 ` [PATCH v2 08/13] selftest: bpf: Add bump allocator for libarena Emil Tsalapatis
2026-01-28  2:36   ` Alexei Starovoitov
2026-01-27 18:16 ` [PATCH v2 09/13] selftests: bpf: Add libarena selftests for the bump allocator Emil Tsalapatis
2026-01-27 18:16 ` [PATCH v2 10/13] selftest: bpf: Add libarena stack allocator Emil Tsalapatis
2026-01-27 18:49   ` bot+bpf-ci
2026-01-27 18:16 ` [PATCH v2 11/13] selftests: bpf: Add selftests for the " Emil Tsalapatis
2026-01-28  2:35   ` Alexei Starovoitov
2026-01-27 18:16 ` [PATCH v2 12/13] selftests: bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-01-27 18:49   ` bot+bpf-ci
2026-01-27 18:16 ` [PATCH v2 13/13] selftests: bpf: Add selftests for the libarena buddy allocator Emil Tsalapatis
2026-01-27 18:38   ` bot+bpf-ci

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=8fa34825-ea90-48e7-82c8-00cf4c7375de@gmail.com \
    --to=mykyta.yatsenko5@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=etsal@meta.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=song@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