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=1796309721; b=dvzctYf7jxpo0JOIK/+nBDJ4JVNWcUvtox51hTabCzA1LEkSUxRjIDoW6v+lr9Q4Dimt 01q/rCmrmmwXxoxBc48jsJBZOca9x9rnvPf339q/5wZt7blmduPHy9Qz2/zwA0LglZi1R kN53lqtAxpFDKjeKDqi//xaCMcyDXJhAHcjLfGEybhjAfhFO3/z86IJbHn5VXvtTNhuDI 9jEx2FRPYdlqDg0jjeiesA88FXYVoMkvKCDFwAxVDfHiXj5W9v+3ExU93W33m5ucNa5/W KRCNSe9jaUZTaarx943WNcT/nz1wPJR4NtP3Xqfvm21tAQkNPzA39ihpDikeVnXgsug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309721; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=TI1kss2saYbj7DGJ7xutt6JmLOECzioH3fUdPkOIR3E=; b=F5nL+bJhuqGC+AWh6Ap8Ipw9cI8q2wlx8tHL+BxyNp4naLlxU0oLHYQtnE5y3ue/8LF4 pE6xMkhU22wvDMVNFh1JhJLAg+N2k94sgwYpADkitrTHJBufHJyc0H43X3r+WAIhfT2rm ftfN7HwS9hPobI9ZUNaRf+CygIIAAVtyQs6xBB0sk5rrN6h2KubwsMVZWIE+X5KAEgLes 72rqwmjPSPirgBBElbI+h5Dr1DTL6gQ99RTEFsoHYO9ZRHdPBigEkCs2kU8mC3tFpQDMl N4U+Gf9Ud7a0JgIF+4M9J3sgkAOI9AgrDfPpRkoUhXPhEV9czkDuocLQFcurxwE6QFA== 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=II9f15Yk; 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 C0C77606A322 for ; Thu, 3 Dec 2026 14:55:21 +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=II9f15Yk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4628A1F00899; Thu, 3 Dec 2026 14:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309721; bh=TI1kss2saYbj7DGJ7xutt6JmLOECzioH3fUdPkOIR3E=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=II9f15YkomR1Tg7Az/x8V3evCYSW/FZ2L4WyDDT2trAMHzuV0aHQWFaJgfR9cgxjT K4U6hnx1MXWkis7n5zt7XWg6o3oxQuI4Yo9Q1tvANVsm7OTSOvWJFCdfRi2h0tiZOn hAEpQ4BcEz6r0oAobjfd+moIjYeyWNt54H+uEyxP5qsw5lLN+cmaCxJBNKaHuLuzAa H+kH5drzysXfj5Gc/tkZllxW9koMSIAmyjJQdPJGg7mkvWY19hYveY2mbME2yZqNSY U+bML760QCBC2nayUTWUZvvBHXC7ru/bxSE4gDJBn/PlX2ahft/iAqkCGcjg6oGlHa 09fQ63u+zSiWg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next v2 2/2] bpf: Reduce branch predictor flush and move it out of pack_mutex 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: Thu, 03 Dec 2026 14:55:20 +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: high-order kzalloc_flex() in alloc_new_pack() exceeds costly order -- commit ffc40b7484a2a688a0e417b3e1c0e5493a3fce98 Author: Xu Kuohai bpf: Reduce branch predictor flush and move it out of pack_mutex This commit switches branch predictor dirty tracking in the BPF prog pack allocator from per-pack to per-chunk via a dirty_map bitmap, and moves the predictor flush out from under pack_mutex into a separate pack_flush_mutex. > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index 4c908133011df..143fa134fea55 100644 > --- a/kernel/bpf/core.c > +++ b/kernel/bpf/core.c [ ... ] > @@ -1235,16 +1242,16 @@ static struct bpf_prog_pack *alloc_new_pack(bpf_j= it_fill_hole_t bpf_fill_ill_ins > struct bpf_prog_pack *pack; > int err; > =20 > - pack =3D kzalloc_flex(*pack, bitmap, BITS_TO_LONGS(BPF_PROG_CHUNK_COUNT= )); > + pack =3D kzalloc_flex(*pack, bitmap, 2 * BITS_TO_LONGS(BPF_PROG_CHUNK_C= OUNT)); > if (!pack) > return NULL; > + pack->dirty_map =3D pack->bitmap + BITS_TO_LONGS(BPF_PROG_CHUNK_COUNT); > pack->ptr =3D bpf_jit_alloc_exec(BPF_PROG_PACK_SIZE); > if (!pack->ptr) > goto out; > bitmap_zero(pack->bitmap, BPF_PROG_PACK_SIZE / BPF_PROG_CHUNK_SIZE); > + bitmap_fill(pack->dirty_map, BPF_PROG_CHUNK_COUNT); [Severity: Medium] Can doubling the bitmap array in kzalloc_flex() cause compaction stalls under pack_mutex or spurious -ENOMEM failures? On 4 KiB-page systems, each bitmap is 4 KiB * num_possible_nodes(). Doubling it pushes this contiguous GFP_KERNEL allocation past KMALLOC_MAX_CACHE_SIZE to order-2 pages (16 KiB) on 1-node hosts, and from order 3 to order 4 (64 KiB, above PAGE_ALLOC_COSTLY_ORDER) on 4-node hosts. Under physical fragmentation, an order-4 GFP_KERNEL allocation triggers direct compaction under pack_mutex and fails with -ENOMEM without reclaim retries, even when bpf_jit_alloc_exec() would succeed via vmalloc order-0 fallback. This is also paid when bpf_pred_flush_enabled is false. Both alloc_new_pack() and bpf_prog_pack_free() run in sleepable context under pack_mutex alongside bpf_jit_free_exec(). Would kvzalloc_flex() and kvfree() avoid these high-order allocation failures? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796304466.gi= t.xukuohai@huawei.com?part=3D2