From: Puranjay Mohan <puranjay@kernel.org>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v1 1/3] bpf: Extract bpf_get_linfo_file_line
Date: Mon, 30 Mar 2026 13:27:35 +0100 [thread overview]
Message-ID: <m2zf3pzemg.fsf@kernel.org> (raw)
In-Reply-To: <20260329212534.3270005-2-memxor@gmail.com>
Kumar Kartikeya Dwivedi <memxor@gmail.com> writes:
> Extract bpf_get_linfo_file_line as its own function so that the logic to
> obtain the file, line, and line number for a given program can be shared
> in subsequent patches.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Reviewed-by: Puranjay Mohan <puranjay@kernel.org>
> ---
> include/linux/bpf.h | 2 ++
> kernel/bpf/core.c | 32 +++++++++++++++++++++++---------
> 2 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 05b34a6355b0..2c4f92085d79 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -3946,6 +3946,8 @@ static inline bool bpf_is_subprog(const struct bpf_prog *prog)
> return prog->aux->func_idx != 0;
> }
>
> +int bpf_get_linfo_file_line(struct btf *btf, const struct bpf_line_info *linfo,
> + const char **filep, const char **linep, int *nump);
> int bpf_prog_get_file_line(struct bpf_prog *prog, unsigned long ip, const char **filep,
> const char **linep, int *nump);
> struct bpf_prog *bpf_prog_find_from_stack(void);
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 1af5fb3f21d9..052dd78a2d81 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -3313,6 +3313,28 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(xdp_bulk_tx);
>
> #ifdef CONFIG_BPF_SYSCALL
>
> +int bpf_get_linfo_file_line(struct btf *btf, const struct bpf_line_info *linfo,
> + const char **filep, const char **linep, int *nump)
> +{
> + /* Get base component of the file path. */
> + if (filep) {
> + *filep = btf_name_by_offset(btf, linfo->file_name_off);
> + *filep = kbasename(*filep);
> + }
> +
> + /* Obtain the source line, and strip whitespace in prefix. */
> + if (linep) {
> + *linep = btf_name_by_offset(btf, linfo->line_off);
> + while (isspace(**linep))
> + *linep += 1;
> + }
> +
> + if (nump)
> + *nump = BPF_LINE_INFO_LINE_NUM(linfo->line_col);
> +
> + return 0;
> +}
> +
> int bpf_prog_get_file_line(struct bpf_prog *prog, unsigned long ip, const char **filep,
> const char **linep, int *nump)
> {
> @@ -3347,15 +3369,7 @@ int bpf_prog_get_file_line(struct bpf_prog *prog, unsigned long ip, const char *
> if (idx == -1)
> return -ENOENT;
>
> - /* Get base component of the file path. */
> - *filep = btf_name_by_offset(btf, linfo[idx].file_name_off);
> - *filep = kbasename(*filep);
> - /* Obtain the source line, and strip whitespace in prefix. */
> - *linep = btf_name_by_offset(btf, linfo[idx].line_off);
> - while (isspace(**linep))
> - *linep += 1;
> - *nump = BPF_LINE_INFO_LINE_NUM(linfo[idx].line_col);
> - return 0;
> + return bpf_get_linfo_file_line(btf, &linfo[idx], filep, linep, nump);
> }
>
> struct walk_stack_ctx {
> --
> 2.52.0
next prev parent reply other threads:[~2026-03-30 12:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-29 21:25 [PATCH bpf-next v1 0/3] Add support to emit verifier warnings Kumar Kartikeya Dwivedi
2026-03-29 21:25 ` [PATCH bpf-next v1 1/3] bpf: Extract bpf_get_linfo_file_line Kumar Kartikeya Dwivedi
2026-03-30 11:28 ` Mykyta Yatsenko
2026-03-30 12:27 ` Puranjay Mohan [this message]
2026-03-30 12:35 ` Puranjay Mohan
2026-03-29 21:25 ` [PATCH bpf-next v1 2/3] bpf: Emit verifier warnings through prog stderr Kumar Kartikeya Dwivedi
2026-03-30 11:39 ` Mykyta Yatsenko
2026-03-30 12:39 ` Puranjay Mohan
2026-03-30 15:02 ` Alexei Starovoitov
2026-03-29 21:25 ` [PATCH bpf-next v1 3/3] libbpf: Wire up verifier warning display logic Kumar Kartikeya Dwivedi
2026-03-30 12:56 ` Mykyta Yatsenko
2026-03-30 23:46 ` Andrii Nakryiko
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=m2zf3pzemg.fsf@kernel.org \
--to=puranjay@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.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