From 0d4eb1e86ec84fd8e44fadf5fb22a891300ce7b8 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Fri, 28 Feb 2020 12:38:10 -0800 Subject: [PATCH] mm: vmpressure: Interpret zero scanned pages as 100% pressure When no pages are scanned, it usually means no zones were reclaimable and nothing could be done. In this case, the reported pressure should be 100 to elicit help from any listeners. This fixes the vmpressure framework not working when memory pressure is very high. Signed-off-by: Sultan Alsawaf --- mm/vmpressure.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 55c8a1bca3b9..c3dfaecc9c88 100755 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -482,26 +482,25 @@ static void vmpressure_global(gfp_t gfp, unsigned long scanned, unsigned long pressure; unsigned long stall; - if (!scanned) - return; - - spin_lock(&vmpr->sr_lock); - if (!vmpr->scanned) - calculate_vmpressure_win(); + if (scanned) { + spin_lock(&vmpr->sr_lock); + if (!vmpr->scanned) + calculate_vmpressure_win(); - vmpr->scanned += scanned; - vmpr->reclaimed += reclaimed; + vmpr->scanned += scanned; + vmpr->reclaimed += reclaimed; - if (!current_is_kswapd()) - vmpr->stall += scanned; + if (!current_is_kswapd()) + vmpr->stall += scanned; - stall = vmpr->stall; - scanned = vmpr->scanned; - reclaimed = vmpr->reclaimed; - spin_unlock(&vmpr->sr_lock); + stall = vmpr->stall; + scanned = vmpr->scanned; + reclaimed = vmpr->reclaimed; + spin_unlock(&vmpr->sr_lock); - if (scanned < vmpressure_win) - return; + if (scanned < vmpressure_win) + return; + } spin_lock(&vmpr->sr_lock); vmpr->scanned = 0; @@ -509,8 +508,12 @@ static void vmpressure_global(gfp_t gfp, unsigned long scanned, vmpr->stall = 0; spin_unlock(&vmpr->sr_lock); - pressure = vmpressure_calc_pressure(scanned, reclaimed); - pressure = vmpressure_account_stall(pressure, stall, scanned); + if (scanned) { + pressure = vmpressure_calc_pressure(scanned, reclaimed); + pressure = vmpressure_account_stall(pressure, stall, scanned); + } else { + pressure = 100; + } vmpressure_notify(pressure); }