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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B69CC433F5 for ; Fri, 18 Feb 2022 09:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233739AbiBRJox (ORCPT ); Fri, 18 Feb 2022 04:44:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbiBRJov (ORCPT ); Fri, 18 Feb 2022 04:44:51 -0500 Received: from spam.unicloud.com (mx.gosinoic.com [220.194.70.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D57A223BCF for ; Fri, 18 Feb 2022 01:44:34 -0800 (PST) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 21I9gtqS053033; Fri, 18 Feb 2022 17:42:55 +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; Fri, 18 Feb 2022 17:42:54 +0800 From: luofei To: , CC: , , luofei Subject: [PATCH v3 2/2] hw/poison: Add in-use hugepage hwpoison filter judgement Date: Fri, 18 Feb 2022 04:42:42 -0500 Message-ID: <20220218094242.2056346-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb06.Unicloud.com (10.10.0.52) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL: spam.unicloud.com 21I9gtqS053033 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 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 -- 2.27.0