From nobody Mon May 25 00:56:11 2026 Received: from mail.ilvokhin.com (mail.ilvokhin.com [178.62.254.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DDFE3A3826 for ; Wed, 20 May 2026 12:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.62.254.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779279768; cv=none; b=t9wQHqXfdujhH+TRpur0ISZcVhuqSbh5atDYiAmDkygM2CQcojHnFQfznkPBNA0pdO6RdCL5+A10Qk2YbntW3p1qHJWZuybRg02TkQo1+MUGrFW9BTlvFU8r1myxLpEo1dSoGAhUSgq3x5On462oy4D53V6FbEu3W9Ov6BBjQdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779279768; c=relaxed/simple; bh=CE35f+2mfa/agedYULukSIOICUNtVY1dlx+vD+tRjr4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IUB/oGRXjWM8u3jgS/bPeGcBJ9GlxJpniu95C1CCts42LYSvilnv4zXOlxG79Gm6w6WwhifpYuvVndr2PMiq4BS1HXywM7DgUfKYzSIHLGO9JM8HUBX9pdIpVqwLJnyvMsefcZyyqSAeUEx1of+BXpuDNTZeWaWPFjB5hGzNAF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ilvokhin.com; spf=pass smtp.mailfrom=ilvokhin.com; dkim=pass (1024-bit key) header.d=ilvokhin.com header.i=@ilvokhin.com header.b=e2h+4wDt; arc=none smtp.client-ip=178.62.254.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ilvokhin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ilvokhin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ilvokhin.com header.i=@ilvokhin.com header.b="e2h+4wDt" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 3BD33D08AA; Wed, 20 May 2026 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1779279765; bh=4z0oVpabtVbiM82/tqdgqkFnCkglhDgJPoHBNxJz1XA=; h=From:To:Cc:Subject:Date; b=e2h+4wDtxKs46ySDdWrvJEh41J4vnSBBeCgr1O4RlbOZgO02Q1r0wAaykhNhdUtIg bzcCtQmgtLAcEH5E1mIMrIuFFuEGqrCPCZlOWABr26ShPr/GX9K/wcqC34iHH54N9y N1GYYFT9OHYxQ1LFaPBBFvlfMNPBxO9YJ20nAkZY= From: Dmitry Ilvokhin To: Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Dmitry Ilvokhin Subject: [PATCH v2] mm/page_alloc: fix defrag_mode for non-reclaimable allocations Date: Wed, 20 May 2026 12:22:28 +0000 Message-ID: <20260520122228.201550-1-d@ilvokhin.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When defrag_mode is enabled, ALLOC_NOFRAGMENT is enforced to prevent migratetype fallbacks and keep pageblocks clean. The allocator relies on reclaim and compaction to free pages of the correct type before allowing fallback as a last resort. However, non-reclaimable allocations such as GFP_ATOMIC cannot invoke direct reclaim or compaction. With defrag_mode=3D1, these allocations hit the !can_direct_reclaim bailout in __alloc_pages_slowpath() with ALLOC_NOFRAGMENT still set, and fail without ever attempting a fallback. This causes a large number of SLUB allocation failures for skbuff_head_cache under network-heavy workloads, despite free memory being available in other migratetype freelists. Clear ALLOC_NOFRAGMENT and retry for allocations that request kswapd reclaim but cannot do direct reclaim themselves (GFP_ATOMIC). Purely speculative allocations like GFP_TRANSHUGE_LIGHT that don't set __GFP_KSWAPD_RECLAIM are left to fail, since they have reasonable fallbacks and should not cause fragmentation. Fixes: e3aa7df331bc ("mm: page_alloc: defrag_mode") Signed-off-by: Dmitry Ilvokhin Acked-by: Johannes Weiner --- Changes in v2: - Add check for __GFP_KSWAPD_RECLAIM. - Picked up Johannes acked-by tag. v1: https://lore.kernel.org/all/20260518163736.173910-1-d@ilvokhin.com/ mm/page_alloc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 227d58dc3de6..c5a077de1be0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4811,8 +4811,19 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int = order, } =20 /* Caller is not willing to reclaim, we can't balance anything */ - if (!can_direct_reclaim) + if (!can_direct_reclaim) { + /* + * Reclaim/compaction cannot run, so defrag_mode's strategy + * of enforcing ALLOC_NOFRAGMENT cannot be fulfilled. Allow + * fallbacks rather than failing the allocation outright. + */ + if (defrag_mode && (alloc_flags & ALLOC_NOFRAGMENT) && + (gfp_mask & __GFP_KSWAPD_RECLAIM)) { + alloc_flags &=3D ~ALLOC_NOFRAGMENT; + goto retry; + } goto nopage; + } =20 /* Avoid recursion of direct reclaim */ if (current->flags & PF_MEMALLOC) --=20 2.53.0-Meta