Skip to content

Commit 597c892

Browse files
hnaztorvalds
authored andcommitted
mm: don't wake kswapd prematurely when watermark boosting is disabled
On 2-node NUMA hosts we see bursts of kswapd reclaim and subsequent pressure spikes and stalls from cache refaults while there is plenty of free memory in the system. Usually, kswapd is woken up when all eligible nodes in an allocation are full. But the code related to watermark boosting can wake kswapd on one full node while the other one is mostly empty. This may be justified to fight fragmentation, but is currently unconditionally done whether watermark boosting is occurring or not. In our case, many of our workloads' throughput scales with available memory, and pure utilization is a more tangible concern than trends around longer-term fragmentation. As a result we generally disable watermark boosting. Wake kswapd only woken when watermark boosting is requested. Link: https://lkml.kernel.org/r/20201020175833.397286-1-hannes@cmpxchg.org Fixes: 1c30844 ("mm: reclaim small amounts of memory when an external fragmentation event occurs") Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7fc2513 commit 597c892

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mm/page_alloc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,20 +2482,20 @@ static bool can_steal_fallback(unsigned int order, int start_mt)
24822482
return false;
24832483
}
24842484

2485-
static inline void boost_watermark(struct zone *zone)
2485+
static inline bool boost_watermark(struct zone *zone)
24862486
{
24872487
unsigned long max_boost;
24882488

24892489
if (!watermark_boost_factor)
2490-
return;
2490+
return false;
24912491
/*
24922492
* Don't bother in zones that are unlikely to produce results.
24932493
* On small machines, including kdump capture kernels running
24942494
* in a small area, boosting the watermark can cause an out of
24952495
* memory situation immediately.
24962496
*/
24972497
if ((pageblock_nr_pages * 4) > zone_managed_pages(zone))
2498-
return;
2498+
return false;
24992499

25002500
max_boost = mult_frac(zone->_watermark[WMARK_HIGH],
25012501
watermark_boost_factor, 10000);
@@ -2509,12 +2509,14 @@ static inline void boost_watermark(struct zone *zone)
25092509
* boosted watermark resulting in a hang.
25102510
*/
25112511
if (!max_boost)
2512-
return;
2512+
return false;
25132513

25142514
max_boost = max(pageblock_nr_pages, max_boost);
25152515

25162516
zone->watermark_boost = min(zone->watermark_boost + pageblock_nr_pages,
25172517
max_boost);
2518+
2519+
return true;
25182520
}
25192521

25202522
/*
@@ -2552,8 +2554,7 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,
25522554
* likelihood of future fallbacks. Wake kswapd now as the node
25532555
* may be balanced overall and kswapd will not wake naturally.
25542556
*/
2555-
boost_watermark(zone);
2556-
if (alloc_flags & ALLOC_KSWAPD)
2557+
if (boost_watermark(zone) && (alloc_flags & ALLOC_KSWAPD))
25572558
set_bit(ZONE_BOOSTED_WATERMARK, &zone->flags);
25582559

25592560
/* We are not allowed to try stealing from the whole block */

0 commit comments

Comments
 (0)