Re: [PATCH] bpf/verifier: compress bpf_reg_state by using bitfields
From: Eduard Zingerman
Date: Thu Jan 15 2026 - 13:55:36 EST
On Thu, 2026-01-15 at 23:20 +0800, wujing wrote:
> The struct bpf_reg_state is 112 bytes long on 64-bit architectures,
> with several fields that have limited ranges. In particular, the bool
> 'precise' at the end causes 7 bytes of padding.
>
> This patch packs 'frameno', 'subreg_def', and 'precise' into a single
> u32/s32 bitfield block:
> - frameno: 4 bits (sufficient for MAX_CALL_FRAMES=8)
> - subreg_def: 27 bits (sufficient for 1M insns limit)
> - precise: 1 bit
>
> This reduces the size of struct bpf_reg_state from 112 to 104 bytes,
> saving 8 bytes per register. This also reduces the size of
> struct bpf_stack_state. Overall, it reduces peak memory usage of the
> verifier for complex programs with millions of states.
>
> The patch also updates states_maybe_looping() to use a non-bitfield
> boundary for memcmp(), as offsetof() cannot be used on bitfields.
>
> Signed-off-by: wujing <realwujing@xxxxxxxxx>
> Signed-off-by: Qiliang Yuan <yuanql9@xxxxxxxxxxxxxxx>
> ---
varistat collects verifier memory usage statistics.
Does this change has an impact on programs generated for
e.g. selftests and sched_ext?
In general, you posted 4 patches claiming performance improvements,
but non of them are supported by any measurements.
P.S.
Is this LLM-generated?