mm/page_alloc: boost watermarks on atomic allocation failure
Subsystems (4)
PATCH v8 1/1 mm/page_alloc: boost watermarks on atomic allocation failure
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=0x480020(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=0x480020(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:0x480020(GFP_ATOMIC), nodemask=(null) [38535649.671692] swapper/100 cpuset=/ mems_allowed=0-1
---
---
v8:
- Use spin_lock_irqsave() to prevent inconsistent lock state (softirq-on vs in-softirq) as reported by LKP.
v7:
- Use local variable for boost_amount to improve code readability
- Add zone->lock protection in boost_zones_for_atomic()
- Add lockdep assertion in boost_watermark() to prevent locking mistakes
- Remove redundant boost call at fail label due to 1-second debounce
- Link: https://lore.kernel.org/all/[email protected]/
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 | 48 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-)
include/linux/mmzone.h +1 -0
@@ -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;unsigned long nr_reserved_highatomic;unsigned long nr_free_highatomic;
mm/page_alloc.c +46 -2
76 lines not on this page · raw message
Signature · 1 line
2.51.0