From nobody Thu Apr 2 20:38:41 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 361E313D891 for ; Fri, 13 Feb 2026 03:18:08 +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=1770952689; cv=none; b=EJ4TwJwvW84r/d9VP3NtVYKje79YRAy+j1vO8/2Z4lxByW2Zs6V/HnvyNb5lhbWlLf4AP1M4LNK/Bth7hozJjZ7/meWOJFRBY53QBh0cuZOkv/2GAPfqOa2SRWwnNEXpSDKNcSbMVeQPQGX9bi5uPeNgjZmBIL+64HSkptdL5P0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770952689; c=relaxed/simple; bh=AQ5p3KN5AvnXKHUNcWuNr0sSRUqI6mNTUmxlpOa0NDc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=m9fRO/ovzQXJzOTvbAs58vwNs9TS6sfDPzziGPixQEA45XABVfjYcKkWJUjBLxGgBUa/srWkz5P0SJa3UfwKJ1x4Vr8nRHkZj+1zPlpQsTIBI4F8UdBrYHSKeLaq1JtCrRi5W2y+t57M8HSsYDMVIAumLz0t+cT8LczIn7sXUCY= 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=HbawJ5fg; 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="HbawJ5fg" Received: by mail-dl1-f66.google.com with SMTP id a92af1059eb24-12713e56abdso375979c88.1 for ; Thu, 12 Feb 2026 19:18:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770952687; x=1771557487; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=uzinu5cvWSVigsPPlyALTMaWKR2jEut1B9F+0mvA3UE=; b=HbawJ5fgWUdidLrsFCjHzITXv4TRjCtxk6IzmwIqjxtLldJx5ZAtmMdF8PQiVn1fZH qSGQt3xPuqs1pDT8sfv0O7m9YUVkblYQjC7hZ85xUx5T3+GYKW/5rVwQeZZiKdWtbwHM Yl+FCys7LR9jxB10qamB3SE/p732AC6b/iUFUM0HxQ73Adv9qLjQaUSvoX3udeMFBeqP e/stWVrDPtQ3ywHGZKHJjepMgI5JXmPLFDqBH2oslETjzDLnFtHzPIfvUNHLZKK8nraQ r3PFnGU4psrQ+4YgthMatTQzgLpA3IKGPtj1xyYhRQZ5R/Atu7Ejxea2+s8dco3uQ0Ls +HPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770952687; x=1771557487; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uzinu5cvWSVigsPPlyALTMaWKR2jEut1B9F+0mvA3UE=; b=RjnL3+XijQOhSgXHDWdcY2mVqQ8FAQrLCbjl00v1LLfVy40SI61Xmw28tbKAZWCIgG DlS7xmbzsV4Y5syg/ij5Ebjsf4leEqn4HtsCv/pUYhNTuZbHVRkVLwm9KmVpyFebDq7U EpRopKWs/C9l9pBe9IQlfIcydlo0zU5pmMBn0EHiUCTYUIF49yXXhAfZBdrbMRIby021 nFvHIM5bQ0HeHVZhni3Rbhg/7W5ae4DpOTsIs1Tc84+9aPH/s3ICoevyx5ty1eoPCBGa YWHA+EwTB1Zb2iri7NGnH0to4CdYsRYyX8jmMJGHGPUfX+6XkhFJSgwdWL8O35v+4IIo KYdA== X-Forwarded-Encrypted: i=1; AJvYcCXEb3N8OMS4mznfFJoV9Qt+stRPGsKTJYqtb2dgsKzmPwvEV0nnkZY8C1xiufuIfQwm7iWVoXKTiu/J42Y=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx0py/fghk4C4WpEqNtiUlWoUqYbw653TIVjaGS/aXzoxLyyv+ 7nrv7Jb0iLILyl4Cj88v5aV5tbSaBqF3HBTlD1jc6qzeU+6N9X2D3qso X-Gm-Gg: AZuq6aKpoTB/yr16nzv/f8sQrOosdIsO6xITOC/iffDOBto4L08xRmwsXBOF1jWNIQK uw0OQHGpFtDEvxNJCywtFYbwooQL8rRkVzJeSnOctX7fQwRdaYBIzR8PWWMhXTHzPSGwNNbrMNZ nd+mTd+tA9VVVKBNpTCU/6QTLXS80MjKIH5F2arF2ZgLvi9XnHIgVmOVjmeRgSzUWA/x/o0U47O /kn+Ipildffd5ixIF9TpQ8ISJagRVnEzTLE0rM+9AgW05JAboG+F6EF5A7gTgSNOeoQA6W0h8T6 a2J/LA2CkpzReXCgxTJNBxG98Vw6w0NtvjC62j7QvTiR+4KP8iU200syDpf+3DhrW7nfyukVPcF dBoOzs1p2i6a251QLCx4enAey20/DCvmjBsKKeSGhczkt5PyC3gCbKq6L6j6PxtEXVwPtGCSuRN cue1JQGgLnaNiV4zQuObYCiTuXHTo= X-Received: by 2002:a05:7022:51b:b0:119:e569:f86c with SMTP id a92af1059eb24-1273a909415mr204652c88.9.1770952687193; Thu, 12 Feb 2026 19:18:07 -0800 (PST) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1272a694059sm6802187c88.2.2026.02.12.19.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 19:18:06 -0800 (PST) From: Qiliang Yuan Date: Fri, 13 Feb 2026 11:17:59 +0800 Subject: [PATCH v9] mm/page_alloc: boost watermarks on atomic allocation failure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260213-wujing-mm-page_alloc-v8-v9-1-cd99f3a6cb70@gmail.com> X-B4-Tracking: v=1; b=H4sIAOaXjmkC/3WNwQqDMBBEf0X23C0xgjU99T9Eyhpj3GKMJK1tE f+9qfRamMsbmDcrRBPYRDhnKwSzcGQ/JVCHDPRAkzXIXWKQQpZCihKfjxtPFp3Dmay50jh6jUu FfZurk2pJl72BtJ6D6fm1m+sm8cDx7sN7P1qqb/tz5vKvMyXHjloqKqWE7oqLdcTjUXsHzbZtH 0Sfo/++AAAA To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Axel Rasmussen , Yuanchu Xie , Wei Xu , Brendan Jackman , Johannes Weiner , Zi Yan , Lance Yang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Atomic allocations (GFP_ATOMIC) are prone to failure under heavy memory pressure as they cannot enter direct reclaim. This patch introduces a watermark boost mechanism to mitigate this issue. When a GFP_ATOMIC request enters the slowpath, the preferred zone's watermark_boost is increased under zone->lock protection. This triggers kswapd to proactively reclaim memory, creating a safety buffer for future atomic allocations. A 1-second debounce timer prevents excessive boosts during traffic bursts. This approach reuses existing watermark_boost infrastructure with minimal overhead and proper locking to ensure thread safety. 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 Acked-by: Vlastimil Babka Signed-off-by: Qiliang Yuan --- v9: - Use mult_frac() for boost calculation. (SJ) - Add !can_direct_reclaim check. (Vlastimil) - Code cleanup: naming, scope, and line limits. (SJ) - Update tags: Add Vlastimil's Acked-by. v8: - Use spin_lock_irqsave() to prevent inconsistent lock state. v7: - Use local variable for boost_amount. - Add zone->lock protection. - Add lockdep assertion. v6: - Use ATOMIC_BOOST_SCALE_SHIFT define. - Add documentation for 0.1% rationale. v5: - Use native boost_watermark(). v4: - Add watermark_scale_boost and gradual decay. v3: - Per-zone debounce timer. v2: - Debounce logic and zone-proportional boosting. v1: - Initial version. --- Link to v8: https://lore.kernel.org/r/20260212-wujing-mm-page_alloc-v8-v8-1= -daba38990cd3@gmail.com --- include/linux/mmzone.h | 1 + mm/page_alloc.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++= +-- 2 files changed, 48 insertions(+), 2 deletions(-) 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..8af88584a8bd 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_FACTOR 1 + /* * results with 256, 32 in the lowmem_reserve sysctl: * 1G machine -> (16M dma, 800M-16M normal, 1G-800M high) @@ -2161,6 +2168,9 @@ bool pageblock_unisolate_and_move_free_pages(struct z= one *zone, struct page *pag static inline bool boost_watermark(struct zone *zone) { unsigned long max_boost; + unsigned long boost_amount; + + lockdep_assert_held(&zone->lock); =20 if (!watermark_boost_factor) return false; @@ -2189,12 +2199,43 @@ 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, - max_boost); + boost_amount =3D max(pageblock_nr_pages, + mult_frac(zone_managed_pages(zone), ATOMIC_BOOST_FACTOR, 1000)); + zone->watermark_boost =3D min(zone->watermark_boost + boost_amount, + max_boost); =20 return true; } =20 +static void boost_zone_for_atomic(struct alloc_context *ac, gfp_t gfp_mask) +{ + struct zoneref *z; + struct zone *zone; + unsigned long now =3D jiffies; + + for_each_zone_zonelist(zone, z, ac->zonelist, ac->highest_zoneidx) { + /* Rate-limit boosts to once per second per zone */ + if (time_after(now, zone->last_boost_jiffies + HZ)) { + unsigned long flags; + bool should_wake; + + zone->last_boost_jiffies =3D now; + + /* Modify watermark under lock, wake kswapd outside */ + spin_lock_irqsave(&zone->lock, flags); + should_wake =3D boost_watermark(zone); + spin_unlock_irqrestore(&zone->lock, flags); + + if (should_wake) + wakeup_kswapd(zone, gfp_mask, 0, + ac->highest_zoneidx); + + /* Boost only the preferred zone */ + 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 +4783,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int = order, if (page) goto got_pg; =20 + /* Boost watermarks for atomic requests entering slowpath */ + if ((gfp_mask & GFP_ATOMIC) && order =3D=3D 0 && !can_direct_reclaim) + boost_zone_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- --- base-commit: b54345928fa1dbde534e32ecaa138678fd5d2135 change-id: 20260206-wujing-mm-page_alloc-v8-fb1979bac6fe Best regards, --=20 Qiliang Yuan