Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp469957pxm; Wed, 23 Feb 2022 04:36:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvlCZKDYNGzOjoHBM+2AiT+CBbv4NJkbrNbjOOvRhbOSzGwmD2VHQYypojhiTlnNIubBTG X-Received: by 2002:a05:6402:3507:b0:413:523:5d24 with SMTP id b7-20020a056402350700b0041305235d24mr13806993edd.85.1645619778121; Wed, 23 Feb 2022 04:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645619778; cv=none; d=google.com; s=arc-20160816; b=Ntrr2Dr1qE9mDvZqU56fPPPnXqjFbc8fMZoJx/r8B03m5KCf5c1inA86yqZ9QuRtWa dxkaqHSnQytaTVtZsn4u1B6Rb8kjN0XKH897pFlc5W/rehlMQpcjHHClrFR2Bhn95Mlq I4ggUUbeS0oQR0+Yzow1vDBd2DvcmPr1DpRvoERh1RYn1EN9RFGdaHFfw8BIa+vi5Lcf 2ixU7JNr+ZSRV+a1LKgfL4MLg9lP+dmlAa928eivrG0DwyHN9RzuREHue19Z42H+s05p riJD7Wr7oCNFVaylOomwNY60svxTnwa4D+kQ5p1IKAz91Vlv5XU+zUOTH/vkd5/9zxwT 26Kw== 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=TlCxpUV5ywFqRPO0c18PB+43XRuXJWrlEotgxudYUWU=; b=uMz7FXjBuG/7oA1tG3woGVr9HMFPTSp//8zTd0dlNvj9GL+jzi1HfgigocU8WidBGC oJTb9d+tKK9PFJvUeim3AaPqrcFuDJwRbEh2p0obCeY0B7HCuKQnCaKirbjf6REE2bfI cuOgvHbM84Nsznl6lwAQ07IjaKRn029uyvNnw0KKuUbP2Amgp1YwW/mqgt86UTbFZ2sq 9xvbGBTtluSIjSHD7g22/5dPsUdrnySY07tDdWXO84JxkGpHulW7PiyitPvjwYP9E+PM m5AQtdZ+OnXF3g379Ti3kn+H1nGrK+y7RI+OkyH5fPBM1IFkJl0FZGR3q0MPkgLa/ZXC KU+g== 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 f15si3034017ejc.941.2022.02.23.04.35.53; Wed, 23 Feb 2022 04:36:18 -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 S237918AbiBWI0E (ORCPT + 99 others); Wed, 23 Feb 2022 03:26:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238936AbiBWIZ6 (ORCPT ); Wed, 23 Feb 2022 03:25:58 -0500 Received: from spam.unicloud.com (mx.gosinoic.com [220.194.70.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B3CB66F9D for ; Wed, 23 Feb 2022 00:25:31 -0800 (PST) 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-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-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 | 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 pfn, int flags) lock_page(head); page_flags = head->flags; + if (hwpoison_filter(p)) { + if (TestClearPageHWPoison(head)) + num_poisoned_pages_dec(); + put_page(p); + res = -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 -- 2.27.0