From: Puranjay Mohan <puranjay@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Xu Kuohai <xukuohai@huaweicloud.com>,
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>,
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 v4 2/3] bpf: Report arena faults to BPF stderr
Date: Mon, 01 Sep 2025 19:22:14 +0000 [thread overview]
Message-ID: <mb61p1poqj7vd.fsf@kernel.org> (raw)
In-Reply-To: <CAADnVQKPLwGF25YOzA=a4Vr==0UZFycv6GkLbwszkFrBiHGCcw@mail.gmail.com>
Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:
> On Mon, Sep 1, 2025 at 6:34 AM Puranjay Mohan <puranjay@kernel.org> wrote:
>>
>> Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:
>>
>> > On Fri, Aug 29, 2025 at 3:30 AM Xu Kuohai <xukuohai@huaweicloud.com> wrote:
>> >>
>> >> > +
>> >> > +void bpf_prog_report_arena_violation(bool write, unsigned long addr)
>> >> > +{
>> >> > + struct bpf_stream_stage ss;
>> >> > + struct bpf_prog *prog;
>> >> > + u64 user_vm_start;
>> >> > +
>> >> > + prog = bpf_prog_find_from_stack();
>> >>
>> >> bpf_prog_find_from_stack depends on arch_bpf_stack_walk, which isn't available
>> >> on all archs. How about switching to bpf_prog_ksym_find with the fault pc?
>> >
>> > Out of archs that support bpf arena only riscv doesn't
>> > support arch_bpf_stack_walk(), which is probably fixable.
>> > But I agree that direct bpf_prog_ksym_find() is cleaner here.
>> > We need to make sure it works for subprogs, since streams[2] are
>> > valid only for main prog.
>> > I think we can add:
>> > struct bpf_prog_aux {
>> > ...
>> > struct bpf_prog_aux *main_prog;
>> > };
>> > init it during jit_subprogs() and use it for stream access.
>> > We can also remove skipping of subprogs in find_from_stack_cb() then.
>> >
>> > Kumar, wdyt?
>>
>> So, IIUC, after adding struct bpf_prog_aux *main_prog_aux in struct
>> bpf_prog_aux,
>>
>> We can do in bpf_prog_alloc_no_stats():
>> fp->aux->main_prog_aux = aux;
>>
>> and in jit_subprogs():
>> func[i]->aux->main_prog_aux = prog->aux;
>>
>> and then all users of bpf_stream_get() can do
>> bpf_stream_get(stream_id, prog->aux->main_prog_aux);
>>
>> with above we can allow find_from_stack_cb() to return subprogs.
>> and bpf_prog_ksym_find() can be used in
>> bpf_prog_report_arena_violation() without any other changes.
>
> Yes. That's exactly the proposal.
I think we should go ahead with this approach but also divide
bpf_prog_aux into two as you suggested. I will send a follow-up set for
that.
Thanks,
Puranjay
next prev parent reply other threads:[~2025-09-01 19:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 15:37 [PATCH bpf-next v4 0/3] bpf: Report arena faults to BPF streams Puranjay Mohan
2025-08-27 15:37 ` [PATCH bpf-next v4 1/3] bpf: arm64: simplify exception table handling Puranjay Mohan
2025-08-28 0:19 ` Kumar Kartikeya Dwivedi
2025-08-29 10:06 ` Xu Kuohai
2025-08-27 15:37 ` [PATCH bpf-next v4 2/3] bpf: Report arena faults to BPF stderr Puranjay Mohan
2025-08-28 0:22 ` Kumar Kartikeya Dwivedi
2025-08-28 0:27 ` Kumar Kartikeya Dwivedi
2025-08-28 12:14 ` Puranjay Mohan
2025-08-29 10:30 ` Xu Kuohai
2025-08-29 20:28 ` Alexei Starovoitov
2025-09-01 13:34 ` Puranjay Mohan
2025-09-01 16:39 ` Alexei Starovoitov
2025-09-01 19:22 ` Puranjay Mohan [this message]
2025-09-01 22:44 ` Kumar Kartikeya Dwivedi
2025-09-02 2:18 ` Alexei Starovoitov
2025-08-27 15:37 ` [PATCH bpf-next v4 3/3] selftests/bpf: Add tests for arena fault reporting Puranjay Mohan
2025-08-27 19:54 ` Yonghong Song
2025-08-27 23:49 ` Kumar Kartikeya Dwivedi
2025-08-28 12:25 ` Puranjay Mohan
2025-08-28 15:44 ` Yonghong Song
2025-08-28 0:23 ` [PATCH bpf-next v4 0/3] bpf: Report arena faults to BPF streams Kumar Kartikeya Dwivedi
2025-08-28 12:13 ` Puranjay Mohan
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=mb61p1poqj7vd.fsf@kernel.org \
--to=puranjay@kernel.org \
--cc=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=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 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.