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=1795619497; b=L2r2YpleEOISSMHIk7YsqoKeSdqdWHePaU8aN5DxWy8mCGlx5oTSV5l3pNNnbjh/plWE RqHm8DxOQJgQte3zn/iYJATfUfG2AUStjJATfgFoIYQKBE8tf1glrAHfWMsiPVN/wgQzR NpL4tPgSnVSkhi3bVvmIotS1MKPj69i/KQCOGoNPi8VgS51nVLuDst6FgsXDUBGjfg3xg EKwsPcj8CPiMtL96XvTiDL7r8ErhmGPSXkUd5rL6+peElYx/MXRXuV0gMzf+7AMikUL9K O04JVDCusHIA4nF2kZATXXYmgUlJZiTQKWhQlBKKkDy27tDoOWGJLpmX8B4/FMA0ozg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795619497; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=WVO1soJfHbEBmgo7qXJtgiUvrJX4687UFMur9tkTGHE=; b=KiQyLIl9WYs3HNMKR0+BIO/3tbB/iT94M1G0LTZiXUdMhQD30iEMYOVS8xJH2yqb5YMa FSvIzwPdnb2JKAft9IXdO5/7g4czovoy6jH2DglYV2uweNuqoU1JOtGOrAVv6b9L9RqcN +sNZFnXNCzoZlXBcCQ6N31wnID9vXTgSSVQIco5db6LoogyJ2XryUroZM2gDXeCxEXCGm su7u7dnblboeZkMHSyQR5fvnoyu/K9+xUZhVOWTOIFmdItGP96/ERImO59F+S1pVFmsio 2ZG7M9PByqOzowxe9EiFRI1eTVL46IY2Yxl+RHxfzy9UKxeWGEELbDRc8VGHMnVzlkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FzgOoNJM; 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 DD853606A31E; Wed, 25 Nov 2026 15:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FzgOoNJM Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E9B1F000C0; Wed, 25 Nov 2026 15:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795619497; bh=WVO1soJfHbEBmgo7qXJtgiUvrJX4687UFMur9tkTGHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FzgOoNJMiygZh0Gaj6jVIA6V7wrMVXCkOkTJ0Vl70jmeVmvuxPvePz1v1eIYktFGV RWwQjyFKWFbjlfxkD2SObhWHCfDg4ipR2dMWagL2PI6v+IWUEEiFZYNG/9+E5ng8iS jzt89+bS4YG2evyCnwWwdVA9Oa3bE+QdBHkA7XXs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , "David Hildenbrand (Arm)" , Johannes Weiner , "Vlastimil Babka (SUSE)" Subject: [PATCH 7.3 0598/1005] mm: page_frag: refill the cache for large fragments Date: Wed, 25 Nov 2026 15:32:16 +0100 Message-ID: <20261125143835.754105087@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143821.729802100@linuxfoundation.org> References: <20261125143821.729802100@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit c028ecdf15131a2ab70d78a76657b81c00fa240d upstream. A fragment which is larger than PAGE_SIZE can only be served from the 32K page of a page_frag_cache. If memory is low and the cache had to fall back to a single page, __page_frag_alloc_align() returns NULL and keeps that page. Since the offset counts up, this check comes first and is made whenever the fragment does not fit behind nc->offset, no matter how big the page of the cache is. So the cache is never refilled on behalf of a large fragment: with fragsz = 10000 the first three allocations succeed, the fourth one and all the following ones fail although memory is plentiful. nc->offset does not move either, so this lasts until smaller fragments have used up the rest of the page, which never happens if the cache has no other user. The nfp driver allocates its receive buffers with napi_alloc_frag() and netdev_alloc_frag(). They are larger than a page with a jumbo MTU. Only give up if the fragment does not fit into the page at all, which is what the comment describes. The fourth allocation in the scenario above with a 32k page will thus now proceed to refill the cache. Fixes: 8218f62c9c9b ("mm: page_frag: use initial zero offset for page_frag_alloc_align()") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Josef Bacik Signed-off-by: David Hildenbrand (Arm) Reviewed-by: Johannes Weiner [vbabka@kernel.org: make the comment more obvious] Link: https://patch.msgid.link/20261103-pgalloc-ai-hotfixes-v2-2-e0d2890ab74f@kernel.org Signed-off-by: Vlastimil Babka (SUSE) Signed-off-by: Greg Kroah-Hartman --- mm/page_frag_cache.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) --- a/mm/page_frag_cache.c +++ b/mm/page_frag_cache.c @@ -119,15 +119,20 @@ refill: size = PAGE_SIZE << encoded_page_decode_order(encoded_page); offset = __ALIGN_KERNEL_MASK(nc->offset, ~align_mask); if (unlikely(offset + fragsz > size)) { - if (unlikely(fragsz > PAGE_SIZE)) { + if (unlikely(fragsz > size)) { /* - * The caller is trying to allocate a fragment - * with fragsz > PAGE_SIZE but the cache isn't big - * enough to satisfy the request, this may - * happen in low memory conditions. - * We don't release the cache page because - * it could make memory pressure worse - * so we simply return NULL here. + * The caller is trying to allocate a fragment that's + * larger than the whole cache page. + * + * Either fragsz is larger than PAGE_FRAG_CACHE_MAX_SIZE + * so this cannot ever succeed. + * + * Or the refill has fallen back to order-0 due to a low + * memory condition. Then we don't want to release the + * cache page to attempt a new large-size refill because + * it could make memory pressure worse. + * + * So in both cases we simply return NULL here. */ return NULL; }