mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: xukuohai@huaweicloud.com,bpf@vger.kernel.org,linux-kernel@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,john.fastabend@gmail.com,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,puranjay@kernel.org,pawan.kumar.gupta@linux.intel.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2 2/2] bpf: Reduce branch predictor flush and move it out of pack_mutex
Date: Thu,  3 Dec 2026 15:15:38 +0000 (UTC)	[thread overview]
Message-ID: <d6b5a4455f62d2c550597c698163d4fddb0d45d338eba1448b678c071bc0a457@mail.kernel.org> (raw)
In-Reply-To: <b9e8f1d2f3f419bd739f8b54ba22ccbd677e0a9e.1796304466.git.xukuohai@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]

> 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@gmail.com>
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>

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

      reply	other threads:[~2026-12-03 15:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:09 [PATCH bpf-next v2 0/2] bpf: Move IPIs out of pack_mutex and reduce IBPB flushes Xu Kuohai
2026-12-03 14:09 ` [PATCH bpf-next v2 1/2] bpf: Invalidate freed prog pack memory without holding pack_mutex Xu Kuohai
2026-12-03 14:09 ` [PATCH bpf-next v2 2/2] bpf: Reduce branch predictor flush and move it out of pack_mutex Xu Kuohai
2026-12-03 15:15   ` bot+bpf-ci [this message]

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=d6b5a4455f62d2c550597c698163d4fddb0d45d338eba1448b678c071bc0a457@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=puranjay@kernel.org \
    --cc=song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®