From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CEADCA9EAE for ; Tue, 29 Oct 2019 09:31:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E96D62086D for ; Tue, 29 Oct 2019 09:31:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E96D62086D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9B8B56B0005; Tue, 29 Oct 2019 05:31:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 990136B0006; Tue, 29 Oct 2019 05:31:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87ED56B0007; Tue, 29 Oct 2019 05:31:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 658A66B0005 for ; Tue, 29 Oct 2019 05:31:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 064DF181AF5C6 for ; Tue, 29 Oct 2019 09:31:05 +0000 (UTC) X-FDA: 76096303290.09.bite04_43577dd9b4334 X-HE-Tag: bite04_43577dd9b4334 X-Filterd-Recvd-Size: 5719 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Oct 2019 09:31:02 +0000 (UTC) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A40846C8899226C8A06E; Tue, 29 Oct 2019 17:30:59 +0800 (CST) Received: from [127.0.0.1] (10.133.219.218) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Tue, 29 Oct 2019 17:30:58 +0800 Message-ID: <5DB806D1.8020503@huawei.com> Date: Tue, 29 Oct 2019 17:30:57 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Michal Hocko CC: , , , , Minchan Kim Subject: Re: [PATCH] mm: fix unevictable page reclaim when calling madvise_pageout References: <1572275317-63910-1-git-send-email-zhongjiang@huawei.com> <20191029081102.GB31513@dhcp22.suse.cz> In-Reply-To: <20191029081102.GB31513@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.219.218] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2019/10/29 16:11, Michal Hocko wrote: > [Cc Minchan] > > On Mon 28-10-19 23:08:37, zhong jiang wrote: >> Recently, I hit the following issue when running in the upstream. >> >> kernel BUG at mm/vmscan.c:1521! >> invalid opcode: 0000 [#1] SMP KASAN PTI >> CPU: 0 PID: 23385 Comm: syz-executor.6 Not tainted 5.4.0-rc4+ #1 >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 >> RIP: 0010:shrink_page_list+0x12b6/0x3530 mm/vmscan.c:1521 >> Code: de f5 ff ff e8 ab 79 eb ff 4c 89 f7 e8 43 33 0d 00 e9 cc f5 ff ff e8 99 79 eb ff 48 c7 c6 a0 34 2b a0 4c 89 f7 e8 1a 4d 05 00 <0f> 0b e8 83 79 eb ff 48 89 d8 48 c1 e8 03 42 80 3c 38 00 0f 85 74 >> RSP: 0018:ffff88819a3df5a0 EFLAGS: 00010286 >> RAX: 0000000000040000 RBX: ffffea00061c3980 RCX: ffffffff814fba36 >> RDX: 00000000000056f7 RSI: ffffc9000c02c000 RDI: ffff8881f70268cc >> RBP: ffff88819a3df898 R08: ffffed103ee05de0 R09: ffffed103ee05de0 >> R10: 0000000000000001 R11: ffffed103ee05ddf R12: ffff88819a3df6f0 >> R13: ffff88819a3df6f0 R14: ffffea00061c3980 R15: dffffc0000000000 >> FS: 00007f21b9d8e700(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000 >> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> CR2: 0000001b2d621000 CR3: 00000001c8c46004 CR4: 00000000007606f0 >> DR0: 0000000020000140 DR1: 0000000000000000 DR2: 0000000000000000 >> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600 >> PKRU: 55555554 >> Call Trace: >> reclaim_pages+0x499/0x800 mm/vmscan.c:2188 >> madvise_cold_or_pageout_pte_range+0x58a/0x710 mm/madvise.c:453 >> walk_pmd_range mm/pagewalk.c:53 [inline] >> walk_pud_range mm/pagewalk.c:112 [inline] >> walk_p4d_range mm/pagewalk.c:139 [inline] >> walk_pgd_range mm/pagewalk.c:166 [inline] >> __walk_page_range+0x45a/0xc20 mm/pagewalk.c:261 >> walk_page_range+0x179/0x310 mm/pagewalk.c:349 >> madvise_pageout_page_range mm/madvise.c:506 [inline] >> madvise_pageout+0x1f0/0x330 mm/madvise.c:542 >> madvise_vma mm/madvise.c:931 [inline] >> __do_sys_madvise+0x7d2/0x1600 mm/madvise.c:1113 >> do_syscall_64+0x9f/0x4c0 arch/x86/entry/common.c:290 >> entry_SYSCALL_64_after_hwframe+0x49/0xbe >> >> madvise_pageout access the specified range of the vma and isolate >> them, then run shrink_page_list to reclaim the memory. But It also >> isolate the unevictable page to reclaim. Hence, we can catch the >> cases in shrink_page_list. >> >> We can fix it by preventing unevictable page from isolating. >> Another way to fix the issue by removing the condition of >> BUG_ON(PageUnevictable(page)) in shrink_page_list. I think it >> is better to use the latter. Because We has taken the unevictable >> page and skip it into account in shrink_page_list. > The justification is indeed not clear. This is essentially the same kind > of bug as a58f2cef26e1 ("mm/vmscan.c: fix trying to reclaim unevictable > LRU page") which has been fixed by checking PageUnevictable before > adding it to the list of pages to reclaim. According to the above some bugfix from Minchan and keep the long existing BUG_ON. Maybe It is better to do that. > Removing a long existing BUG_ON begs for a much better explanation. > shrink_page_list is not a trivial piece of code but I _suspect_ that > removing it should be ok for mapped pages at least (try_to_unmap) but I > am not so sure how unmapped unevictable pages are handled from top of my > head. As to the unmapped unevictable pages. shrink_page_list has taken that into account. shinkr_page_list page_evictable --> will filter the unevictable pages to putback its lru. That should be not a problem after removing the BUG_ON. > Please also ad Fixes: $sha Will add in v2. Thanks >> Signed-off-by: zhong jiang >> --- >> mm/vmscan.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index f7d1301..1c6e959 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -1524,7 +1524,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, >> unlock_page(page); >> keep: >> list_add(&page->lru, &ret_pages); >> - VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page), page); >> + VM_BUG_ON_PAGE(PageLRU(page), page); >> } >> >> pgactivate = stat->nr_activate[0] + stat->nr_activate[1]; >> -- >> 1.7.12.4 >>