From nobody Sat Feb 7 21:24:24 2026 Received: from mail-dy1-f194.google.com (mail-dy1-f194.google.com [74.125.82.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC783328FC for ; Wed, 21 Jan 2026 06:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768978139; cv=none; b=giVAqIsoCLupjstNlJItEj6e3hrQ3hMU2Xjp5mYvQk+6HXOcK3KpMKthTwA18JYU5UdsDB4VQto3EfZALcUvqiOJfpBS+PEYVJ6z8Gwj3mN7WdFsA6whTz5yfIOds3nne5tSbSjVuqJ9PcZvm4uXuazaM6MPEAXWs++Iu5v0zDA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768978139; c=relaxed/simple; bh=aDjNJbPbwfemekUP+XVYRKuu9vVvYAefjFFyv0oZPfY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JQs+78IRs0lAp2sAP+Um8Xv1wpfGpHR/a3nKk0nzMTzDUA3CQerCziATDT0tEUhRWzLs6nosyCsSk10jHF2TMpL/ES5LaBIaP1MlWSvuDyCoLMoCF/tdHE5/uAJNTgY2SLPsvqA+YRPIuKXObFF/9KlwvYchhwmT4KXy3GOPCIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KPyDbnJq; arc=none smtp.client-ip=74.125.82.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KPyDbnJq" Received: by mail-dy1-f194.google.com with SMTP id 5a478bee46e88-2b6fd5bec41so3046923eec.1 for ; Tue, 20 Jan 2026 22:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768978137; x=1769582937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QfNI6YqTs0cYKPLMD89dgBVnDvHEsK2S5AP6RZaGePE=; b=KPyDbnJqTI1FAcCQ+1HaDP+MIst5sdxS91MrjGCwMgymx0K18B2H7tHade89Bhq/nt WOK8rsf5OyRt4RpEqKtpjRTFCWeATTrjCtJ3aUx4lshFhHf0pxonxe2GGwASYqyrOakf ztcysKHmNpwrf9gwMn/34MhN1hmOcEJulPfnU5Z+fS89L0b/GbB3DqAbvI+aly2G9K0p o3z/CUdkFItO/YjAC2xTAJ/8APaLXdoMjRnErTj2/fGd1QVEOmChNkCW52j8abpsuvaj KT0JvPzaj7BQnwvwq2Z/QJdZaWzPdR0QdUS2Bwun2x6Ptqj5xFzwSj+k/U/hJ3zl00XS tzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768978137; x=1769582937; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QfNI6YqTs0cYKPLMD89dgBVnDvHEsK2S5AP6RZaGePE=; b=QBjzoZAqb+39g60O3GgR2zkKGVfJB1pN6I2xe62HKMiZZ9wq0Ag/whjZgbRhhbcm0x StQGryBFBLHvsPzyOq765FD2oDVkdQfJI1s+Nhqg1jPiUY6M6wyNk1coCJjqbb16Kxoi 7nricRGCUNLiPsXJ8HaTyiVO4Q0ysl7wfLw02x9gvji9YyXkPdi7C5SquDCGCMGA4J4E chbuoX3G+J0fFhInb8ZVSm/NLE6NjRwfdMQJ6aU0lVkWyTLWqZGeHDUYOaZFjSoziU+a rYrkxv/FpHxRLOfFo7mIFA/Cj5MRxxHC3Es3swGKYd0CCvlqim2Ry0/LEw9Ma/oz6hvs jpDA== X-Forwarded-Encrypted: i=1; AJvYcCUW9TeQs7Vgk/OXzB9hfLYyqNct5Wb16XV8SyZq3wPVPhrAmih61j2BF4DC5BTdXKyWn17ae7ifWfUEA9o=@vger.kernel.org X-Gm-Message-State: AOJu0YxCoDccW5+MWqc+Sc4wjuvBAfv/0khaLHwcDN+Py6obw8eQEnmN OJKF6D8pIytQBbSQ3oriKfeWz3PeezKhk9jvKDH83oDyheQ6gIxf/uMR X-Gm-Gg: AZuq6aJQ5XsLLhHZ3JKCeJ4jBi+0/TTG7eC70aHLvtdXBE2I7DWZ00qgbfkHxAI4IKW IWyQXHTVfSmmRcsygRr6Gw/FCVaijqhZwKJjyw4bI+fSeKtF3W5JMfMHfJIO/9jDJ5xESZpbWTB 2k1Lml06kZOcJKjfJPi8kvbOkGiwTf7dE9bP3AVlHctLL5j9wyEMk2kF5K30YDLMHgIKQfVfBsC pWuyktZ7Bwd0s987Wj+O+gWE+vVyLDfm694p9JzEhxPQl4YsRVK9W1pTclSF149qW3g8ZkBE3ac mppu37tJ62tAf6oFoUUHonXEmQNB61Y5avYEUCAP6sqbyV2j1nTd8d4h2akWSQ36jc+F1DO/XLF +NrdDl4M1XJ5TnGWqTdSUjsdfapHq/oOiyNAP0+zG2Mi/aDsiw/YnWgYG06me2kDgf6IMJriddS Vsqh4= X-Received: by 2002:a05:7301:6086:b0:2af:674e:bc73 with SMTP id 5a478bee46e88-2b6b3f13902mr16692503eec.7.1768978137041; Tue, 20 Jan 2026 22:48:57 -0800 (PST) Received: from debian ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6b34c0e22sm19517053eec.6.2026.01.20.22.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 22:48:56 -0800 (PST) From: Qiliang Yuan To: david@kernel.org Cc: lance.yang@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, weixugc@google.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, rppt@kernel.org, surenb@google.com, jackmanb@google.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qiliang Yuan Subject: [PATCH v5] mm/page_alloc: boost watermarks on atomic allocation failure Date: Wed, 21 Jan 2026 01:48:49 -0500 Message-ID: <20260121064849.34497-1-realwujing@gmail.com> X-Mailer: git-send-email 2.51.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" Atomic allocations (GFP_ATOMIC) are prone to failure under heavy memory pressure as they cannot enter direct reclaim. This patch introduces a 'Soft Boost' mechanism to mitigate this. When a GFP_ATOMIC request fails or enters the slowpath, the preferred zone's watermark_boost is increased. This triggers kswapd to proactively reclaim memory, creating a safety buffer for future atomic bursts. To prevent excessive reclaim during packet storms, a 1-second debounce timer (last_boost_jiffies) is added to each zone to rate-limit boosts. This approach reuses existing watermark_boost infrastructure, ensuring minimal overhead and asynchronous background reclaim via kswapd. Allocation failure logs: [38535644.718700] node 0: slabs: 1031, objs: 43328, free: 0 [38535644.725059] node 1: slabs: 339, objs: 17616, free: 317 [38535645.428345] SLUB: Unable to allocate memory on node -1, gfp=3D0x48002= 0(GFP_ATOMIC) [38535645.436888] cache: skbuff_head_cache, object size: 232, buffer size: = 256, default order: 2, min order: 0 [38535645.447664] node 0: slabs: 940, objs: 40864, free: 144 [38535645.454026] node 1: slabs: 322, objs: 19168, free: 383 [38535645.556122] SLUB: Unable to allocate memory on node -1, gfp=3D0x48002= 0(GFP_ATOMIC) [38535645.564576] cache: skbuff_head_cache, object size: 232, buffer size: = 256, default order: 2, min order: 0 [38535649.655523] warn_alloc: 59 callbacks suppressed [38535649.655527] swapper/100: page allocation failure: order:0, mode:0x480= 020(GFP_ATOMIC), nodemask=3D(null) [38535649.671692] swapper/100 cpuset=3D/ mems_allowed=3D0-1 Signed-off-by: Qiliang Yuan --- v5: - Replaced custom watermark_scale_boost and manual recomputations with=20 native boost_watermark reuse. - Simplified logic to use existing 'boost' architecture for better=20 community acceptability. v4: - Introduced watermark_scale_boost and gradual decay via balance_pgdat. - Added proactive soft-boosting when entering slowpath. v3: - Moved debounce timer to per-zone to avoid cross-node interference. - Optimized candidate zone selection to reduce global reclaim pressure. v2: - Added basic debounce logic and scaled boosting strength based on zone s= ize. v1: - Initial proposal: Basic watermark boost on atomic allocation failure. --- include/linux/mmzone.h | 1 + mm/page_alloc.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 75ef7c9f9307..8e37e4e6765b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -882,6 +882,7 @@ struct zone { /* zone watermarks, access with *_wmark_pages(zone) macros */ unsigned long _watermark[NR_WMARK]; unsigned long watermark_boost; + unsigned long last_boost_jiffies; =20 unsigned long nr_reserved_highatomic; unsigned long nr_free_highatomic; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c380f063e8b7..1faace9e2dc5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2189,12 +2189,31 @@ static inline bool boost_watermark(struct zone *zon= e) =20 max_boost =3D max(pageblock_nr_pages, max_boost); =20 - zone->watermark_boost =3D min(zone->watermark_boost + pageblock_nr_pages, + zone->watermark_boost =3D min(zone->watermark_boost + + max(pageblock_nr_pages, zone_managed_pages(zone) >> 10), max_boost); =20 return true; } =20 +static void boost_zones_for_atomic(struct alloc_context *ac, gfp_t gfp_mas= k) +{ + struct zoneref *z; + struct zone *zone; + unsigned long now =3D jiffies; + + for_each_zone_zonelist(zone, z, ac->zonelist, ac->highest_zoneidx) { + /* 1 second debounce to avoid spamming boosts in a burst */ + if (time_after(now, zone->last_boost_jiffies + HZ)) { + zone->last_boost_jiffies =3D now; + if (boost_watermark(zone)) + wakeup_kswapd(zone, gfp_mask, 0, ac->highest_zoneidx); + /* Only boost the preferred zone to be precise */ + break; + } + } +} + /* * When we are falling back to another migratetype during allocation, shou= ld we * try to claim an entire block to satisfy further allocations, instead of @@ -4742,6 +4761,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int = order, if (page) goto got_pg; =20 + /* Proactively boost for atomic requests entering slowpath */ + if ((gfp_mask & GFP_ATOMIC) && order =3D=3D 0) + boost_zones_for_atomic(ac, gfp_mask); + /* * For costly allocations, try direct compaction first, as it's likely * that we have enough base pages and don't need to reclaim. For non- @@ -4947,6 +4970,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int = order, goto retry; } fail: + /* Boost watermarks on atomic allocation failure to trigger kswapd */ + if (unlikely(page =3D=3D NULL && (gfp_mask & GFP_ATOMIC) && order =3D=3D = 0)) + boost_zones_for_atomic(ac, gfp_mask); + warn_alloc(gfp_mask, ac->nodemask, "page allocation failure: order:%u", order); got_pg: --=20 2.51.0