From patchwork Fri Oct 21 08:46:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13014414 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 9CBFBC4332F for ; Fri, 21 Oct 2022 08:32:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EB588E0002; Fri, 21 Oct 2022 04:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09B978E0001; Fri, 21 Oct 2022 04:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECC3A8E0002; Fri, 21 Oct 2022 04:32:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DCD768E0001 for ; Fri, 21 Oct 2022 04:32:23 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F43316116E for ; Fri, 21 Oct 2022 08:32:23 +0000 (UTC) X-FDA: 80044289766.24.3A12477 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf17.hostedemail.com (Postfix) with ESMTP id 7984F40016 for ; Fri, 21 Oct 2022 08:32:20 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MtyCy4cKBzpVWk; Fri, 21 Oct 2022 16:23:42 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:01 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:01 +0800 From: Kefeng Wang To: Naoya Horiguchi , Andrew Morton CC: Miaohe Lin , , , Kefeng Wang Subject: [PATCH 1/3] mm: memory-failure: make put_ref_page() more useful Date: Fri, 21 Oct 2022 16:46:09 +0800 Message-ID: <20221021084611.53765-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666341141; a=rsa-sha256; cv=none; b=mdzIuuL+x0/ElrXPKTVirpH/QLMGSEJMtRdxu85rd+ViSku00UBnO20KVGm2RX4ZmdoGk8 QZiY/awqm6USJHdHXFPlkUTFGRPRipPGwPMzL0e2sAnabGcVNP/EsNzJxraqHxQdmxj4xL 8MHoi3LH83iQ49kfVJ+5T5lO3IS38yE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666341141; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=SvtD7TEzG/7RYfxd+tmpCjijSpKb3RLAE436DHlzYsE=; b=yJVXBwknnic+VH1lYyn+zwLlBz31Qj3PQOMtReNoCmSnYgNCWw/Ys69O4pfzAJJjcXV+4Q HYyxD6VIFCJC+O3itzVY2nSIzs3H/tO+l2WPHkUMPEPR711oXFOu2LP4bMBsJR5hlYzriB cFmHfcD1mVaCjqFhC8P9RGMSw/T+AIE= X-Stat-Signature: 7txfmuco3um75qfy3nbdkqdiwqbwmf7a X-Rspamd-Queue-Id: 7984F40016 Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1666341140-645038 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: Pass pfn/flags to put_ref_page(), then check MF_COUNT_INCREASED and drop refcount to make the code look cleaner. Signed-off-by: Kefeng Wang Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index bead6bccc7f2..b94152abb1c9 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1913,17 +1913,25 @@ static inline unsigned long free_raw_hwp_pages(struct page *hpage, bool flag) } #endif /* CONFIG_HUGETLB_PAGE */ +/* Drop the extra refcount in case we come from madvise() */ +static void put_ref_page(unsigned long pfn, int flags) +{ + struct page *page; + + if (!(flags & MF_COUNT_INCREASED)) + return; + + page = pfn_to_page(pfn); + if (page) + put_page(page); +} + static int memory_failure_dev_pagemap(unsigned long pfn, int flags, struct dev_pagemap *pgmap) { - struct page *page = pfn_to_page(pfn); int rc = -ENXIO; - if (flags & MF_COUNT_INCREASED) - /* - * Drop the extra refcount in case we come from madvise(). - */ - put_page(page); + put_ref_page(pfn, flags); /* device metadata space is not recoverable */ if (!pgmap_pfn_valid(pgmap, pfn)) @@ -2516,12 +2524,6 @@ static int soft_offline_in_use_page(struct page *page) return ret; } -static void put_ref_page(struct page *page) -{ - if (page) - put_page(page); -} - /** * soft_offline_page - Soft offline a page. * @pfn: pfn to soft-offline @@ -2550,19 +2552,17 @@ int soft_offline_page(unsigned long pfn, int flags) { int ret; bool try_again = true; - struct page *page, *ref_page = NULL; + struct page *page; WARN_ON_ONCE(!pfn_valid(pfn) && (flags & MF_COUNT_INCREASED)); if (!pfn_valid(pfn)) return -ENXIO; - if (flags & MF_COUNT_INCREASED) - ref_page = pfn_to_page(pfn); /* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */ page = pfn_to_online_page(pfn); if (!page) { - put_ref_page(ref_page); + put_ref_page(pfn, flags); return -EIO; } @@ -2570,7 +2570,7 @@ int soft_offline_page(unsigned long pfn, int flags) if (PageHWPoison(page)) { pr_info("%s: %#lx page already poisoned\n", __func__, pfn); - put_ref_page(ref_page); + put_ref_page(pfn, flags); mutex_unlock(&mf_mutex); return 0; } From patchwork Fri Oct 21 08:46:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13014445 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 A4E85C433FE for ; Fri, 21 Oct 2022 08:55:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE7558E0002; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C96068E0003; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0F7A8E0002; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9C0048E0001 for ; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6D92A81264 for ; Fri, 21 Oct 2022 08:55:47 +0000 (UTC) X-FDA: 80044348734.14.206F532 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id 2BC494002D for ; Fri, 21 Oct 2022 08:55:43 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MtyBd3zLvzVj4w; Fri, 21 Oct 2022 16:22:33 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:02 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:01 +0800 From: Kefeng Wang To: Naoya Horiguchi , Andrew Morton CC: Miaohe Lin , , , Kefeng Wang Subject: [PATCH 2/3] mm: memory-failure: avoid pfn_valid() twice in soft_offline_page() Date: Fri, 21 Oct 2022 16:46:10 +0800 Message-ID: <20221021084611.53765-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221021084611.53765-1-wangkefeng.wang@huawei.com> References: <20221021084611.53765-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666342547; a=rsa-sha256; cv=none; b=aKmJuw+LmUxjrwVrn7NWceRUH/H1IqdnA/ODiciMmwK8BAixx+txK3DKXi1L7qMtw+3NqQ Ak73dKWv//UCNe9pSf3c3Cmp7qNy7GAD9iNtHr2L4yIv9aoHz/r9Q8wwNg3MhcIWAusicP U+xyR5t9YwJL4XM/ZbD18pG+nIHuyKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666342546; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UU5kiPJznsCXvUnAokOkugtvK9CpUBlArCg9rxWhxEc=; b=3vjAerWbmBPvMokbSIr5YxXc0batd/WU8vI6LgV2P7D0xCc/reXisCRZdTxnCZQ6H+dR+l g6FGgB1Ybadv3aqodvzHIQCnlOk+7OO5eNGYt6LK1kV5tAn/HjwzW31OgPofaHmugJhfju Uenr+JqHuvQazugeBdnEv+7ZbojIdIY= Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: x456gc8ss1pkehir8cupnq599dpdpqwo X-Rspamd-Queue-Id: 2BC494002D X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666342543-662713 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: Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid(). Signed-off-by: Kefeng Wang Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b94152abb1c9..ca0199d0f79d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2554,10 +2554,10 @@ int soft_offline_page(unsigned long pfn, int flags) bool try_again = true; struct page *page; - WARN_ON_ONCE(!pfn_valid(pfn) && (flags & MF_COUNT_INCREASED)); - - if (!pfn_valid(pfn)) + if (!pfn_valid(pfn)) { + WARN_ON_ONCE(flags & MF_COUNT_INCREASED); return -ENXIO; + } /* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */ page = pfn_to_online_page(pfn); From patchwork Fri Oct 21 08:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13014446 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 310E7C4332F for ; Fri, 21 Oct 2022 08:55:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00FF58E0001; Fri, 21 Oct 2022 04:55:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E931F8E0005; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE4A28E0001; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4D428E0001 for ; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8632916128B for ; Fri, 21 Oct 2022 08:55:47 +0000 (UTC) X-FDA: 80044348734.17.66753CE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 08E848003B for ; Fri, 21 Oct 2022 08:55:45 +0000 (UTC) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MtyBp6z82zVj56; Fri, 21 Oct 2022 16:22:42 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:02 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:02 +0800 From: Kefeng Wang To: Naoya Horiguchi , Andrew Morton CC: Miaohe Lin , , , Kefeng Wang Subject: [PATCH 3/3] mm: memory-failure: make action_result() return int Date: Fri, 21 Oct 2022 16:46:11 +0800 Message-ID: <20221021084611.53765-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221021084611.53765-1-wangkefeng.wang@huawei.com> References: <20221021084611.53765-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666342547; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=skbbdds17ZacrWxOgkXX0qdH5w3rkeZiTghVmvfF610=; b=tSghY72rLYBqu5yS845Bvsz0zXeINv/dx9JVjBgUhf2NhJXI5XKSgRWMfqWWWd6obJMIOf 7HXQQLKLpJ93o+kF78csFUKeZi5kBWBUBJvlD7kpr7GjGKKkKGQd9H2qWPZ83kRKYLnQTF IaTuOtRAl2092DkD0dUAv2/6/o952Nw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666342547; a=rsa-sha256; cv=none; b=Akc4CaehtMw5iKeo3nR6/HcviAzZqMaStjFY+0QTbEyHrKZtYUxw0EEBwGBo4UwWPi4crn M0otTpSpBrTzoXrzZtA8/RO/F+QOGeu8gyzi8SaEx06e3ucZgmtbgVPp5m1bECpEUtoTQw tNxw1p1neLvFdDRaDwaII4Q3c+IQTcM= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 08E848003B X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: hpowufbzudgcopbx9isjm8agstxpa58d X-HE-Tag: 1666342545-302749 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: Check mf_result in action_result(), only return 0 when MF_RECOVERED, or return -EBUSY, which will simplify code a bit. Signed-off-by: Kefeng Wang --- mm/memory-failure.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ca0199d0f79d..3f469e2da047 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1182,14 +1182,16 @@ static struct page_state error_states[] = { * "Dirty/Clean" indication is not 100% accurate due to the possibility of * setting PG_dirty outside page lock. See also comment above set_page_dirty(). */ -static void action_result(unsigned long pfn, enum mf_action_page_type type, - enum mf_result result) +static int action_result(unsigned long pfn, enum mf_action_page_type type, + enum mf_result result) { trace_memory_failure_event(pfn, type, result); num_poisoned_pages_inc(); pr_err("%#lx: recovery action for %s: %s\n", pfn, action_page_types[type], action_name[result]); + + return result == MF_RECOVERED ? 0 : -EBUSY; } static int page_action(struct page_state *ps, struct page *p, @@ -1856,8 +1858,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb flags |= MF_NO_RETRY; goto retry; } - action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); - return res; + return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); } head = compound_head(p); @@ -1883,22 +1884,18 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb } else { res = MF_FAILED; } - action_result(pfn, MF_MSG_FREE_HUGE, res); - return res == MF_RECOVERED ? 0 : -EBUSY; + return action_result(pfn, MF_MSG_FREE_HUGE, res); } page_flags = head->flags; if (!hwpoison_user_mappings(p, pfn, flags, head)) { - action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); - res = -EBUSY; - goto out; + res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); + unlock_page(head); + return res; } return identify_page_state(pfn, p, page_flags); -out: - unlock_page(head); - return res; } #else @@ -2063,16 +2060,13 @@ int memory_failure(unsigned long pfn, int flags) } res = MF_FAILED; } - action_result(pfn, MF_MSG_BUDDY, res); - res = res == MF_RECOVERED ? 0 : -EBUSY; + res = action_result(pfn, MF_MSG_BUDDY, res); } else { - action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); } goto unlock_mutex; } else if (res < 0) { - action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); goto unlock_mutex; } } @@ -2093,8 +2087,7 @@ int memory_failure(unsigned long pfn, int flags) */ SetPageHasHWPoisoned(hpage); if (try_to_split_thp_page(p) < 0) { - action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); goto unlock_mutex; } VM_BUG_ON_PAGE(!page_count(p), p); @@ -2127,8 +2120,7 @@ int memory_failure(unsigned long pfn, int flags) retry = false; goto try_again; } - action_result(pfn, MF_MSG_DIFFERENT_COMPOUND, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_DIFFERENT_COMPOUND, MF_IGNORED); goto unlock_page; } @@ -2168,8 +2160,7 @@ int memory_failure(unsigned long pfn, int flags) * Abort on fail: __filemap_remove_folio() assumes unmapped page. */ if (!hwpoison_user_mappings(p, pfn, flags, p)) { - action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); goto unlock_page; } @@ -2177,8 +2168,7 @@ int memory_failure(unsigned long pfn, int flags) * Torn down by someone else? */ if (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) { - action_result(pfn, MF_MSG_TRUNCATED_LRU, MF_IGNORED); - res = -EBUSY; + res = action_result(pfn, MF_MSG_TRUNCATED_LRU, MF_IGNORED); goto unlock_page; }