From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796226947; b=MnCHcfFQIVqduqpH0M94+sXpfSuWNPY2w6VWemPVoJNkEYuDaXlqmJ+m3o3XZ+o/UDY4 HxGmC3s1jlwu/cyR+LpjmaJTDnJX2gtCdqcrxNAVylv4PrpQk+ld6uOGalM8iqWOXGQs8 mFwaXqUyDg5Yo48Yhsgp+NJgvxnMA/lFvLAxl2dgjGh6BxdA71Lra9JG5KtcAcwiJPs0P NoHDwdnfaAlMQLlomfw93UZip2RaQm9vghYAQ5KVmL7fqzUEGmN/zgxILYekjDarU3ukM rTFJi3LERW0tnFbRaeVIokla5lji4FEuU8qt4XKWH0eP05w20e/2e8CQYvtA7izaRRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796226947; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XmX3NRd+mJphFB4AT9NrS2qZetY0LiGvyQ0R2uS5f38=; b=C1qguIPmqDQD3ZHZm6VnGJ/7xDVpohu5qOkH85ZkN5wuuf1pPVwMghNxfT0IS7LdeKO5 hO0/EIbloHi/zuM/Whf1hXFT675OSm8l8hv3GmTU966J0oB+/07RVJhUugoZHTIiWqJlM F5VORDHGsG4Vi9UCUFeDdPoLR0WzenaKFxpaNXUjKN7s2UQbWPiOtIl8giB2nHpyCNzNU URpOFa7M579hJjOlNAauFhSh5LgTLc46DlgsgD6mnMueNBbDsRK+N4qXTOBRVH8jwPe7P 4MrsFQrVIQvmj9cQoz+UrOk3dkUvm8JmWxI+BiOQ1N1Ss5c3vYuhEO2A3EpEoKiL78A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Stip1kUX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DFA3606A32F for ; Wed, 2 Dec 2026 15:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Stip1kUX Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDFD71F0089B; Wed, 2 Dec 2026 15:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796226947; bh=XmX3NRd+mJphFB4AT9NrS2qZetY0LiGvyQ0R2uS5f38=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Stip1kUXTQkx9oY4snAw7uw0HZJmC4sjflSv0keePqLFOTXLxytmqYn1gX1jQ+kse HyFl34d81qGplWb74xDTMGX+lQAaduM4oUQxEhXh+BYMig5EFqB92I9dwehyvbb8xj xsPBIVVd1oRRJZ1/YRRc1VUhbQO4uUwPqjlbDNJcL1TakWWxuI5Z2go9A7TRRRs1HD qa4qdDbTwm6UekEwXzMCpfvbTweIy/pbIDMQJBd6z3gdzve6NTevaU+QHgb1+5/6rh 4ihl8rAeTgQGEmKar8dn2qB66cUaI8g53+1o880w0yoPCppmRuSRt3tcJucafV31P0 jRmDRk2r37ABw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 2/3] bpf: Change dirty tracking from packs to chunks Reply-To: sashiko-reviews@lists.linux.dev To: "Xu Kuohai" , bpf@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:55:46 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] bpf: stale dirty_map read when !arch_flush_needed in bpf_prog_pack_alloc() -- commit 811051fe76077420fa826110b71c4df5c0c494fd Author: Xu Kuohai bpf: Change dirty tracking from packs to chunks This commit switches predictor dirty tracking in the BPF prog pack allocator from per-pack to per-chunk using a dirty_map bitmap on each pack. > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index 63bc7e7b95409..920c8cdaf2679 100644 > --- a/kernel/bpf/core.c > +++ b/kernel/bpf/core.c [ ... ] > @@ -1304,16 +1345,23 @@ void *bpf_prog_pack_alloc(u32 size, bpf_jit_fill_= hole_t bpf_fill_ill_insns, bool > if (!static_branch_unlikely(&bpf_pred_flush_enabled)) > goto found_free_area; > /* > - * cBPF reuse of a dirty pack triggers a flush, so prefer a > - * clean pack for cBPF. eBPF never flushes, so steer it to a > - * dirty pack and keep clean packs free for cBPF. > + * cBPF reuse of a dirty chunk triggers a flush, so prefer > + * clean chunks for cBPF. eBPF never flushes, so steer it to > + * dirty chunks and keep clean chunks free for cBPF. > */ > - if (was_classic ^ pack->arch_flush_needed) > + dirty_pos =3D find_next_bit(pack->dirty_map, pos + nbits, pos); > + if (was_classic ^ (dirty_pos < pos + nbits)) > goto found_free_area; > + > if (!fallback_pack) { > fallback_pack =3D pack; > fallback_pos =3D pos; > } > + > + /* Find clean chunks for cBPF or dirty chunks for eBPF */ > + pos =3D bpf_pack_find_area(pack, dirty_pos, nbits, was_classic); > + if (pos < BPF_PROG_CHUNK_COUNT) > + goto found_free_area; > } [Severity: Medium] Does consulting pack->dirty_map here without checking pack->arch_flush_needed misclassify clean packs that still hold stale dirty bits? When a flush runs, it sets p->arch_flush_needed =3D false across pack_list without clearing p->dirty_map, deferring bitmap_zero() until the next bpf_prog_pack_free() on each pack. Until a free happens in that pack, pack->dirty_map retains stale 1 bits (including all bits set to 1 from alloc_new_pack()). If an earlier pack in pack_list has only dirty free chunks and becomes fallback_pack, while a later pack has arch_flush_needed =3D=3D false with stale bits in dirty_map, a cBPF allocation treats the clean pack as dirty, skips it, falls back to the dirty fallback_pack, and triggers an unnecessary bpf_arch_pred_flush(). For eBPF, the stale bits make the clean pack look dirty, steering eBPF allocations into clean packs instead of saving them for cBPF. Checking pack->arch_flush_needed before inspecting pack->dirty_map (treating all chunks in the pack as clean when !pack->arch_flush_needed) would avoid acting on the stale bitmap. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796223449.gi= t.xukuohai@huawei.com?part=3D2