From patchwork Mon Feb 21 02:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luofei X-Patchwork-Id: 12752973 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 8F154C433EF for ; Mon, 21 Feb 2022 02:15:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 014326B0072; Sun, 20 Feb 2022 21:15:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F04A36B0073; Sun, 20 Feb 2022 21:15:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF3156B0074; Sun, 20 Feb 2022 21:15:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id D0D496B0072 for ; Sun, 20 Feb 2022 21:15:49 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 864B89EB13 for ; Mon, 21 Feb 2022 02:15:49 +0000 (UTC) X-FDA: 79165171218.24.2096987 Received: from spam.unicloud.com (mx.gosinoic.com [220.194.70.58]) by imf04.hostedemail.com (Postfix) with ESMTP id 6D87D40004 for ; Mon, 21 Feb 2022 02:15:48 +0000 (UTC) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 21L2FaV2091761; Mon, 21 Feb 2022 10:15:37 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from localhost.localdomain (10.10.1.7) by zgys-ex-mb09.Unicloud.com (10.10.0.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Mon, 21 Feb 2022 10:15:35 +0800 From: luofei To: , CC: , , luofei Subject: [PATCH v4 2/2] mm/hwpoison: Add in-use hugepage hwpoison filter judgement Date: Sun, 20 Feb 2022 21:15:21 -0500 Message-ID: <20220221021521.2329075-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb07.Unicloud.com (10.10.0.27) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL: spam.unicloud.com 21L2FaV2091761 X-Rspamd-Queue-Id: 6D87D40004 X-Stat-Signature: by9zc3by7wgknktakmj3etbcxptseqxn X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.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: rspam05 X-HE-Tag: 1645409748-939819 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: After successfully obtaining the reference count of the huge page, it is still necessary to call hwpoison_filter() to make a filter judgement, otherwise the filter hugepage will be unmaped and the related process may be killed. Signed-off-by: luofei Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 59d6d939a752..17a7b0a94ab9 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1548,6 +1548,17 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) lock_page(head); page_flags = head->flags; + if (hwpoison_filter(p)) { + if (TestClearPageHWPoison(head)) + num_poisoned_pages_dec(); + put_page(p); + if (flags & MF_MCE_HANDLE) + res = -EHWPOISON; + else + res = 0; + goto out; + } + /* * TODO: hwpoison for pud-sized hugetlb doesn't work right now, so * simply disable it. In order to make it work properly, we need