From nobody Sun Jun 28 01:52:19 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 DA9D1C433FE for ; Wed, 16 Feb 2022 09:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbiBPJPa (ORCPT ); Wed, 16 Feb 2022 04:15:30 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbiBPJP2 (ORCPT ); Wed, 16 Feb 2022 04:15:28 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D95B7217F99 for ; Wed, 16 Feb 2022 01:15:15 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4JzBzZ32yVz8wkc; Wed, 16 Feb 2022 17:11: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.2308.21; Wed, 16 Feb 2022 17:15:13 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 1/8] mm/memory-failure.c: minor clean up for memory_failure_dev_pagemap Date: Wed, 16 Feb 2022 17:14:24 +0800 Message-ID: <20220216091431.39406-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" The flags always has MF_ACTION_REQUIRED and MF_MUST_KILL set. So we do not need to check these flags again. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 55edb0cc3848..b3ff7e99a421 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1644,7 +1644,7 @@ static int memory_failure_dev_pagemap(unsigned long p= fn, int flags, * SIGBUS (i.e. MF_MUST_KILL) */ flags |=3D MF_ACTION_REQUIRED | MF_MUST_KILL; - collect_procs(page, &tokill, flags & MF_ACTION_REQUIRED); + collect_procs(page, &tokill, true); =20 list_for_each_entry(tk, &tokill, nd) if (tk->size_shift) @@ -1659,7 +1659,7 @@ static int memory_failure_dev_pagemap(unsigned long p= fn, int flags, start =3D (page->index << PAGE_SHIFT) & ~(size - 1); unmap_mapping_range(page->mapping, start, size, 0); } - kill_procs(&tokill, flags & MF_MUST_KILL, false, pfn, flags); + kill_procs(&tokill, true, false, pfn, flags); rc =3D 0; unlock: dax_unlock_page(page, cookie); --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 BA7F6C4332F for ; Wed, 16 Feb 2022 09:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbiBPJPc (ORCPT ); Wed, 16 Feb 2022 04:15:32 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbiBPJP2 (ORCPT ); Wed, 16 Feb 2022 04:15:28 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C0C217FA0 for ; Wed, 16 Feb 2022 01:15:15 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JzC274JMpzbkV6; Wed, 16 Feb 2022 17:14:07 +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; Wed, 16 Feb 2022 17:15:13 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 2/8] mm/memory-failure.c: catch unexpected -EFAULT from vma_address() Date: Wed, 16 Feb 2022 17:14:25 +0800 Message-ID: <20220216091431.39406-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" It's unexpected to walk the page table when vma_address() return -EFAULT. But dev_pagemap_mapping_shift() is called only when vma associated to the error page is found already in collect_procs_{file,anon}, so vma_address() should not return -EFAULT except with some bug, as Naoya pointed out. We can use VM_BUG_ON_VMA() to catch this bug here. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b3ff7e99a421..eaa241058401 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -315,6 +315,7 @@ static unsigned long dev_pagemap_mapping_shift(struct p= age *page, pmd_t *pmd; pte_t *pte; =20 + VM_BUG_ON_VMA(address =3D=3D -EFAULT, vma); pgd =3D pgd_offset(vma->vm_mm, address); if (!pgd_present(*pgd)) return 0; --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 821BDC433EF for ; Wed, 16 Feb 2022 09:15:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbiBPJPf (ORCPT ); Wed, 16 Feb 2022 04:15:35 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6717219224 for ; Wed, 16 Feb 2022 01:15:16 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JzC282pQNzcbhC; Wed, 16 Feb 2022 17:14:08 +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; Wed, 16 Feb 2022 17:15:14 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 3/8] mm/memory-failure.c: rework the signaling logic in kill_proc Date: Wed, 16 Feb 2022 17:14:26 +0800 Message-ID: <20220216091431.39406-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" BUS_MCEERR_AR code is only sent when MF_ACTION_REQUIRED is set and the target is current. Rework the code to make this clear. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index eaa241058401..7e205d91b2d7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -258,16 +258,13 @@ static int kill_proc(struct to_kill *tk, unsigned lon= g pfn, int flags) pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware mem= ory corruption\n", pfn, t->comm, t->pid); =20 - if (flags & MF_ACTION_REQUIRED) { - if (t =3D=3D current) - ret =3D force_sig_mceerr(BUS_MCEERR_AR, - (void __user *)tk->addr, addr_lsb); - else - /* Signal other processes sharing the page if they have PF_MCE_EARLY se= t. */ - ret =3D send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr, - addr_lsb, t); - } else { + if ((flags & MF_ACTION_REQUIRED) && (t =3D=3D current)) + ret =3D force_sig_mceerr(BUS_MCEERR_AR, + (void __user *)tk->addr, addr_lsb); + else /* + * Signal other processes sharing the page if they have + * PF_MCE_EARLY set. * Don't use force here, it's convenient if the signal * can be temporarily blocked. * This could cause a loop when the user sets SIGBUS @@ -275,7 +272,6 @@ static int kill_proc(struct to_kill *tk, unsigned long = pfn, int flags) */ ret =3D send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr, addr_lsb, t); /* synchronous? */ - } if (ret < 0) pr_info("Memory failure: Error sending signal to %s:%d: %d\n", t->comm, t->pid, ret); --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 447C9C4332F for ; Wed, 16 Feb 2022 09:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbiBPJPs (ORCPT ); Wed, 16 Feb 2022 04:15:48 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231941AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AE121CC8C for ; Wed, 16 Feb 2022 01:15:17 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JzByP2Vqdz1FCsp; Wed, 16 Feb 2022 17:10:53 +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; Wed, 16 Feb 2022 17:15:14 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 4/8] mm/memory-failure.c: fix race with changing page more robustly Date: Wed, 16 Feb 2022 17:14:27 +0800 Message-ID: <20220216091431.39406-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" We're only intended to deal with the non-Compound page after we split thp in memory_failure. However, the page could have changed compound pages due to race window. If this happens, we could try again to hopefully handle the page next round. Also remove unneeded orig_head. It's always equal to the hpage. So we can use hpage directly and remove this redundant one. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7e205d91b2d7..d66f642888be 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1690,7 +1690,6 @@ int memory_failure(unsigned long pfn, int flags) { struct page *p; struct page *hpage; - struct page *orig_head; struct dev_pagemap *pgmap; int res =3D 0; unsigned long page_flags; @@ -1736,7 +1735,7 @@ int memory_failure(unsigned long pfn, int flags) goto unlock_mutex; } =20 - orig_head =3D hpage =3D compound_head(p); + hpage =3D compound_head(p); num_poisoned_pages_inc(); =20 /* @@ -1817,13 +1816,18 @@ int memory_failure(unsigned long pfn, int flags) lock_page(p); =20 /* - * The page could have changed compound pages during the locking. - * If this happens just bail out. + * We're only intended to deal with the non-Compound page here. + * However, the page could have changed compound pages due to + * race window. If this happens, we could try again to hopefully + * handle the page next round. */ - if (PageCompound(p) && compound_head(p) !=3D orig_head) { - action_result(pfn, MF_MSG_DIFFERENT_COMPOUND, MF_IGNORED); - res =3D -EBUSY; - goto unlock_page; + if (PageCompound(p)) { + if (TestClearPageHWPoison(p)) + num_poisoned_pages_dec(); + unlock_page(p); + put_page(p); + flags &=3D ~MF_COUNT_INCREASED; + goto try_again; } =20 /* --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 A6171C433F5 for ; Wed, 16 Feb 2022 09:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbiBPJPh (ORCPT ); Wed, 16 Feb 2022 04:15:37 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B64B921CC85 for ; Wed, 16 Feb 2022 01:15:17 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JzByP5RRvz1FDBT; Wed, 16 Feb 2022 17:10:53 +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; Wed, 16 Feb 2022 17:15:15 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 5/8] mm/memory-failure.c: remove PageSlab check in hwpoison_filter_dev Date: Wed, 16 Feb 2022 17:14:28 +0800 Message-ID: <20220216091431.39406-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" Since commit 03e5ac2fc3bf ("mm: fix crash when using XFS on loopback"), page_mapping() can handle the Slab pages. So remove this unnecessary PageSlab check and obsolete comment. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d66f642888be..791d89e0c15a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -130,12 +130,6 @@ static int hwpoison_filter_dev(struct page *p) hwpoison_filter_dev_minor =3D=3D ~0U) return 0; =20 - /* - * page_mapping() does not accept slab pages. - */ - if (PageSlab(p)) - return -EINVAL; - mapping =3D page_mapping(p); if (mapping =3D=3D NULL || mapping->host =3D=3D NULL) return -EINVAL; --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 21747C433F5 for ; Wed, 16 Feb 2022 09:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232003AbiBPJPj (ORCPT ); Wed, 16 Feb 2022 04:15:39 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875C1219C27 for ; Wed, 16 Feb 2022 01:15:17 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JzC2966Frzcd1q; Wed, 16 Feb 2022 17:14:09 +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; Wed, 16 Feb 2022 17:15:15 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 6/8] mm/memory-failure.c: rework the try_to_unmap logic in hwpoison_user_mappings() Date: Wed, 16 Feb 2022 17:14:29 +0800 Message-ID: <20220216091431.39406-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" Only for hugetlb pages in shared mappings, try_to_unmap should take semaphore in write mode here. Rework the code to make it clear. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 791d89e0c15a..0100d4f9da9a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1404,26 +1404,22 @@ static bool hwpoison_user_mappings(struct page *p, = unsigned long pfn, if (kill) collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED); =20 - if (!PageHuge(hpage)) { - try_to_unmap(hpage, ttu); + if (PageHuge(hpage) && !PageAnon(hpage)) { + /* + * For hugetlb pages in shared mappings, try_to_unmap + * could potentially call huge_pmd_unshare. Because of + * this, take semaphore in write mode here and set + * TTU_RMAP_LOCKED to indicate we have taken the lock + * at this higher level. + */ + mapping =3D hugetlb_page_mapping_lock_write(hpage); + if (mapping) { + try_to_unmap(hpage, ttu|TTU_RMAP_LOCKED); + i_mmap_unlock_write(mapping); + } else + pr_info("Memory failure: %#lx: could not lock mapping for mapped huge p= age\n", pfn); } else { - if (!PageAnon(hpage)) { - /* - * For hugetlb pages in shared mappings, try_to_unmap - * could potentially call huge_pmd_unshare. Because of - * this, take semaphore in write mode here and set - * TTU_RMAP_LOCKED to indicate we have taken the lock - * at this higher level. - */ - mapping =3D hugetlb_page_mapping_lock_write(hpage); - if (mapping) { - try_to_unmap(hpage, ttu|TTU_RMAP_LOCKED); - i_mmap_unlock_write(mapping); - } else - pr_info("Memory failure: %#lx: could not lock mapping for mapped huge = page\n", pfn); - } else { - try_to_unmap(hpage, ttu); - } + try_to_unmap(hpage, ttu); } =20 unmap_success =3D !page_mapped(hpage); --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 06CCEC433FE for ; Wed, 16 Feb 2022 09:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232038AbiBPJPm (ORCPT ); Wed, 16 Feb 2022 04:15:42 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0071F21CCB2 for ; Wed, 16 Feb 2022 01:15:17 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JzC296Kg0zbkWc; Wed, 16 Feb 2022 17:14:09 +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; Wed, 16 Feb 2022 17:15:16 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 7/8] mm/memory-failure.c: remove obsolete comment in __soft_offline_page Date: Wed, 16 Feb 2022 17:14:30 +0800 Message-ID: <20220216091431.39406-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" Since commit add05cecef80 ("mm: soft-offline: don't free target page in successful page migration"), set_migratetype_isolate logic is removed. Remove this obsolete comment. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0100d4f9da9a..5d2e653a145d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2165,10 +2165,6 @@ static int __soft_offline_page(struct page *page) ret =3D invalidate_inode_page(page); unlock_page(page); =20 - /* - * RED-PEN would be better to keep it isolated here, but we - * would need to fix isolation locking first. - */ if (ret) { pr_info("soft_offline: %#lx: invalidated\n", pfn); page_handle_poison(page, false, true); --=20 2.23.0 From nobody Sun Jun 28 01:52:19 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 249E6C433EF for ; Wed, 16 Feb 2022 09:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbiBPJPo (ORCPT ); Wed, 16 Feb 2022 04:15:44 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbiBPJP3 (ORCPT ); Wed, 16 Feb 2022 04:15:29 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6482D21D0A2 for ; Wed, 16 Feb 2022 01:15:18 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JzByR1kmSz1FCXG; Wed, 16 Feb 2022 17:10: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.2308.21; Wed, 16 Feb 2022 17:15:16 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 8/8] mm/memory-failure.c: remove unnecessary PageTransTail check Date: Wed, 16 Feb 2022 17:14:31 +0800 Message-ID: <20220216091431.39406-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220216091431.39406-1-linmiaohe@huawei.com> References: <20220216091431.39406-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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 Content-Type: text/plain; charset="utf-8" When we reach here, we're guaranteed to have non-compound page as thp is already splited. Remove this unnecessary PageTransTail check. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- 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 5d2e653a145d..6e7baa90214a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1842,7 +1842,7 @@ int memory_failure(unsigned long pfn, int flags) * page_lock. We need wait writeback completion for this page or it * may trigger vfs BUG while evict inode. */ - if (!PageTransTail(p) && !PageLRU(p) && !PageWriteback(p)) + if (!PageLRU(p) && !PageWriteback(p)) goto identify_page_state; =20 /* --=20 2.23.0