Re: [PATCH bpf-next v2 2/2] bpf: Reduce branch predictor flush and move it out of pack_mutex
From: bot+bpf-ci
Date: Thu Dec 03 2026 - 10:15:52 EST
> bpf: Reduce branch predictor flush and move it out of pack_mutex
TL;DR: Commit message only: it doesn't explain why eBPF allocations no longer
prefer dirty space, and it states the dirty_map/bitmap superset invariant
three times.
> bpf: Reduce branch predictor flush and move it out of pack_mutex
>
> Currently, predictor dirty tracking in the pack allocator is per pack.
> Even if all chunks allocated for a cBPF program are clean, a flush is
> still triggered if they come from a dirty pack.
> Switch dirty tracking from packs to chunks by maintaining a dirty bit
> for each chunk. The basic idea is that once a chunk has been used, it
> remains dirty until it is freed and a subsequent predictor flush
> is performed. The dirty bit is set when a new pack is allocated or
> when a chunk is allocated to a BPF program. At predictor flush time,
> dirty bits are cleared only for free chunks.
> Therefore, pack->dirty_map is a superset of pack->bitmap. Every bit
> set in pack->bitmap is also set in pack->dirty_map, while bits not
> set in pack->dirty_map are also clear in pack->bitmap. Thus, zero
> bits in the dirty map indicate clean and free chunks. This makes it
> easy to find clean and free chunks for cBPF programs. eBPF allocations
> are back to first fit, they no longer steer to dirty packs, as before
> commit b72e29e0f7ee ("bpf: Prefer dirty packs for eBPF allocations").
> Additionally, bpf_prog_pack_alloc() flushes branch predictors under
> pack_mutex. On x86, this involves sending IPIs to all CPUs to perform
> IBPB and waiting for them to complete. This is expensive, so move the
> flush out of the global pack_mutex.
> Suggested-by: Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx>
> Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
This isn't a bug, but could the changelog say why eBPF allocations no
longer prefer dirty space now that tracking is per chunk? The paragraph
reports "eBPF allocations are back to first fit, they no longer steer to
dirty packs" without giving a reason for dropping the preference added by
b72e29e0f7ee.
Also, the superset invariant is stated three ways ("pack->dirty_map is a
superset of pack->bitmap", "Every bit set in pack->bitmap is also set in
pack->dirty_map", and "bits not set in pack->dirty_map are also clear in
pack->bitmap"). Could these be folded into one statement?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47131842365