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 <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
fourteen
Sultan Alsawaf 5 years ago committed by Jenna
parent 2641839440
commit 26a1450ce9
  1. 39
      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);
}

Loading…
Cancel
Save