lowmemorykiller: Don't count swap cache pages twice

The lowmem_shrink function discounts all the swap cache pages from
the file cache count. The zone aware code also discounts all file
cache pages from a certain zone.  This results in some swap cache
pages being discounted twice, which can result in the low memory
killer being unnecessarily aggressive.

Fix the low memory killer to only discount the swap cache pages
once.

Change-Id: I650bbfbf0fbbabd01d82bdb3502b57ff59c3e14f
Signed-off-by: Liam Mark <lmark@codeaurora.org>
This commit is contained in:
Liam Mark 2015-02-27 12:59:00 -08:00
parent e4e704c1ff
commit 137caf0a41
4 changed files with 6 additions and 1 deletions

View file

@ -144,7 +144,8 @@ void tune_lmk_zone_param(struct zonelist *zonelist, int classzone_idx,
if (other_file != NULL)
*other_file -= zone_page_state(zone,
NR_FILE_PAGES)
- zone_page_state(zone, NR_SHMEM);
- zone_page_state(zone, NR_SHMEM)
- zone_page_state(zone, NR_SWAPCACHE);
} else if (zone_idx < classzone_idx) {
if (zone_watermark_ok(zone, 0, 0, classzone_idx, 0) &&
other_free) {

View file

@ -153,6 +153,7 @@ enum zone_stat_item {
#endif
NR_ANON_TRANSPARENT_HUGEPAGES,
NR_FREE_CMA_PAGES,
NR_SWAPCACHE,
NR_VM_ZONE_STAT_ITEMS };
/*

View file

@ -98,6 +98,7 @@ int __add_to_swap_cache(struct page *page, swp_entry_t entry)
if (likely(!error)) {
address_space->nrpages++;
__inc_zone_page_state(page, NR_FILE_PAGES);
__inc_zone_page_state(page, NR_SWAPCACHE);
INC_CACHE_INFO(add_total);
}
spin_unlock_irq(&address_space->tree_lock);
@ -150,6 +151,7 @@ void __delete_from_swap_cache(struct page *page)
ClearPageSwapCache(page);
address_space->nrpages--;
__dec_zone_page_state(page, NR_FILE_PAGES);
__dec_zone_page_state(page, NR_SWAPCACHE);
INC_CACHE_INFO(del_total);
}

View file

@ -742,6 +742,7 @@ const char * const vmstat_text[] = {
#endif
"nr_anon_transparent_hugepages",
"nr_free_cma",
"nr_swapcache",
"nr_dirty_threshold",
"nr_dirty_background_threshold",