From aedef801945c8374069b4be3ff51566f64049834 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Fri, 8 Feb 2019 18:27:35 +0900 Subject: [PATCH] mm: fix passing active page into shrink_page_list Currently, per-process reclaim calls shrink_page_list several times with zone loop. However, it's pointless that passing pages failed to reclaim in earlier trial. More severe problem is shrink_page_list can mark victim pages as PG_active so next trial of shrink_page_list with those PG_active page in the loop can warn like below. Remove the unncessary loop with zone iterator and just pass NULL as zone argument in shrink_page_list. The shrink_page_list doesn't rely on zone except writeback throttling logic in memory pressure. Since writeback throttling work with global reclaim, per-process reclaim doesn't matter. 02-02 19:07:31.511 1000 1729 1729 F BUG : Bad page state in process CompactionThrea pfn:cd3fa 02-02 19:07:31.511 1000 1729 1729 F page : 0000000000000000 count:0 mapcount:0 mapping:0000000000000000 index:0xbf3a7 02-02 19:07:31.511 1000 1729 1729 F flags : 0x40048(uptodate|active|swapbacked) 02-02 19:07:31.511 1000 1729 1729 F : page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set 02-02 19:07:31.511 1000 1729 1729 F : bad because of flags: 02-02 19:07:31.511 1000 1729 1729 F flags : 0x40(active) 02-02 19:07:31.511 1000 1729 1729 W : Modules linked in: wlan(C) lge_battery sw49408 ftm4 touch_core_base 02-02 19:07:31.511 1000 1729 1729 W : CPU: 6 PID: 1729 Comm: CompactionThrea Tainted: G B WC 4.4.172-g8be3181903c2 #1 02-02 19:07:31.511 1000 1729 1729 W Hardware name: Qualcomm Technologies, Inc. MSM8998 v2.1 (DT) 02-02 19:07:31.511 1000 [PHONE_NUMBER] W Call trace: 02-02 19:07:31.511 1000 1729 1729 W : [] dump_backtrace+0x0/0x3e4 02-02 19:07:31.511 1000 1729 1729 W : [] show_stack+0x14/0x1c 02-02 19:07:31.511 1000 1729 1729 W : [] dump_stack+0xcc/0x104 02-02 19:07:31.511 1000 1729 1729 W : [] bad_page+0xe8/0x11c 02-02 19:07:31.511 1000 1729 1729 W : [] free_pages_prepare+0x264/0x274 02-02 19:07:31.511 1000 1729 1729 W : [] free_hot_cold_page+0x38/0x21c 02-02 19:07:31.511 1000 1729 1729 W : [] free_hot_cold_page_list+0xec/0x110 02-02 19:07:31.511 1000 1729 1729 W : [] shrink_page_list+0x988/0xa90 02-02 19:07:31.511 1000 1729 1729 W : [] reclaim_pages+0x220/0x30c 02-02 19:07:31.511 1000 1729 1729 W : [] reclaim_pmd_range+0x13c/0x218 02-02 19:07:31.511 1000 1729 1729 W : [] __walk_page_range+0xf4/0x204 02-02 19:07:31.511 1000 1729 1729 W : [] walk_page_range+0xf8/0x12c 02-02 19:07:31.511 1000 1729 1729 W : [] reclaim_write+0x1e0/0x244 02-02 19:07:31.511 1000 1729 1729 W : [] vfs_write+0xd0/0x240 02-02 19:07:31.511 1000 1729 1729 W : [] SyS_write+0x54/0xb4 02-02 19:07:31.511 1000 1729 1729 W : [] __sys_trace_return+0x0/0x4 Bug: 123834127 Change-Id: I8ced217f6a2d33983d02bfdf7bad7957c4cf7a18 Signed-off-by: Minchan Kim --- mm/vmscan.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index da23f0ff37ec..dccb841c1dcd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -969,7 +969,6 @@ static unsigned long shrink_page_list(struct list_head *page_list, goto keep; VM_BUG_ON_PAGE(PageActive(page), page); - VM_BUG_ON_PAGE(page_zone(page) != zone, page); sc->nr_scanned++; @@ -1048,7 +1047,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, /* Case 1 above */ if (current_is_kswapd() && PageReclaim(page) && - test_bit(ZONE_WRITEBACK, &zone->flags)) { + (zone && test_bit(ZONE_WRITEBACK, &zone->flags))) { nr_immediate++; goto keep_locked; @@ -1133,8 +1132,9 @@ static unsigned long shrink_page_list(struct list_head *page_list, * if many dirty pages have been encountered. */ if (page_is_file_cache(page) && - (!current_is_kswapd() || - !test_bit(ZONE_DIRTY, &zone->flags))) { + (!current_is_kswapd() || + !(zone && + test_bit(ZONE_DIRTY, &zone->flags)))) { /* * Immediately reclaim when written back. * Similar in principal to deactivate_page() @@ -1349,12 +1349,9 @@ unsigned long reclaim_pages(struct list_head *page_list) mod_zone_page_state(zone, NR_ISOLATED_FILE, nr_isolated[1][i]); } - for (i = 0; i < MAX_NR_ZONES; i++) { - zone = pgdat->node_zones + i; - nr_reclaimed += shrink_page_list(page_list, zone, &sc, + nr_reclaimed = shrink_page_list(page_list, NULL, &sc, TTU_UNMAP|TTU_IGNORE_ACCESS, &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, true); - } while (!list_empty(page_list)) { page = lru_to_page(page_list);