From c375dad93bd2ec9f63dbedd6db6090a32806e93c Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Tue, 18 Feb 2020 22:39:41 -0800 Subject: [PATCH] simple_lmk: Include swap memory usage in the size of victims Swap memory usage is important when determining what to kill, so include it in the victim size calculation. Signed-off-by: Sultan Alsawaf --- drivers/android/simple_lmk.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/android/simple_lmk.c b/drivers/android/simple_lmk.c index 3372fe21962d..215ee674d82d 100644 --- a/drivers/android/simple_lmk.c +++ b/drivers/android/simple_lmk.c @@ -75,6 +75,17 @@ static bool vtsk_is_duplicate(int vlen, struct task_struct *vtsk) return false; } +static unsigned long get_total_mm_pages(struct mm_struct *mm) +{ + unsigned long pages = 0; + int i; + + for (i = 0; i < NR_MM_COUNTERS; i++) + pages += get_mm_counter(mm, i); + + return pages; +} + static unsigned long find_victims(int *vindex, short target_adj) { unsigned long pages_found = 0; @@ -108,7 +119,7 @@ static unsigned long find_victims(int *vindex, short target_adj) /* Store this potential victim away for later */ victims[*vindex].tsk = vtsk; victims[*vindex].mm = vtsk->mm; - victims[*vindex].size = get_mm_rss(vtsk->mm); + victims[*vindex].size = get_total_mm_pages(vtsk->mm); /* Keep track of the number of pages that have been found */ pages_found += victims[*vindex].size;