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

Commit 55367947 authored by Vinayak Menon's avatar Vinayak Menon Committed by Patrick Daly
Browse files

lowmemorykiller: avoid false adaptive LMK triggers



In vmpressure notifier of LMK, shift_adj would have been set
by a previous invocation of notifier, which is not followed by
a lowmem_shrink yet. If this is follwed by a lower vmpressure,
and then by a lowmem_shrink, ALMK still triggers because of the
previous higher vmpressure notification. This is wrong.
Since vmpressure has improved, reset shift_adj to avoid false
adaptive LMK trigger.

Change-Id: I2d77103d7c8f4d8a66e4652cba78e619a7bcef9a
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 3e066a00
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -175,6 +175,20 @@ static int lmk_vmpressure_notifier(struct notifier_block *nb,
			atomic_set(&shift_adj, 1);
			trace_almk_vmpressure(pressure, other_free, other_file);
		}
	} else if (atomic_read(&shift_adj)) {
		other_file = global_node_page_state(NR_FILE_PAGES) -
			global_node_page_state(NR_SHMEM) -
			total_swapcache_pages();

		other_free = global_zone_page_state(NR_FREE_PAGES);
		/*
		 * shift_adj would have been set by a previous invocation
		 * of notifier, which is not followed by a lowmem_shrink yet.
		 * Since vmpressure has improved, reset shift_adj to avoid
		 * false adaptive LMK trigger.
		 */
		trace_almk_vmpressure(pressure, other_free, other_file);
		atomic_set(&shift_adj, 0);
	}

	return 0;