From nobody Sun Feb 8 04:11:48 2026 Received: from mail-dl1-f66.google.com (mail-dl1-f66.google.com [74.125.82.66]) (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 C7D5136CE0F for ; Wed, 21 Jan 2026 06:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768978680; cv=none; b=N+3l6XnFSb66KvYZC0YmPIL0TED4pmzgEjEEmvFLkL5zqA+bzLEtidHDJADrWTmADI2Vc2j0kiLhLqHX7zCoAU1LUZyN4Q8nnff62aPdjh+C0cirojs7rNs4rb7wkcjpd9l125E4Xo5DF9ftQRzWEKz8WjS7Vj2TgF6N7fKspdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768978680; c=relaxed/simple; bh=aDjNJbPbwfemekUP+XVYRKuu9vVvYAefjFFyv0oZPfY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Obo6xi9RIifQSWYviGk0ZPGV0Ws3/vq1C6E8PYltzBrKXTqDAV3euAwMLP6apI1YLwMri+AOdumT/uUcFPjzPtbn8Lcu/dhOd1Y28cKdzekdnuNYoOOT7rlhFsGNT8XbD1SPg3uU7XD62JrMMsKyGk/ATm+Z3O4cVxb8kBSkVRI= 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=iosH0DQf; arc=none smtp.client-ip=74.125.82.66 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="iosH0DQf" Received: by mail-dl1-f66.google.com with SMTP id a92af1059eb24-12448c4d404so5204742c88.1 for ; Tue, 20 Jan 2026 22:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768978673; x=1769583473; 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=iosH0DQfZRY3durV0llaHNUnCWzfd+RMeJDnsTifJ0oiS2dHWS48bla2n/wx9pwmeE lwGxtup9iUep6T34T7g7SC4zdnIT0mzx5ZlsttyhAHV36EdHXuep24jR5kzy2DIIKpGq oZDUtIcLBAZQnpkQhDpwk5n1m5EdizSFzte8ZXggqMF2aO70FmuIMiD7wgbN57k2WIV2 9xvTZdXD4gTQ8xZLZB34B84/QlQom4+zKnZfktUOJUr8gP99HDTLjb/tUrXOdLxIDiRg 5HRy44L+A0snVpqPyho1LTfZnanevUByMm06m8xrcf6A80jUbCAdvBi2DpbwAT6xa1wX f8iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768978673; x=1769583473; 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=U0xYo/gCRtGlmFnMDraYtWJE50sj/xEir/yRuTCr9eZovXvwTtF1X6MNNpB4Z35PXZ 3Q+uhgWMYnsJBeim0Um4jAlN5jBqYeJkeGQVcNuLqoJADEfJ6yLMZovH+L1K4EqkqJia LGBI5JcIgvneDrpm0aFvwe7q62ejjaNL9ez9d55sTurHk9TgeGjatZHVf8H+0EKzf8Km QY4DiID2AyG7zbxxnbeVODEW+I/18QrNTfsK+L3a2n7JHhpxbbmgdcPl19kccmvZ6DLJ yD/BwKql1OYRPct8sXHOSTBLphCn9l/QBFXImphgzCrDRUvJ/3zUJiIIJeJ9LZTrx7Qs 68fQ== X-Forwarded-Encrypted: i=1; AJvYcCV5iK+WPdnnPLfkIb/g8Nf+or821rIBKQkx48qv7vKMrU8TAZQZMhBCuAVEPfZ58EHiSibqRcDSoAaJwO0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4jv7Z/a7hSUeoo5NSCEGvFoTYzKGhxM8MwScwb4chsrj5Xo8+ 4Env7iLnNqgW3ORjtf+1/uING8dzy9OZsOwWbONyyKhOTs1yGlRKPiTz X-Gm-Gg: AZuq6aKhJK7GmX00DGOWkVT//fryxJQwas94i+AyCV1uqz50BfLmczG8huiGTVDBQ3g UgaFftYxCzaaF2KRJmukcr4BYG37rW7+WDMaa+oQabjlFrFLZT6jb3CJBErna73L8fgAJAUu9no WJvV3jsfxDQR9uGgdtenXJB/zenDcaHV7wTvq+yO/MDy7cTvsyskVbi8NVddAJS3LrY+Z4pa12/ 9DCiPGq/2TIVLjOpQaeSk32wk0xUXABU7QzAv8FyosALa5pH0T820Iym6iARpcWR3hrzKSDary/ Xa/+sQlPnMEqPN1E64nhmFrsLGURqnPDCqWDjRAKpOfKNDa0JWMIYZ2F/PlsGgDTzVgrWykPkBq 7cxhtF2VJQdBmTlAwVYmvBjNzCpDyQLZUdzS6anUjCDxG9+ba+JBbNxUBBQ8c/lDysc3F00N4QB rAcgk= X-Received: by 2002:a05:7022:2491:b0:11b:9e5e:1a40 with SMTP id a92af1059eb24-1246a9669a1mr2718620c88.15.1768978672473; Tue, 20 Jan 2026 22:57:52 -0800 (PST) Received: from debian ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1244aefa7c5sm25194468c88.10.2026.01.20.22.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 22:57:51 -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, Qiliang Yuan Subject: [PATCH v5] mm/page_alloc: boost watermarks on atomic allocation failure Date: Wed, 21 Jan 2026 01:57:40 -0500 Message-ID: <20260121065740.35616-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