From nobody Thu May 14 09:20:56 2026 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 D824EC433F5 for ; Thu, 7 Apr 2022 13:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231562AbiDGNF5 (ORCPT ); Thu, 7 Apr 2022 09:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343604AbiDGNFp (ORCPT ); Thu, 7 Apr 2022 09:05:45 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 511F725C5A6 for ; Thu, 7 Apr 2022 06:03:24 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KZ1l22cf4zdZhx; Thu, 7 Apr 2022 21:02:54 +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.2375.24; Thu, 7 Apr 2022 21:03:22 +0800 From: Miaohe Lin To: , CC: , , , , , Subject: [PATCH 1/3] mm/memory-failure.c: avoid false-postive PageSwapCache test Date: Thu, 7 Apr 2022 21:03:50 +0800 Message-ID: <20220407130352.15618-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220407130352.15618-1-linmiaohe@huawei.com> References: <20220407130352.15618-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" PageSwapCache is only reliable when PageAnon is true because PG_swapcache serves as PG_owner_priv_1 which can be used by fs if it's pagecache page. So we should test PageAnon to distinguish pagecache page from swapcache page to avoid false-postive PageSwapCache test. 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 ef402b490663..2e97302d62e4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2262,7 +2262,7 @@ static int __soft_offline_page(struct page *page) return 0; } =20 - if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page)) + if (!PageHuge(page) && PageLRU(page) && !PageAnon(page)) /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages. --=20 2.23.0 From nobody Thu May 14 09:20:56 2026 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 4EB56C433EF for ; Thu, 7 Apr 2022 13:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239991AbiDGNGH (ORCPT ); Thu, 7 Apr 2022 09:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343517AbiDGNFq (ORCPT ); Thu, 7 Apr 2022 09:05:46 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7EA925CBB3 for ; Thu, 7 Apr 2022 06:03:24 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KZ1l31llVz1HBd3; Thu, 7 Apr 2022 21:02:55 +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.2375.24; Thu, 7 Apr 2022 21:03:22 +0800 From: Miaohe Lin To: , CC: , , , , , Subject: [PATCH 2/3] mm/memory-failure.c: minor cleanup for HWPoisonHandlable Date: Thu, 7 Apr 2022 21:03:51 +0800 Message-ID: <20220407130352.15618-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220407130352.15618-1-linmiaohe@huawei.com> References: <20220407130352.15618-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The local variable movable can be removed by returning true directly. Also fix typo 'mirgate'. No functional change intended. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi Reviewed-by: David Hildenbrand Reviewed-by: Yang Shi --- mm/memory-failure.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 2e97302d62e4..bd563f47630c 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1180,13 +1180,11 @@ void ClearPageHWPoisonTakenOff(struct page *page) */ static inline bool HWPoisonHandlable(struct page *page, unsigned long flag= s) { - bool movable =3D false; - - /* Soft offline could mirgate non-LRU movable pages */ + /* Soft offline could migrate non-LRU movable pages */ if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page)) - movable =3D true; + return true; =20 - return movable || PageLRU(page) || is_free_buddy_page(page); + return PageLRU(page) || is_free_buddy_page(page); } =20 static int __get_hwpoison_page(struct page *page, unsigned long flags) --=20 2.23.0 From nobody Thu May 14 09:20:56 2026 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 7E6F8C433EF for ; Thu, 7 Apr 2022 13:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343548AbiDGNGK (ORCPT ); Thu, 7 Apr 2022 09:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343539AbiDGNFq (ORCPT ); Thu, 7 Apr 2022 09:05:46 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D4B25CBBE for ; Thu, 7 Apr 2022 06:03:25 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KZ1hv5s5wzFpbF; Thu, 7 Apr 2022 21:01:03 +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.2375.24; Thu, 7 Apr 2022 21:03:23 +0800 From: Miaohe Lin To: , CC: , , , , , Subject: [PATCH 3/3] mm/memory-failure.c: dissolve truncated hugetlb page Date: Thu, 7 Apr 2022 21:03:52 +0800 Message-ID: <20220407130352.15618-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220407130352.15618-1-linmiaohe@huawei.com> References: <20220407130352.15618-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If me_huge_page meets a truncated huge page, hpage won't be dissolved even if we hold the last refcnt. It's because the truncated huge page has NULL page_mapping while it's not anonymous page too. Thus we lose the last chance to dissolve it into buddy to save healthy subpages. Remove PageAnon check to handle these huge pages too. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index bd563f47630c..3f054dbb169d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1046,8 +1046,7 @@ static int me_huge_page(struct page_state *ps, struct= page *p) * hugepage, so we can free and dissolve it into buddy to * save healthy subpages. */ - if (PageAnon(hpage)) - put_page(hpage); + put_page(hpage); if (__page_handle_poison(p)) { page_ref_inc(p); res =3D MF_RECOVERED; --=20 2.23.0