From nobody Sat Feb 7 16:05:44 2026 Received: from mail-dl1-f68.google.com (mail-dl1-f68.google.com [74.125.82.68]) (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 7A59234CFA1 for ; Thu, 22 Jan 2026 02:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769047676; cv=none; b=N9vacnfmGUjPXD5FjsBVieqvSbTUCEqyKK5r9svMtp8UDt26Zl1Qbp2u9ZqVw2YbASuN8MWLUtdOxPrXBWpl0E6rwQ8K8KwiuCvyaHS2G0gsIfGg8EdIKIVbPXsZ9s+GsN2vtfyQcBgtBRdLTHhtGrb87buHYoL1htzm0xonCqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769047676; c=relaxed/simple; bh=veJ883BXshNbMwe9b2qcWbWT2R5GwwZg36wLGBju1Ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oFiwvryuysn0lK4ZBA18yOIP1dHXDrH5rJ/WzHYkxsLkRNjvvyrDT3zlUbC2ym2ImMPxN7y3toHWoxGiNQ81V8ibDurA8W3frjTDyZxsEyNdunIG/Vyg1gFOpcJeupW5ddHH9+0vpqdlXreWwu1M99pcGuWAdsUg9QnUiyCxyUI= 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=B5jPqRxJ; arc=none smtp.client-ip=74.125.82.68 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="B5jPqRxJ" Received: by mail-dl1-f68.google.com with SMTP id a92af1059eb24-1233b953bebso1158793c88.1 for ; Wed, 21 Jan 2026 18:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769047673; x=1769652473; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uBQb1uczQpL5GIk29gYfa4oCHjDRy2kNRGngnJTqEfM=; b=B5jPqRxJEkAORplOfsx11iCiZS+pN3O8ODaCCbncB4MVc1nlbP2eZw5GqAgvCpFgOA +uI7yJjTSGfuUt9CU4XkYGpCTfClAPcmPwhlpNz+qw937Hwd+CbTZQuRWT1qTezYtB6U bvWa38U3bt1apTW8MaRz3G0Ui92u+wSXA6DBAmlQMVOcCLeLUVodpGMtzUjnGFhBtRO9 Oraj1dneISZZ9c0J6uV0Y9+qU1y4Nn85ElCRM67idEo8ezLbXkzOtvph7lOor1ByiMcP /murvgmIAeIjTXzxZigfcNrS5FFUO5w3kH9mdPgZJ/SJgBjD5VklF3lHLyn3J+Du2U1f gc9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769047673; x=1769652473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uBQb1uczQpL5GIk29gYfa4oCHjDRy2kNRGngnJTqEfM=; b=oektGkLpAcNsnWZFx487hsGunSvFHwLOTaVf//NVQFf5gDMLG6m+HGGo+8Rdt1zlxD j1fN2N7RWJBLFU2C+mU45OyQgG1aca+Nu8XazfB1NuR1d5sgw2huzCtwC7WkJXK+Y5R2 ILN+ByMkCidedZKIBgrnyMsEkWCDohIx2+yLTXs3hD9X4kpZ8Sf2VE/aug57zjYKYKpG mvq4E4cPeekF6CBh6oLKZj7nfNfaV3x+ZnO2DL3lS5xFYSMC2sjd6FW5dqIFgl3krj5M fzfIjnXavFwKvFitfJR0Wl5Sc2hu1yfiO/+xwcvyrcEDP8G5XCAFZsJ1ia3HLoWB+WPx 8W4A== X-Forwarded-Encrypted: i=1; AJvYcCXm/jiuiDG2ys3t6c6NevG9d/eTV0e3BOb6GxQFGNivYe8R93mO/23+W3WFracJbZEodv45IxTA2eCi/PQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/OZ8Yy7d8ys5yGnDbdqAeUgHT3UayPEc3HURyzU0dPlrYRLS2 tknLj53skw9QBM2jdTlChR7GqOmT3wzbM1GERjzDYVWBOhZreiq64Wm2 X-Gm-Gg: AZuq6aL5EFNtkJG+mjA2n6X5OpdankqKKE21886vUxLnEhZCKiHMOVMZzhnmES5NJw/ lHQsxZEwGvzWGkYWhKFEd7v6dmhTNro75UpaSNQ2zP/TOSQ3BWpI94aMxQOXa1KbaPwem6/9fgG J+fLKDxR5sQWGIWGT1yOFkFMI8/YxFImT/EF/2mt7H6fTCd4/Nvj6f8Gfafq+Zr+HaZ80DpwTx1 3yDKc61dfdrO+dA/ZwwBPDdIiC0mkon15TQIn3NwFj8p8H5qzv2l/lbn3ZEV3uTvlFcQyTgx9Po a/m0d4owUqHw4Y6FLLkxu7mlkMS+4HR+pzsNvaM/+Ip+GmbxcG5FLQxB1A5n8Imqh09ah2pHS9u ZRmHfc0dBdJUThS5D71zpYfg2uxj+zdyOYtUTQFHqb4d/HRE8mUQNYmhtDZCO4/UISJg4vCdCeE esfYk= X-Received: by 2002:a05:7022:608b:b0:11b:9386:7ed0 with SMTP id a92af1059eb24-1246aaf0f17mr4977855c88.45.1769047672743; Wed, 21 Jan 2026 18:07:52 -0800 (PST) Received: from debian ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6c2de1f29sm21740486eec.15.2026.01.21.18.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 18:07:52 -0800 (PST) From: Qiliang Yuan To: akpm@linux-foundation.org Cc: david@kernel.org, mhocko@suse.com, vbabka@suse.cz, willy@infradead.org, lance.yang@linux.dev, hannes@cmpxchg.org, surenb@google.com, jackmanb@google.com, ziy@nvidia.com, weixugc@google.com, rppt@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, edumazet@google.com, jis1@chinatelecom.cn, wangh13@chinatelecom.cn, liyi1@chinatelecom.cn, sunshx@chinatelecom.cn, zhangzq20@chinatelecom.cn, zhangjn11@chinatelecom.cn, Qiliang Yuan , Qiliang Yuan Subject: [PATCH v6] mm/page_alloc: boost watermarks on atomic allocation failure Date: Wed, 21 Jan 2026 21:07:42 -0500 Message-ID: <20260122020742.230219-1-realwujing@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260121125603.47b204cc8fbe9466b25cce16@linux-foundation.org> References: <20260121125603.47b204cc8fbe9466b25cce16@linux-foundation.org> 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 Signed-off-by: Qiliang Yuan --- v6: - Replace magic number ">> 10" with ATOMIC_BOOST_SCALE_SHIFT define - Add documentation explaining 0.1% zone size boost rationale v5: - Simplify to use native boost_watermark() instead of custom logic v4: - Add watermark_scale_boost and gradual decay via balance_pgdat v3: - Move debounce timer to per-zone; optimize zone selection v2: - Add debounce logic and zone-proportional boosting v1: - Initial: boost min_free_kbytes on GFP_ATOMIC failure --- include/linux/mmzone.h | 1 + mm/page_alloc.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) --- include/linux/mmzone.h | 1 + mm/page_alloc.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 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..8ea2435125d5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -218,6 +218,13 @@ unsigned int pageblock_order __read_mostly; static void __free_pages_ok(struct page *page, unsigned int order, fpi_t fpi_flags); =20 +/* + * Boost watermarks by ~0.1% of zone size on atomic allocation pressure. + * This provides zone-proportional safety buffers: ~1MB per 1GB of zone si= ze. + * Larger zones under GFP_ATOMIC pressure need proportionally larger reser= ves. + */ +#define ATOMIC_BOOST_SCALE_SHIFT 10 + /* * results with 256, 32 in the lowmem_reserve sysctl: * 1G machine -> (16M dma, 800M-16M normal, 1G-800M high) @@ -2189,12 +2196,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) >> ATOMIC_BOOST_SCALE_S= HIFT), 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 +4768,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 +4977,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