From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Puranjay Mohan <puranjay@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
Xu Kuohai <xukuohai@huaweicloud.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v5 2/4] bpf: core: introduce main_prog_aux for stream access
Date: Mon, 1 Sep 2025 19:25:29 -0700 [thread overview]
Message-ID: <CAADnVQLgcZyUgB2Uq7z8Vc0f=nTWLw8hNPZ2xzVCbWUJxuheQw@mail.gmail.com> (raw)
In-Reply-To: <20250901193730.43543-3-puranjay@kernel.org>
On Mon, Sep 1, 2025 at 12:37 PM Puranjay Mohan <puranjay@kernel.org> wrote:
>
> BPF streams are only valid for the main programs, to make it easier to
> access streams from subprogs, introduce main_prog_aux in struct
> bpf_prog_aux.
>
> prog->aux->main_prog_aux = prog->aux, for main programs and
> prog->aux->main_prog_aux = main_prog->aux, for subprograms.
>
> This makes it easy to access streams like:
> stream = bpf_stream_get(stream_id, prog->main_prog_aux);
>
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> ---
> include/linux/bpf.h | 1 +
> kernel/bpf/core.c | 3 +--
> kernel/bpf/stream.c | 6 +++---
> kernel/bpf/verifier.c | 1 +
> 4 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 8f6e87f0f3a89..d133171c4d2a9 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1633,6 +1633,7 @@ struct bpf_prog_aux {
> /* function name for valid attach_btf_id */
> const char *attach_func_name;
> struct bpf_prog **func;
> + struct bpf_prog_aux *main_prog_aux;
> void *jit_data; /* JIT specific data. arch dependent */
> struct bpf_jit_poke_descriptor *poke_tab;
> struct bpf_kfunc_desc_tab *kfunc_tab;
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index ef01cc644a965..dbbf8e4b6e4c2 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -120,6 +120,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flag
>
> fp->pages = size / PAGE_SIZE;
> fp->aux = aux;
> + fp->aux->main_prog_aux = aux;
Though I agree that it's not strictly necessary, this approach
is so much easier to reason about.
Kumar, wdyt?
next prev parent reply other threads:[~2025-09-02 2:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 19:37 [PATCH bpf-next v5 0/4] bpf: report arena faults to BPF streams Puranjay Mohan
2025-09-01 19:37 ` [PATCH bpf-next v5 1/4] bpf: arm64: simplify exception table handling Puranjay Mohan
2025-09-01 19:37 ` [PATCH bpf-next v5 2/4] bpf: core: introduce main_prog_aux for stream access Puranjay Mohan
2025-09-02 2:25 ` Alexei Starovoitov [this message]
2025-09-02 2:32 ` Kumar Kartikeya Dwivedi
2025-09-01 19:37 ` [PATCH bpf-next v5 3/4] bpf: Report arena faults to BPF stderr Puranjay Mohan
2025-09-02 12:42 ` kernel test robot
2025-09-03 0:01 ` Eduard Zingerman
2025-09-01 19:37 ` [PATCH bpf-next v5 4/4] selftests/bpf: Add tests for arena fault reporting Puranjay Mohan
2025-09-02 16:22 ` Yonghong Song
2025-09-02 22:21 ` Eduard Zingerman
2025-09-05 14:00 ` Puranjay Mohan
2025-09-05 18:38 ` Eduard Zingerman
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='CAADnVQLgcZyUgB2Uq7z8Vc0f=nTWLw8hNPZ2xzVCbWUJxuheQw@mail.gmail.com' \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=puranjay@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=will@kernel.org \
--cc=xukuohai@huaweicloud.com \
--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;
as well as URLs for NNTP newsgroup(s).