diff options
| author | Vinayak Menon <vinmenon@codeaurora.org> | 2015-08-27 16:29:37 +0530 |
|---|---|---|
| committer | Kyle Yan <kyan@codeaurora.org> | 2016-05-31 15:26:37 -0700 |
| commit | af6c02b830fc2e001f3011f0f8244565eb0cc976 (patch) | |
| tree | 1dbdb761cb4cdcd94b49aaa347db9da7ca38901b | |
| parent | f8a4373feae9b2df9490cb10315e5aa0087593b3 (diff) | |
lowmemorykiller: add zcache awareness
zcache stores compressed file pages which should be
considered as reclaimable pages by lowmemorykiller
in calculating values to be compared against minfree.
Change-Id: Ia3e08bc14ba61c0a45ed54ba5cd525717a572060
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
| -rw-r--r-- | drivers/staging/android/lowmemorykiller.c | 11 | ||||
| -rw-r--r-- | include/linux/zcache.h | 22 |
2 files changed, 29 insertions, 4 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index 72e1d437fd1b..07b70358e09c 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -48,6 +48,7 @@ #include <linux/fs.h> #include <linux/cpuset.h> #include <linux/vmpressure.h> +#include <linux/zcache.h> #define CREATE_TRACE_POINTS #include <trace/events/almk.h> @@ -151,7 +152,7 @@ static int lmk_vmpressure_notifier(struct notifier_block *nb, return 0; if (pressure >= 95) { - other_file = global_page_state(NR_FILE_PAGES) - + other_file = global_page_state(NR_FILE_PAGES) + zcache_pages() - global_page_state(NR_SHMEM) - total_swapcache_pages(); other_free = global_page_state(NR_FREE_PAGES); @@ -164,7 +165,7 @@ static int lmk_vmpressure_notifier(struct notifier_block *nb, if (lowmem_minfree_size < array_size) array_size = lowmem_minfree_size; - other_file = global_page_state(NR_FILE_PAGES) - + other_file = global_page_state(NR_FILE_PAGES) + zcache_pages() - global_page_state(NR_SHMEM) - total_swapcache_pages(); @@ -403,8 +404,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) other_free = global_page_state(NR_FREE_PAGES); if (global_page_state(NR_SHMEM) + total_swapcache_pages() < - global_page_state(NR_FILE_PAGES)) - other_file = global_page_state(NR_FILE_PAGES) - + global_page_state(NR_FILE_PAGES) + zcache_pages()) + other_file = global_page_state(NR_FILE_PAGES) + zcache_pages() - global_page_state(NR_SHMEM) - total_swapcache_pages(); else @@ -512,6 +513,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) " Total reserve is %ldkB\n" \ " Total free pages is %ldkB\n" \ " Total file cache is %ldkB\n" \ + " Total zcache is %ldkB\n" \ " GFP mask is 0x%x\n", selected->comm, selected->pid, selected_oom_score_adj, @@ -527,6 +529,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) (long)(PAGE_SIZE / 1024), global_page_state(NR_FILE_PAGES) * (long)(PAGE_SIZE / 1024), + (long)zcache_pages() * (long)(PAGE_SIZE / 1024), sc->gfp_mask); if (lowmem_debug_level >= 2 && selected_oom_score_adj == 0) { diff --git a/include/linux/zcache.h b/include/linux/zcache.h new file mode 100644 index 000000000000..2db7e4bbb662 --- /dev/null +++ b/include/linux/zcache.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef _LINUX_ZCACHE_H +#define _LINUX_ZCACHE_H + +#ifdef CONFIG_ZCACHE +extern u64 zcache_pages(void); +#else +u64 zcache_pages(void) { return 0; } +#endif + +#endif /* _LINUX_ZCACHE_H */ |
