From 80d9ce54d508435fba17b35a8d6ec269aed1e8e2 Mon Sep 17 00:00:00 2001 From: Vinayak Menon Date: Wed, 19 Aug 2015 16:11:04 +0530 Subject: [PATCH] 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. Since vmpressure has improved, reset shift_adj to avoid false adaptive LMK trigger. Change-Id: I2d77103d7c8f4d8a66e4652cba78e619a7bcef9a Signed-off-by: Vinayak Menon --- drivers/staging/android/lowmemorykiller.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index 54cf4c1c6..cb82b62ea 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -202,7 +202,7 @@ int adjust_minadj(short *min_score_adj) static int lmk_vmpressure_notifier(struct notifier_block *nb, unsigned long action, void *data) { - int other_free, other_file; + int other_free = 0, other_file = 0; unsigned long pressure = action; int array_size = ARRAY_SIZE(lowmem_adj); @@ -235,6 +235,15 @@ static int lmk_vmpressure_notifier(struct notifier_block *nb, trace_almk_vmpressure(pressure, other_free, other_file); } + } else if (atomic_read(&shift_adj)) { + /* + * 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;