BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Andrii Nakryiko" <andrii.nakryiko@gmail.com>,
	"Eduard Zingerman" <eddyz87@gmail.com>
Cc: "Yonghong Song" <yonghong.song@linux.dev>, <bpf@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next v4 00/20] bpf: Run exception cleanup landing pads when bpf_throw() unwinds
Date: Wed, 23 Sep 2026 21:34:21 +0000	[thread overview]
Message-ID: <DLN0OB4STWN9.1101L0OPX69QV@gmail.com> (raw)
In-Reply-To: <DLMY4E5MYGQI.29MKOKECHM134@gmail.com>

On Wed Sep 23, 2026 at 7:34 PM UTC, Kumar Kartikeya Dwivedi wrote:
> On Wed Sep 23, 2026 at 9:24 PM CEST, Andrii Nakryiko wrote:
>> On Wed, Sep 23, 2026 at 12:04 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
>>>
>>> On Tue, 2026-09-22 at 17:04 -0700, Eduard Zingerman wrote:
>>> > On Tue, 2026-09-22 at 23:37 +0000, Alexei Starovoitov wrote:
>>> > > On Tue Sep 22, 2026 at 11:08 PM UTC, Eduard Zingerman wrote:
>>> > > > On Tue, 2026-09-22 at 21:47 +0000, Alexei Starovoitov wrote:
>>> > > > > On Tue Sep 22, 2026 at 4:27 AM UTC, Eduard Zingerman wrote:
>>> > > > > >
>>> > > > > > Total size of executable sections for all Meta BPF object files used
>>> > > > > > for CI veristat testing is 10Mb. Of these there are 30K non-helper
>>> > > > > > call instructions in total.
>>> > > > > > So we are talking about increase by 8 * 30K = 240K ~ 2.4% worst case.
>>> > > > > > Note that the instruction encoding optimized for size already hearts
>>> > > > > > us in src/dst registers department: we have no room for virtual
>>> > > > > > registers, which would have simplified e.g. register allocation task
>>> > > > > > for ARM64. Point being that optimizing intermediate IR for size is not
>>> > > > > > always a right target.
>>> > > > >
>>> > > > > I wasn't talking about increase in bpf ELF size,
>>> > > > > but the amount of the verifier work necessary to double the number
>>> > > > > of call insns.
>>> > > >
>>> > > > I don't understand what you mean by the amount of the verifier work.
>>> > > > Traced program paths would remain the same, only the encoding of the
>>> > > > information about exceptions changes.
>>> > >
>>> > > Any new insn requires plumbing through out.
>>> > > imo ld_imm64 encoding FD inline was a mistake.
>>> > > We should have went with relocations through out.
>>> > > Much cleaner to extend.
>>> > > Same philosophy here. Landing pad is a metadata.
>>> > > It's not a good idea to encode metadata into assembly instruction.
>>> > > bpf ISA is not a high level IR.
>>> >
>>> > Here [1] is Yonghong's series repackaged by codex with the following
>>> > encoding:
>>> >
>>> >   call <subprog-or-kfunc> // regular encoding
>>> >   unwind <label>          // a new instruction that must follow the call instruction
>>> >
>>> > The amount of the verifier/libbpf code dropped from ~2K to 1K lines.
>>> >
>>> > [1] https://github.com/eddyz87/bpf/tree/unwind-postfix
>>>
>>> I want to highlight this once more, before it gets buried.
>>>
>>> Whether landing pad is metadata or not is a matter of opinion,
>>> seeing the program CFG from it's source w/o a need to consult
>>> additional tables is definitely a plus.
>>> Same with ld_imm64, and yes it adds a few checks in the verifier,
>>> but those checks are trivial.
>>>
>>> I looked a bit at what other VMs/IRs do and it's a mix:
>>> - JVM has exception tables similar to ours (begin, end, landing-pad).
>>> - GCC (gimple and rtl) have landing pad address attached to an
>>>   instruction / control flow graph node.
>>> - LLVM has invoke instruction that takes three parameters:
>>>   what to call, where to jump on success, where to jump to unwind.
>>>
>>> With that in mind, I think that the rational thing to do is to choose
>>> based on the implementation complexity. Compared to v5 [2] of this
>>> series the branch [1] allows to forgo:
>>> - UAPI to copy the cleanup table from user space (patch #2)
>
> We will still have UAPI, in form of new instruction, so this is less salient.
>
>>> - insn_aux_data changes for cleanup_pad address (patch #4)
>>> - simplifies check_cfg() handling (patch #5)
>>> - simplifies main verification pass (patch #9):
>>>   - throw raises unwinding flag
>>>   - varifier interprets `unwind` as any other instruction,
>>>         jump if unwinding, fallthrough during normal operation.
>>> - dramatically simplifies libbpf part, dropping patches #16,17,18:
>>>   - no need to collect cleanup tables from elf
>>>   - no need to relocate these tables
>>>   - no need to pass them to the syscall
>>>
>
> All of these do make sense.

Sorry, all I hear is a knee jerk reaction to a lot of slop.
yes. a lot of it is not needed, but invoke approach is no go.
As I said couple time [ip_start, ip_end] is not a single call insn.
libbpf patches do a bunch of unnecessary copy paste,
but that's because we didn't do insn_array support cleanly.
From libbpf pov bpf_cleanup section shouldn't be any different as
"one more section with pointers to instructions".

Sorry, we're not doing new 16-byte insn. We can chat about it
during the meeting, but I feel it will be a waste of time.
New insn doesn't reduce amount of slop.
Ed's example 1k vs 2k is a counter example.
This is just one llm vs another. Both sucked and both slop.
Just different amount of it.


  reply	other threads:[~2026-09-23 21:34 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 21:00 [PATCH bpf-next v4 00/20] bpf: Run exception cleanup landing pads when bpf_throw() unwinds Yonghong Song
2026-09-21 21:00 ` [PATCH bpf-next v4 01/20] bpf: Accept the compiler's exception cleanup table at program load Yonghong Song
2026-09-21 21:56   ` bot+bpf-ci
2026-09-22  3:27     ` Yonghong Song
2026-09-21 21:00 ` [PATCH bpf-next v4 02/20] bpf: Add the bpf_unwind_resume() kfunc Yonghong Song
2026-09-21 21:56   ` bot+bpf-ci
2026-09-22  3:31     ` Yonghong Song
2026-09-21 21:00 ` [PATCH bpf-next v4 03/20] bpf: Add lookups for exception cleanup resumes and landing pads Yonghong Song
2026-09-22  4:04   ` Alexei Starovoitov
2026-09-22  5:28     ` Yonghong Song
2026-09-21 21:00 ` [PATCH bpf-next v4 04/20] bpf: Prepare for an exception cleanup table before the CFG walk Yonghong Song
2026-09-22 18:27   ` Eduard Zingerman
2026-09-23  3:07     ` Yonghong Song
2026-09-23  3:54       ` Eduard Zingerman
2026-09-23  4:05         ` Yonghong Song
2026-09-21 21:00 ` [PATCH bpf-next v4 05/20] bpf: Make exception landing pads reachable in the CFG Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 06/20] bpf: Explore the landing pads no call site reaches Yonghong Song
2026-09-21 23:58   ` Eduard Zingerman
2026-09-22  3:32     ` Yonghong Song
2026-09-22  4:10       ` Eduard Zingerman
2026-09-21 21:01 ` [PATCH bpf-next v4 07/20] bpf: Refuse exception cleanup shapes bpf_throw() cannot dispatch Yonghong Song
2026-09-21 21:20   ` sashiko-bot
2026-09-22  3:39     ` Yonghong Song
2026-09-21 21:56   ` bot+bpf-ci
2026-09-22  3:44     ` Yonghong Song
2026-09-22  0:30   ` Eduard Zingerman
2026-09-22  3:45     ` Yonghong Song
2026-09-22 21:43       ` Eduard Zingerman
2026-09-23  3:11         ` Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 08/20] bpf: Walk the exception unwind in the verifier Yonghong Song
2026-09-21 21:40   ` sashiko-bot
2026-09-22  4:17     ` Yonghong Song
2026-09-21 21:56   ` bot+bpf-ci
2026-09-22  5:21     ` Yonghong Song
2026-09-22  4:08   ` Alexei Starovoitov
2026-09-22  5:25     ` Yonghong Song
2026-09-22 21:53       ` Eduard Zingerman
2026-09-23  3:18         ` Yonghong Song
2026-09-22 23:43   ` Eduard Zingerman
2026-09-23  3:21     ` Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 09/20] bpf: Refuse a private stack for a program with an exception cleanup table Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 10/20] bpf: Dispatch exception cleanup pads from bpf_throw() Yonghong Song
2026-09-22 21:38   ` Eduard Zingerman
2026-09-23  3:22     ` Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 11/20] bpf, x86: Dispatch exception cleanup pads at run time Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 12/20] bpf, arm64: " Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 13/20] libbpf: Resolve the compiler's _Unwind_Resume to the kernel's kfunc Yonghong Song
2026-09-21 21:13   ` sashiko-bot
2026-09-21 21:01 ` [PATCH bpf-next v4 14/20] libbpf: Add cleanup_info to bpf_prog_load_opts Yonghong Song
2026-09-21 21:01 ` [PATCH bpf-next v4 15/20] libbpf: Collect .bpf_cleanup records and pass them to the kernel Yonghong Song
2026-09-21 21:20   ` sashiko-bot
2026-09-21 21:01 ` [PATCH bpf-next v4 16/20] libbpf: Carry the exception cleanup table through the light skeleton Yonghong Song
2026-09-21 21:02 ` [PATCH bpf-next v4 17/20] libbpf: Let the static linker carry .bpf_cleanup relocations Yonghong Song
2026-09-21 21:02 ` [PATCH bpf-next v4 18/20] selftests/bpf: Add an end-to-end .bpf_cleanup exception test Yonghong Song
2026-09-21 21:22   ` sashiko-bot
2026-09-22  5:26     ` Yonghong Song
2026-09-21 21:56   ` bot+bpf-ci
2026-09-21 21:02 ` [PATCH bpf-next v4 19/20] selftests/bpf: Cover the exception cleanup shapes the chain does not reach Yonghong Song
2026-09-21 21:19   ` sashiko-bot
2026-09-21 21:02 ` [PATCH bpf-next v4 20/20] selftests/bpf: Load an exception cleanup program from a light skeleton Yonghong Song
2026-09-22  1:08 ` [PATCH bpf-next v4 00/20] bpf: Run exception cleanup landing pads when bpf_throw() unwinds Eduard Zingerman
2026-09-22  2:16   ` Alexei Starovoitov
2026-09-22  2:31     ` Kumar Kartikeya Dwivedi
2026-09-22 21:44       ` Alexei Starovoitov
2026-09-23  4:36         ` Kumar Kartikeya Dwivedi
2026-09-23  4:54           ` Alexei Starovoitov
2026-09-23  5:20             ` Kumar Kartikeya Dwivedi
2026-09-23  6:16             ` Eduard Zingerman
2026-09-23  6:44               ` Kumar Kartikeya Dwivedi
2026-09-22  4:27     ` Eduard Zingerman
2026-09-22 21:47       ` Alexei Starovoitov
2026-09-22 23:08         ` Eduard Zingerman
2026-09-22 23:37           ` Alexei Starovoitov
2026-09-23  0:04             ` Eduard Zingerman
2026-09-23 19:04               ` Eduard Zingerman
2026-09-23 19:24                 ` Andrii Nakryiko
2026-09-23 19:34                   ` Kumar Kartikeya Dwivedi
2026-09-23 21:34                     ` Alexei Starovoitov [this message]
2026-09-23 22:00                       ` Eduard Zingerman
2026-09-23 23:22                         ` Alexei Starovoitov

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=DLN0OB4STWN9.1101L0OPX69QV@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=memxor@gmail.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