mm/vmscan: count layzfree pages and fix nr_isolated_* mismatch
Fix an nr_isolate_* mismatch problem between cma and dirty lazyfree pages. If try_to_unmap_one is used for reclaim and it detects a dirty lazyfree page, then the lazyfree page is changed to a normal anon page having SwapBacked by commit802a3a92ad
("mm: reclaim MADV_FREE pages"). Even with the change, reclaim context correctly counts isolated files because it uses is_file_lru to distinguish file. And the change to anon is not happened if try_to_unmap_one is used for migration. So migration context like compaction also correctly counts isolated files even though it uses page_is_file_lru insted of is_file_lru. Recently page_is_file_cache was renamed to page_is_file_lru by commit9de4f22a60
("mm: code cleanup for MADV_FREE"). But the nr_isolate_* mismatch problem happens on cma alloc. There is reclaim_clean_pages_from_list which is being used only by cma. It was introduced by commit02c6de8d75
("mm: cma: discard clean pages during contiguous allocation instead of migration") to reclaim clean file pages without migration. The cma alloc uses both reclaim_clean_pages_from_list and migrate_pages, and it uses page_is_file_lru to count isolated files. If there are dirty lazyfree pages allocated from cma memory region, the pages are counted as isolated file at the beginging but are counted as isolated anon after finished. Mem-Info: Node 0 active_anon:3045904kB inactive_anon:611448kB active_file:14892kB inactive_file:205636kB unevictable:10416kB isolated(anon):0kB isolated(file):37664kB mapped:630216kB dirty:384kB writeback:0kB shmem:42576kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no Like log above, there were too much isolated files, 37664kB, which triggers too_many_isolated in reclaim even when there is no actually isolated file in system wide. It could be reproducible by running two programs, writing on MADV_FREE page and doing cma alloc, respectively. Although isolated anon is 0, I found that the internal value of isolated anon was the negative value of isolated file. Fix this by compensating the isolated count for both LRU lists. Count non-discarded lazyfree pages in shrink_page_list, then compensate the counted number in reclaim_clean_pages_from_list. Reported-by: Yong-Taek Lee <ytk.lee@samsung.com> Suggested-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Michal Nazarewicz <mina86@mina86.com> Cc: Shaohua Li <shli@fb.com> Link: http://lkml.kernel.org/r/20200426011718.30246-1-jaewon31.kim@samsung.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
a892cb6b97
Коммит
1f318a9b0d
|
@ -29,6 +29,7 @@ struct reclaim_stat {
|
||||||
unsigned nr_activate[2];
|
unsigned nr_activate[2];
|
||||||
unsigned nr_ref_keep;
|
unsigned nr_ref_keep;
|
||||||
unsigned nr_unmap_fail;
|
unsigned nr_unmap_fail;
|
||||||
|
unsigned nr_lazyfree_fail;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum writeback_stat_item {
|
enum writeback_stat_item {
|
||||||
|
|
26
mm/vmscan.c
26
mm/vmscan.c
|
@ -1295,11 +1295,15 @@ static unsigned long shrink_page_list(struct list_head *page_list,
|
||||||
*/
|
*/
|
||||||
if (page_mapped(page)) {
|
if (page_mapped(page)) {
|
||||||
enum ttu_flags flags = ttu_flags | TTU_BATCH_FLUSH;
|
enum ttu_flags flags = ttu_flags | TTU_BATCH_FLUSH;
|
||||||
|
bool was_swapbacked = PageSwapBacked(page);
|
||||||
|
|
||||||
if (unlikely(PageTransHuge(page)))
|
if (unlikely(PageTransHuge(page)))
|
||||||
flags |= TTU_SPLIT_HUGE_PMD;
|
flags |= TTU_SPLIT_HUGE_PMD;
|
||||||
|
|
||||||
if (!try_to_unmap(page, flags)) {
|
if (!try_to_unmap(page, flags)) {
|
||||||
stat->nr_unmap_fail += nr_pages;
|
stat->nr_unmap_fail += nr_pages;
|
||||||
|
if (!was_swapbacked && PageSwapBacked(page))
|
||||||
|
stat->nr_lazyfree_fail += nr_pages;
|
||||||
goto activate_locked;
|
goto activate_locked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1491,8 +1495,8 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
|
||||||
.priority = DEF_PRIORITY,
|
.priority = DEF_PRIORITY,
|
||||||
.may_unmap = 1,
|
.may_unmap = 1,
|
||||||
};
|
};
|
||||||
struct reclaim_stat dummy_stat;
|
struct reclaim_stat stat;
|
||||||
unsigned long ret;
|
unsigned long nr_reclaimed;
|
||||||
struct page *page, *next;
|
struct page *page, *next;
|
||||||
LIST_HEAD(clean_pages);
|
LIST_HEAD(clean_pages);
|
||||||
|
|
||||||
|
@ -1504,11 +1508,21 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = shrink_page_list(&clean_pages, zone->zone_pgdat, &sc,
|
nr_reclaimed = shrink_page_list(&clean_pages, zone->zone_pgdat, &sc,
|
||||||
TTU_IGNORE_ACCESS, &dummy_stat, true);
|
TTU_IGNORE_ACCESS, &stat, true);
|
||||||
list_splice(&clean_pages, page_list);
|
list_splice(&clean_pages, page_list);
|
||||||
mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, -ret);
|
mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, -nr_reclaimed);
|
||||||
return ret;
|
/*
|
||||||
|
* Since lazyfree pages are isolated from file LRU from the beginning,
|
||||||
|
* they will rotate back to anonymous LRU in the end if it failed to
|
||||||
|
* discard so isolated count will be mismatched.
|
||||||
|
* Compensate the isolated count for both LRU lists.
|
||||||
|
*/
|
||||||
|
mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_ANON,
|
||||||
|
stat.nr_lazyfree_fail);
|
||||||
|
mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE,
|
||||||
|
-stat.nr_lazyfree_fail);
|
||||||
|
return nr_reclaimed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче