From 26a1450ce963cb56e344873e90beadaf5d1206cb 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 Signed-off-by: Ruchit --- mm/vmpressure.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 79207bd5f729..44ce6a010b2e 100755 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -369,26 +369,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; @@ -396,8 +395,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); }