From patchwork Fri Mar 18 07:39:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12783879 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 1BA54C433FE for ; Thu, 17 Mar 2022 11:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83A496B0071; Thu, 17 Mar 2022 07:04:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EA388D0002; Thu, 17 Mar 2022 07:04:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D9258D0001; Thu, 17 Mar 2022 07:04:28 -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 60FC86B0071 for ; Thu, 17 Mar 2022 07:04:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E847233B2 for ; Thu, 17 Mar 2022 11:04:28 +0000 (UTC) X-FDA: 79253594616.02.E7EBF48 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf09.hostedemail.com (Postfix) with ESMTP id 2BB22140012 for ; Thu, 17 Mar 2022 11:04:27 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KK41Y6LnMz9shJ; Thu, 17 Mar 2022 19:00:33 +0800 (CST) Received: from huawei.com (10.175.124.27) 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; Thu, 17 Mar 2022 19:04:23 +0800 From: Miaohe Lin To: , , , CC: , , Subject: [PATCH v3 1/2] mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages Date: Fri, 18 Mar 2022 15:39:44 +0800 Message-ID: <20220318073945.62164-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220318073945.62164-1-linmiaohe@huawei.com> References: <20220318073945.62164-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2BB22140012 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: 1ehyuyrwuewbaeyxqa6wwudqtwb56117 X-Rspamd-Server: rspam07 X-HE-Tag: 1647515067-843214 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: 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. 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.