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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86BB4C433F5 for ; Mon, 21 Mar 2022 02:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70CBC6B0072; Sun, 20 Mar 2022 22:18:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BC126B0073; Sun, 20 Mar 2022 22:18:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 582C76B0074; Sun, 20 Mar 2022 22:18:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 4899F6B0072 for ; Sun, 20 Mar 2022 22:18:07 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1076120A3A for ; Mon, 21 Mar 2022 02:18:07 +0000 (UTC) X-FDA: 79266783414.09.ED3EE8D Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 3E431C001E for ; Mon, 21 Mar 2022 02:18:06 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KMJC25BjNzfYqW; Mon, 21 Mar 2022 10:16:30 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 21 Mar 2022 10:18:01 +0800 Subject: Re: [PATCH v4 1/2] mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages To: Matthew Wilcox CC: , , , , , , References: <20220320051334.44502-1-linmiaohe@huawei.com> <20220320051334.44502-2-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <0d5f2c97-992b-442c-9ecf-26ba363461aa@huawei.com> Date: Mon, 21 Mar 2022 10:18:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3E431C001E X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: 7yrrkzeq8mamwqzibxg61qxewpa5dk3n X-Rspamd-Server: rspam07 X-HE-Tag: 1647829086-564481 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 2022/3/20 0:20, Matthew Wilcox wrote: > On Sun, Mar 20, 2022 at 01:13:33PM +0800, Miaohe Lin wrote: >> invalidate_inode_page() can invalidate the pages in the swap cache because >> the check of page->mapping != mapping is removed via Matthew's patch titled >> "mm/truncate: Inline invalidate_complete_page() into its one caller". But >> invalidate_inode_page() is not expected to deal with the pages in the swap >> cache. Also non-lru movable page can reach here too. They're not page cache >> pages. Skip these pages by checking PageSwapCache and PageLRU to fix this >> unexpected issue. > > I disagree with this changelog. > > invalidate_inode_page() should not be called for pages which are not > in the page cache. > > And then the patch shouldn't test PageLRU (which is actually wrong) or > PageSwapCache(). It should simply be: > > + if (!PageHuge(page) && !PageAnon(page)) If we reach here, the page can be one of the PageHuge, __PageMovable and PageLRU. If above code is used, __PageMovable can pass the check and enter the invalidate_inode_page unexpectedly. So I think PageLRU check is necessary here. But it seems PageSwapCache is only reliable when PageAnon, so might we should do: + if (!PageHuge(page) && PageLRU(page) && !PageAnon(page)) Am I miss something? Many thanks for comment. > >> Signed-off-by: Miaohe Lin >> --- >> mm/memory-failure.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index 5444a8ef4867..ecf45961f3b6 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -2178,7 +2178,7 @@ static int __soft_offline_page(struct page *page) >> return 0; >> } >> >> - if (!PageHuge(page)) >> + if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page)) >> /* >> * Try to invalidate first. This should work for >> * non dirty unmapped page cache pages. >> -- >> 2.23.0 >> >> > > . >