From mboxrd@z Thu Jan 1 00:00:00 1970 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 3FD79C433FE for ; Wed, 23 Feb 2022 08:24:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAEA08D0002; Wed, 23 Feb 2022 03:24:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A37748D0001; Wed, 23 Feb 2022 03:24:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D7A28D0002; Wed, 23 Feb 2022 03:24:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 7E7E48D0001 for ; Wed, 23 Feb 2022 03:24:08 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 36D4F180972C3 for ; Wed, 23 Feb 2022 08:24:08 +0000 (UTC) X-FDA: 79173356976.15.7BE7849 Received: from spam.unicloud.com (gw.haihefund.cn [220.194.70.58]) by imf12.hostedemail.com (Postfix) with ESMTP id CCFE740004 for ; Wed, 23 Feb 2022 08:24:06 +0000 (UTC) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 21N8N1w0031342; Wed, 23 Feb 2022 16:23:01 +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; Wed, 23 Feb 2022 16:23:01 +0800 From: luofei To: , CC: , , luofei Subject: [PATCH v5 2/2] mm/hwpoison: Add in-use hugepage hwpoison filter judgement Date: Wed, 23 Feb 2022 03:22:54 -0500 Message-ID: <20220223082254.2769757-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb11.Unicloud.com (10.10.0.28) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL:spam.unicloud.com 21N8N1w0031342 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CCFE740004 X-Stat-Signature: kjmq6mrxi3kf7bqzwtr14isx8uoc386p Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com; dmarc=none X-Rspam-User: X-HE-Tag: 1645604646-790786 Content-Transfer-Encoding: quoted-printable 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 --- mm/memory-failure.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7e16d31df0f3..bad659092176 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1547,6 +1547,14 @@ static int memory_failure_hugetlb(unsigned long pf= n, int flags) lock_page(head); page_flags =3D head->flags; =20 + if (hwpoison_filter(p)) { + if (TestClearPageHWPoison(head)) + num_poisoned_pages_dec(); + put_page(p); + res =3D -EOPNOTSUPP; + 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 --=20 2.27.0