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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C77C433F5 for ; Mon, 21 Mar 2022 02:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344154AbiCUCTd (ORCPT ); Sun, 20 Mar 2022 22:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344147AbiCUCT2 (ORCPT ); Sun, 20 Mar 2022 22:19:28 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3A441EEFF for ; Sun, 20 Mar 2022 19:18:03 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> >> > > . >