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 <sultan@kerneltoast.com>
fourteen
Sultan Alsawaf 5 years ago committed by Jenna
parent f52583d0f0
commit c375dad93b
  1. 13
      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;

Loading…
Cancel
Save