Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1171011pxb; Fri, 18 Feb 2022 02:05:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiQkuBNMS54IPiIhTuhPn/ZJPQqA5fIrRI/GRyLrZuRzYCIVDLyhpjUjLcklCxrJ/NhUT4 X-Received: by 2002:a63:b10:0:b0:373:393f:2015 with SMTP id 16-20020a630b10000000b00373393f2015mr5726687pgl.322.1645178707610; Fri, 18 Feb 2022 02:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645178707; cv=none; d=google.com; s=arc-20160816; b=LrW/UA+aZFweBEPOKBmSbHkGcXQkjMVfVPBpdpRBFgWzU0i4hf9iT7nFgtXFolFEp4 t3AeJcMaEKmZuWzs5bfIBmndNRO0Pdh/UCK3cLOCCP4Bh5IgiO25ENvj/f/zOMe1Eshl UizpYtptAmTdNFt1WxMLn+MYrtRn1YCVhjAxrouYDwgxWEZK9wTvXaVMc2lD4aBPgfe8 CVo4fvQGF95OR5tUVYDlqyCja8LYiMQSYjVgh8Q33SFjA9JKtik98ZZzA8SSPTIiRz78 Unx4/VJDgMFgQAN2XJe9o7p7ecsO94wYg9ALou4inYaYmZvjHc4Aad5H+P6gShXr4ui4 yCLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Rj26STirKkupQNnyBaergAEhUVGBsEl6uS7Fbp6ILLA=; b=ukG5DFh/hPPGyq3OfJRe9L0xFommnqN/tzICmPxQP+TbycCoRoUoE7+/tHRT81jj7i M135r9wGN7eiRU0U6Pk7XmBVYRI5vgnoC6WBkCuQ8JCXToqMvIS+U7suPaZRpL4TUKU2 AzVB/LPMDQ97N/WrPH2m/lmfFrFTelN+WNKpJMjiaOEMTbv7qHS/n88HasVO1zzbRFlA TMBr/MSWlF4mNTrzN7do5mvQbl+9fwB4ft3O2qep+MixySnP70gjrAJa5DeTdVwSXs8E 2RGN3BzEgP6pIkQWFj4KZ87T0BncMeap7PFAcIT+xtzIFbXH+NoJRFYbY6KGsHzkJH4t SvSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14si2975705pja.89.2022.02.18.02.04.51; Fri, 18 Feb 2022 02:05:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233738AbiBRJow (ORCPT + 99 others); Fri, 18 Feb 2022 04:44:52 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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