Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1449de51 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm: vmpressure: fix sending wrong events on underflow"

parents 3e089813 9dd531d8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -149,8 +149,15 @@ static unsigned long vmpressure_calc_pressure(unsigned long scanned,
						    unsigned long reclaimed)
{
	unsigned long scale = scanned + reclaimed;
	unsigned long pressure;
	unsigned long pressure = 0;

	/*
	 * reclaimed can be greater than scanned in cases
	 * like THP, where the scanned is 1 and reclaimed
	 * could be 512
	 */
	if (reclaimed >= scanned)
		goto out;
	/*
	 * We calculate the ratio (in percents) of how many pages were
	 * scanned vs. reclaimed in a given time frame (window). Note that
@@ -161,6 +168,7 @@ static unsigned long vmpressure_calc_pressure(unsigned long scanned,
	pressure = scale - (reclaimed * scale / scanned);
	pressure = pressure * 100 / scale;

out:
	pr_debug("%s: %3lu  (s: %lu  r: %lu)\n", __func__, pressure,
		 scanned, reclaimed);