From patchwork Thu Aug 4 12:07:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luofei X-Patchwork-Id: 12936314 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 48285C19F2C for ; Thu, 4 Aug 2022 12:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94D5D8E0002; Thu, 4 Aug 2022 08:08:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FD118E0001; Thu, 4 Aug 2022 08:08:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C4548E0002; Thu, 4 Aug 2022 08:08:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6B4D78E0001 for ; Thu, 4 Aug 2022 08:08:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1A05DA0449 for ; Thu, 4 Aug 2022 12:08:14 +0000 (UTC) X-FDA: 79761787308.29.C279739 Received: from spam.unicloud.com (gw.haihefund.cn [220.194.70.58]) by imf13.hostedemail.com (Postfix) with ESMTP id 8E8D220135 for ; Thu, 4 Aug 2022 12:08:11 +0000 (UTC) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 274C7r4m014658; Thu, 4 Aug 2022 20:07:53 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from zgys-ex-mb09.Unicloud.com (10.10.0.24) by zgys-ex-mb10.Unicloud.com (10.10.0.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Thu, 4 Aug 2022 20:07:53 +0800 Received: from zgys-ex-mb09.Unicloud.com ([fe80::eda0:6815:ca71:5aa]) by zgys-ex-mb09.Unicloud.com ([fe80::eda0:6815:ca71:5aa%16]) with mapi id 15.01.2375.017; Thu, 4 Aug 2022 20:07:53 +0800 From: =?eucgb2312_cn?b?wt63yQ==?= To: "naoya.horiguchi@nec.com" , "akpm@linux-foundation.org" CC: "linmiaohe@huawei.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: =?eucgb2312_cn?b?tPC4tDogW1BBVENIXSBtbSwgaHdwb2lzb24sIGh1Z2V0bGI6IENoZWNr?= =?eucgb2312_cn?b?IGh1Z2V0bGIgaGVhZCBwYWdlIGh3cG9pc29uIGZsYWcgd2hlbiB1bnBvaXNvbiBw?= =?eucgb2312_cn?b?YWdl?= Thread-Topic: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page Thread-Index: AQHYp/YA2P+b2sgj8UGtO/UrSrrbAq2epYGn Date: Thu, 4 Aug 2022 12:07:53 +0000 Message-ID: <85ab16d0a56c4942bb8a3e67b9d55858@unicloud.com> References: <20220804113308.2901178-1-luofei@unicloud.com> In-Reply-To: <20220804113308.2901178-1-luofei@unicloud.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.1.7] MIME-Version: 1.0 X-DNSRBL: X-MAIL: spam.unicloud.com 274C7r4m014658 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659614893; 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=45tUdafWHtLESPVP23AGG46uCwozZpGkxKtbdhEIB+U=; b=Yqlh24DChpprHOPshMC4pCWaNkbT0NdfyeZlg7bMkzo49tqCsllQx4zY8VTw0cYlTzvfk7 3dvhx7ooRfy/WWQXV2gpVoYQTSlQOV2IWA6aZ/FkGRsxMXnCJdKOvEBp/6+mzYmCqTsMoY VvkFjqGqrRDvZ8dtZnDXl75tSb6XgTI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659614893; a=rsa-sha256; cv=none; b=OIZb/HWYwM2GA3IzDHEAD4A8ecQrNOPhfrai5F8kMTyDd2BSVw1O6IqVFvztuviTRZRfbD 59CkqVWmmlDmm61mEJehBZslOaDCZ9ppi9wQENBKHpD4rtTNGDH6ri63/pam+XWft8CsLv YD948eVoXi3cX6UdEfs95Hj+usObtb8= Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8E8D220135 X-Stat-Signature: 73rftbhwjsuus4py9f9qjs3engodmf86 X-Rspam-User: X-HE-Tag: 1659614891-532077 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: Sorry, wrong patch, please ignore this email. diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 14439806b5ef..fc571b0ceb9d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2293,6 +2293,28 @@ core_initcall(memory_failure_init); pr_info(fmt, pfn); \ }) +static bool hugetlb_page_head_poison(struct page *hpage, struct page *page) +{ + struct llist_head *head; + struct llist_node *t, *tnode; + struct raw_hwp_page *p; + + if (PageHuge(page) && PageHWPoison(hpage) && HPageFreed(hpage)) + return false; + + if (HPageRawHwpUnreliable(hpage)) + return false; + + head = raw_hwp_list_head(hpage); + llist_for_each_safe(tnode, t, head->first) { + p = container_of(tnode, struct raw_hwp_page, node); + if (p->page == page) + return true; + } + + return false; +} + /** * unpoison_memory - Unpoison a previously poisoned page * @pfn: Page number of the to be unpoisoned page @@ -2330,7 +2352,7 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (!PageHWPoison(p)) { + if (!PageHWPoison(p) && !hugetlb_page_head_poison(page, p)) { unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n", pfn, &unpoison_rs); goto unlock_mutex;