From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
bpf@vger.kernel.org, andrii@kernel.org, daniel@iogearbox.net,
kernel-team@meta.com, eddyz87@gmail.com, memxor@gmail.com
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next 1/2] bpf: Stop JIT passes only when no insn moves
Date: Wed, 21 Oct 2026 23:52:33 +0100 [thread overview]
Message-ID: <6ecce342-a2a6-407b-95a4-472df021f5af@gmail.com> (raw)
In-Reply-To: <DMAV2RFTNVWP.26B5N5NZ3TCEL@gmail.com>
On 10/21/26 11:15 PM, Alexei Starovoitov wrote:
> On Wed, Oct 21, 2026 at 07:21 AM Mykyta Yatsenko <mykyta.yatsenko5@gmail.com> wrote:
>> A backward jump is sized from its target's current-pass address and its
>> own previous-pass address, so it can grow while other jumps shrink. Two
>> passes may then give the same image length with jumps still changing,
>> and the image pass fails with "bpf_jit: fatal error".
>
> can we fix the sizing of the backward jump instead ?
>
> It's the third time it bites us.
> commit 1612a981b766 ("bpf, x64: fix JIT emission for dead code")
> special cased ja -1 and
> commit c8831bdbfbab ("bpf, x64: Fix a jit convergence issue")
> limited imm8 to 123 because of it.
> With this patch jumps still grow, and the one that grows in a padding
> pass still ends in "unexpected jmp_cond padding: -4 bytes".
>
> do_jit() knows how far the current pass moved insn i. With that taken
> into account a backward jump is sized by the insns it jumps over, the
> same way as a forward one. Insn sizes start at 64 and only go down, so
> the image shrinks with every pass like the comment in
> bpf_int_jit_compile() says, and proglen == oldproglen means that
> nothing moved.
> Then no need for addrs_changed, for the ja -1 special case and
> for is_imm8_jmp_offset().
>
> Something like this (compile tested only):
I'll send v2. Thanks for the suggestion.
> pw-bot: cr
next prev parent reply other threads:[~2026-10-21 22:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 14:21 [PATCH bpf-next 0/2] bpf: Fix x86 JIT stopping before jumps converge Mykyta Yatsenko
2026-10-21 14:21 ` [PATCH bpf-next 1/2] bpf: Stop JIT passes only when no insn moves Mykyta Yatsenko
2026-10-21 22:15 ` Alexei Starovoitov
2026-10-21 22:52 ` Mykyta Yatsenko [this message]
2026-10-21 14:21 ` [PATCH bpf-next 2/2] selftests/bpf: Test JIT jumps which change at a repeated image length Mykyta Yatsenko
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=6ecce342-a2a6-407b-95a4-472df021f5af@gmail.com \
--to=mykyta.yatsenko5@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=memxor@gmail.com \
--cc=yatsenko@meta.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 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.