From nobody Mon May 25 05:12:51 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 3D54248B384 for ; Mon, 18 May 2026 16:38:01 +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=1779122285; cv=none; b=o2s/1AaHQED+XPj162LV/jedkxXvewc8nrrnnPH7LRiY/AcalvnjHkz1cFeNTKxFM191ynZbSH+8lK8dfM4gccZUYQV29WGBQQmOkHGm+D9uIyKq+sWPARy5C9WTxcKmUWM4IPYZeGmGJKn8g8BlKmLPsatt70sPiDLi9VzPZ4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779122285; c=relaxed/simple; bh=F+RxNYT2TXddNqjzw4j83xFcMqGafBlXVABVhkTOxp8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MBbl1Tw+0DOPLTuKysKJorEI1/FVVuel24URmTUKxsasSkAsM7lp87K0n1CvINN9oRJ7YiFjwTRDl6/WerouYHfsXk/3K6sKFixETnn52p6dUfUoi3IeildlSajvldZWjinLAL7p5gvEhtkqPdWYLSPbscYEZyFxmqnn8zVnX9U= 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=doTmd2YJ; 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="doTmd2YJ" Received: from localhost.localdomain (shell.ilvokhin.com [138.68.190.75]) (Authenticated sender: d@ilvokhin.com) by mail.ilvokhin.com (Postfix) with ESMTPSA id 00A69D076E; Mon, 18 May 2026 16:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilvokhin.com; s=mail; t=1779122280; bh=GQZOR7EeHJdI+Jk9OxQH7NOcHFGL3WtzweHiN46bj4g=; h=From:To:Cc:Subject:Date; b=doTmd2YJ7YsbL/O2wd9bQuUjetpnMPCEve2KwqCCbt86vHYap6grSzGxQc3fvwuqX h9thuj/sXvjzsYFJVYWxLQUCeO0BirzP3j0MgpXnxnDzxyHXrpJuDCshPWuiQhV2uA fMsLWtvfRiexFYMjEAjP9yoEwTAod4abxSlg5P3U= 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] mm/page_alloc: fix defrag_mode for non-reclaimable allocations Date: Mon, 18 May 2026 16:37:36 +0000 Message-ID: <20260518163736.173910-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 before giving up on allocations that cannot reclaim, following the same pattern used after reclaim/compaction exhaustion later in the slowpath. Fixes: e3aa7df331bc ("mm: page_alloc: defrag_mode") Signed-off-by: Dmitry Ilvokhin Acked-by: Johannes Weiner --- mm/page_alloc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 227d58dc3de6..749422b8396f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4811,8 +4811,18 @@ __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)) { + 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