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

Commit c1c69b87 authored by Liam Mark's avatar Liam Mark Committed by Vinayak Menon
Browse files

android/lowmemorykiller: Account for total_swapcache_pages



The lowmemorykiller relies on NR_FILE_PAGES when measuring
the amount of reclaimable memory in the system.
However when swap is enabled swap cache pages are counted
in NR_FILE_PAGES, and swap cache pages aren't as reclaimable
in low memory as file cache pages. Therefore a large swap
cache can result in the lowmemorykiller not running and
an OOM occurring.

In order to ensure the lowmemorykiller properly evaluates the
amount of reclaimable memory don't count the swap cache pages.

Change-Id: I38239283e572f814b277c718eaf6be7f92abacbb
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 06a5f877
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/swap.h>
#include <linux/fs.h>

#ifdef CONFIG_HIGHMEM
#define _ZONE ZONE_HIGHMEM
@@ -282,10 +283,16 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
		return 0;

	other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;

	if (global_node_page_state(NR_SHMEM) + total_swapcache_pages() +
			global_node_page_state(NR_UNEVICTABLE) <
			global_node_page_state(NR_FILE_PAGES))
		other_file = global_node_page_state(NR_FILE_PAGES) -
					global_node_page_state(NR_SHMEM) -
					global_node_page_state(NR_UNEVICTABLE) -
					total_swapcache_pages();
	else
		other_file = 0;

	tune_lmk_param(&other_free, &other_file, sc);