From patchwork Mon Jun 14 02:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3461DC48BDF for ; Mon, 14 Jun 2021 02:12:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3CA9613AB for ; Mon, 14 Jun 2021 02:12:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3CA9613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 552316B0070; Sun, 13 Jun 2021 22:12:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 529A96B0071; Sun, 13 Jun 2021 22:12:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 416A66B0072; Sun, 13 Jun 2021 22:12:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 0ACF36B0070 for ; Sun, 13 Jun 2021 22:12:29 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9499E180AD806 for ; Mon, 14 Jun 2021 02:12:29 +0000 (UTC) X-FDA: 78250705218.39.7E26F58 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf12.hostedemail.com (Postfix) with ESMTP id 37786F2 for ; Mon, 14 Jun 2021 02:12:18 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id h12-20020a17090aa88cb029016400fd8ad8so9231903pjq.3 for ; Sun, 13 Jun 2021 19:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PD461rujAEvHxr+/423Md1bdyuXr957SSOfQ9o3RiIk=; b=Zg98D31y7/QomMWOeDbhAIjUUpumQ3WhsLgSXqChPuNcTO+2B3Yg3tFURj+HMYSTuY PMei/LmWGdXfCCmEKF9ncLLJrQ/jKYh0rTohjWY6rqlxctl4HwaV91DLBLy0OYa7dw+r MGa4EDsvCz+6oSI/dPLaVhDmrKlmWDjreg465vIppbjSNcGgDGSvyo108WGwpF5NK+62 WzSZk9NMXQpwoC+XEiabwbJ7H3gRE0GRj/mtYQzhWAzNZNltfg+YM9S96fZDpiXLUkVC BA+dAoDG9gLipFKLklBHKCam2Wq/IIdiGC5c/yfYlUXKnr+/yQXjvvPVoauEVtILZ3ri uUPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PD461rujAEvHxr+/423Md1bdyuXr957SSOfQ9o3RiIk=; b=mEwkt8FHxXjlvAD2nEO2ZpSlrbH3y1r+O2/SAenmKZCdEGPPaxSWMah7M1J2yUKmRV xcN025l1MCvn6VMA6GTTN33mAuv+PQhh2Hk/Fobj6bPCEr6xzdFykNOXQIV2LjqCi0fh L//SkEXwwyIg5SfS3y1x7O3wSoHK2xRn1z6Tgk+cojhTJAqpIsD34P4FwlYGgrzL1dqL kcZ6pyjV31ckx284g6iYufiRKA3RhrtxLrAf79hRJSmMtwE5yBnEuFXW8xhUnY6fseuF pwr9LinhIsGloIieXD+910wCigeiXfbhtK0A/o2DuBqbYJJuyAHLPHCJuZDu9gQqcanM AKHw== X-Gm-Message-State: AOAM532WLluqSrcyP4HxJKgKPWaBBmuX0O4WYf2GrwOV/8SPWe66YmAj rnG3W52CKKVImf2+7BI2Q5LyN/FMz6pz X-Google-Smtp-Source: ABdhPJwugd/Yot3NacwjR7y/JV2uBnlBgfNLUSBKKMWCNNy/msTA+QPtRFK0ZmFAhnIT4pJeCnUYrQ== X-Received: by 2002:a17:90b:4b49:: with SMTP id mi9mr20470555pjb.219.1623636748399; Sun, 13 Jun 2021 19:12:28 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:28 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/6] mm/hwpoison: mf_mutex for soft offline and unpoison Date: Mon, 14 Jun 2021 11:12:07 +0900 Message-Id: <20210614021212.223326-2-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Zg98D31y; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com X-Rspamd-Server: rspam02 X-Stat-Signature: gawxybeqkrfwpj6kpoc9d8b1t46jkmtx X-Rspamd-Queue-Id: 37786F2 X-HE-Tag: 1623636738-177416 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: From: Naoya Horiguchi Originally mf_mutex is introduced to serialize multiple MCE events, but it's also helpful to exclude races among soft_offline_page() and unpoison_memory(). So apply mf_mutex to them. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index ae30fd6d575a..280eb6d6dd15 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1583,6 +1583,8 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, return rc; } +static DEFINE_MUTEX(mf_mutex); + /** * memory_failure - Handle memory failure of a page. * @pfn: Page Number of the corrupted page @@ -1609,7 +1611,6 @@ int memory_failure(unsigned long pfn, int flags) int res = 0; unsigned long page_flags; bool retry = true; - static DEFINE_MUTEX(mf_mutex); if (!sysctl_memory_failure_recovery) panic("Memory failure on page %lx", pfn); @@ -1918,6 +1919,7 @@ int unpoison_memory(unsigned long pfn) struct page *page; struct page *p; int freeit = 0; + int ret = 0; unsigned long flags = 0; static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); @@ -1928,28 +1930,30 @@ int unpoison_memory(unsigned long pfn) p = pfn_to_page(pfn); page = compound_head(p); + mutex_lock(&mf_mutex); + if (!PageHWPoison(p)) { unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } if (page_count(page) > 1) { unpoison_pr_info("Unpoison: Someone grabs the hwpoison page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } if (page_mapped(page)) { unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } if (page_mapping(page)) { unpoison_pr_info("Unpoison: the hwpoison page has non-NULL mapping %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } /* @@ -1960,7 +1964,7 @@ int unpoison_memory(unsigned long pfn) if (!PageHuge(page) && PageTransHuge(page)) { unpoison_pr_info("Unpoison: Memory failure is now running on %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } if (!get_hwpoison_page(p, flags)) { @@ -1968,7 +1972,7 @@ int unpoison_memory(unsigned long pfn) num_poisoned_pages_dec(); unpoison_pr_info("Unpoison: Software-unpoisoned free page %#lx\n", pfn, &unpoison_rs); - return 0; + goto unlock_mutex; } lock_page(page); @@ -1990,7 +1994,9 @@ int unpoison_memory(unsigned long pfn) if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) put_page(page); - return 0; +unlock_mutex: + mutex_unlock(&mf_mutex); + return ret; } EXPORT_SYMBOL(unpoison_memory); @@ -2171,6 +2177,8 @@ int soft_offline_page(unsigned long pfn, int flags) return -EIO; } + mutex_lock(&mf_mutex); + if (PageHWPoison(page)) { pr_info("%s: %#lx page already poisoned\n", __func__, pfn); put_ref_page(ref_page); @@ -2194,5 +2202,7 @@ int soft_offline_page(unsigned long pfn, int flags) __func__, pfn, page->flags, &page->flags); } + mutex_unlock(&mf_mutex); + return ret; } From patchwork Mon Jun 14 02:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC687C48BE8 for ; Mon, 14 Jun 2021 02:12:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 719BA613AB for ; Mon, 14 Jun 2021 02:12:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 719BA613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 132726B0072; Sun, 13 Jun 2021 22:12:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10AD76B0073; Sun, 13 Jun 2021 22:12:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEF226B0074; Sun, 13 Jun 2021 22:12:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id BC8566B0072 for ; Sun, 13 Jun 2021 22:12:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 60C8E8249980 for ; Mon, 14 Jun 2021 02:12:32 +0000 (UTC) X-FDA: 78250705344.03.11FFB93 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf08.hostedemail.com (Postfix) with ESMTP id 2DF3F801912B for ; Mon, 14 Jun 2021 02:12:24 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id ei4so8841977pjb.3 for ; Sun, 13 Jun 2021 19:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0vdMGIW3kH9wsKcFDP9ep4AZRTLAnVl6tpWr1FVt4M0=; b=Mpd1k+BpOuolkJoCsSxTQ13L6/VHwy0QbCKwaGlxzCMP/wxROPvRVQ9NNsbITJD4Lq n0e9Ew2CprYBhVPB8b6K/UENJrJ0KAiAcezsoZUrMBW1P4qdeCHuPBuJPftPRSSLBj+1 yMYEse3kXdDCDdlEHL/vpO1Rew/NoIIjbfz/dGMcEmBS0ZShaURcYgsH4eTr42Zy3VNO Z8Y+UHcPa89mL8n/INVVR4hPm0zqYDYPjvNul/AumfOcdSlVwjope/8j4mxW9g6eFaHv 9yzBs2/uTefvTtnZczQOWT697Syo8X0c3U6RUaNLM6LGd7lrOWB3behfItAyp0WCcmNc 6nDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0vdMGIW3kH9wsKcFDP9ep4AZRTLAnVl6tpWr1FVt4M0=; b=MnLTh0duwTZJyIKJMFYWKdeTr/glYQPjjwV2lfldD8o72b3ajGPcq+NhXaQHxy5W9Z T3M7Q/whkkgIZs3Esz7COyqdzQupIDZw3UKkncfVMZBFR1/p6Y5E5FmT9Ec7QOujIcT0 vMECQRNqkQjynsfZerqvOtD5MYGskFt1pVGizSmqOowTNFFKY90NTQcg7lTElmdKj69g Y6GolbOHBpEkGTF5Ddcfv7/cU/g1B0aFnOg+kDSPR32NNCMOgauIpPQQYZfh+xmeSem3 IF27k6Ot2LNj05ww0o1u/DXDkqHrJwcPVaVVeGnUZlY8CBpatkbBtlgl0hJiAMs+5L6z kdcg== X-Gm-Message-State: AOAM5316AZGQOb8rbMbzetyH0rTNpJ3QL0XCeDW6JGTbCnfVNuZRp0ts Xpc2HPkP8rgHZzua1eBtfmVSj31ChyVq X-Google-Smtp-Source: ABdhPJy9ExdxUVcz/l5+hEZ86ATtZOzE+wZeDhbCyXaRLE0w51mObupsZVVjbyjVrKMZrjT2TiDPBQ== X-Received: by 2002:a17:90a:708a:: with SMTP id g10mr21223850pjk.108.1623636751104; Sun, 13 Jun 2021 19:12:31 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:30 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/6] mm/hwpoison: remove race consideration Date: Mon, 14 Jun 2021 11:12:08 +0900 Message-Id: <20210614021212.223326-3-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Mpd1k+Bp; spf=pass (imf08.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: tz9gakztura6qb6qoqocfyws8uwk5y4d X-Rspamd-Queue-Id: 2DF3F801912B X-Rspamd-Server: rspam06 X-HE-Tag: 1623636744-972749 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: From: Naoya Horiguchi Now memory_failure() and unpoison_memory() are protected by mf_mutex, so no need to explicitly check races between them. So remove them. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index 280eb6d6dd15..e7910386fc9c 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1461,14 +1461,6 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) lock_page(head); page_flags = head->flags; - if (!PageHWPoison(head)) { - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); - num_poisoned_pages_dec(); - unlock_page(head); - put_page(head); - return 0; - } - /* * TODO: hwpoison for pud-sized hugetlb doesn't work right now, so * simply disable it. In order to make it work properly, we need @@ -1730,16 +1722,6 @@ int memory_failure(unsigned long pfn, int flags) */ page_flags = p->flags; - /* - * unpoison always clear PG_hwpoison inside page lock - */ - if (!PageHWPoison(p)) { - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); - num_poisoned_pages_dec(); - unlock_page(p); - put_page(p); - goto unlock_mutex; - } if (hwpoison_filter(p)) { if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); @@ -1956,17 +1938,6 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - /* - * unpoison_memory() can encounter thp only when the thp is being - * worked by memory_failure() and the page lock is not held yet. - * In such case, we yield to memory_failure() and make unpoison fail. - */ - if (!PageHuge(page) && PageTransHuge(page)) { - unpoison_pr_info("Unpoison: Memory failure is now running on %#lx\n", - pfn, &unpoison_rs); - goto unlock_mutex; - } - if (!get_hwpoison_page(p, flags)) { if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); @@ -1975,20 +1946,12 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - lock_page(page); - /* - * This test is racy because PG_hwpoison is set outside of page lock. - * That's acceptable because that won't trigger kernel panic. Instead, - * the PG_hwpoison page will be caught and isolated on the entrance to - * the free buddy page pool. - */ if (TestClearPageHWPoison(page)) { unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n", pfn, &unpoison_rs); num_poisoned_pages_dec(); freeit = 1; } - unlock_page(page); put_page(page); if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) From patchwork Mon Jun 14 02:12:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B88C48BDF for ; Mon, 14 Jun 2021 02:12:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42412613AB for ; Mon, 14 Jun 2021 02:12:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42412613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB6166B0074; Sun, 13 Jun 2021 22:12:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D90346B0075; Sun, 13 Jun 2021 22:12:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDFED6B0078; Sun, 13 Jun 2021 22:12:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 8BC566B0074 for ; Sun, 13 Jun 2021 22:12:35 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 21E0F584C for ; Mon, 14 Jun 2021 02:12:35 +0000 (UTC) X-FDA: 78250705470.35.24E9B4A Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf17.hostedemail.com (Postfix) with ESMTP id 14EBC4080F7B for ; Mon, 14 Jun 2021 02:12:28 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id w14-20020a17090aea0eb029016e9e0e7983so2599661pjy.4 for ; Sun, 13 Jun 2021 19:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIs+Dwa4YB8s9iK40ccyfE3brt/FVPHgMtnsfMB/YQQ=; b=T6rfps4hk8jXV+vVjlPo2YcvZksWU3htx/21N7tanZvOw1EJIj+C4+Z7QgDnMs8k19 E14aahCkAT4lbBVc+ScUGLUViPq5S7xH546wn3WA9h76eiEg1y8B66PFqDuZwJWxyW3H tyBGWK3lvOuY9mDNx8tz1ra2Kiuhh0ieif18SBU7lb/giLWz4h9W+9TcGI0S7WJPXt1Q OkJ4HS3vEZXp4ajy6YER9cO6xuD2gsPqt/A6qitjn3xk9embV12YfuzutQGSGO9pvBRQ EKxFU1wpTs04VqKgkk5ED8bfbe7VJVcnIa/Wx0RapJKmSQ/nPHBUgaA8rfTXPuy1wfQt Jpyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIs+Dwa4YB8s9iK40ccyfE3brt/FVPHgMtnsfMB/YQQ=; b=CU+p1npDYJ1XVo6QrlSvNii+I1UZpVe90uDq+/N5bxGy1yvskQ/+Pi+CgpQxgjEqlw dfZD6dbgrH7Rma6Kt5hKGcPs21jnJoFjv7sNe74B64cMkLBxCFXq8bPcHdxsHkfE31n5 6xwZo77JXPuydKWWr8f2x0WwkqAXt9pyYqJUjDcYyhxt6m1WXmyWZeiaCD7N3JPq8ixn zR6X3Y44CbhsBSNkQNC7daa4OpsyV+sLIp75qpudQZf2Or7XcD3ajF/4G8Gttcr3jKeK SUBJyAnEaXbllxgNGhyco+1DUDaVHNgCQU5fytbDZNs1oB2aNLEPfHPzDnUMoRhqcRwX 0WdQ== X-Gm-Message-State: AOAM530vY1aZB015/lgVbsKlOnAPtxdV6lFfgriHweq64T0oy3BrMaKI TtaCVmLoJOlvNi13Mp32I72Li2kpFPE6 X-Google-Smtp-Source: ABdhPJxH72pb6ziU7YQ25+rMunImKsUEj2DatwNxJyDtt4XYuDUpNvN3m0N5HJfDfDbZ1rYY0fPhrg== X-Received: by 2002:a17:90a:6304:: with SMTP id e4mr16476639pjj.222.1623636753886; Sun, 13 Jun 2021 19:12:33 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:33 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/6] mm/hwpoison: introduce MF_MSG_PAGETABLE Date: Mon, 14 Jun 2021 11:12:09 +0900 Message-Id: <20210614021212.223326-4-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 14EBC4080F7B Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=T6rfps4h; spf=pass (imf17.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: nfq9z5ze7iot7ezsq84oipbdqz8nord4 X-HE-Tag: 1623636748-986103 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: From: Naoya Horiguchi Page table pages could have some amount of share on system memory, so define it for a separate page type message. Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 + include/ras/ras_event.h | 1 + mm/memory-failure.c | 1 + 3 files changed, 3 insertions(+) diff --git v5.13-rc5/include/linux/mm.h v5.13-rc5_patched/include/linux/mm.h index c274f75efcf9..45008654f695 100644 --- v5.13-rc5/include/linux/mm.h +++ v5.13-rc5_patched/include/linux/mm.h @@ -3103,6 +3103,7 @@ enum mf_action_page_type { MF_MSG_KERNEL, MF_MSG_KERNEL_HIGH_ORDER, MF_MSG_SLAB, + MF_MSG_PAGETABLE, MF_MSG_DIFFERENT_COMPOUND, MF_MSG_POISONED_HUGE, MF_MSG_HUGE, diff --git v5.13-rc5/include/ras/ras_event.h v5.13-rc5_patched/include/ras/ras_event.h index 0bdbc0d17d2f..2f459f6f87fb 100644 --- v5.13-rc5/include/ras/ras_event.h +++ v5.13-rc5_patched/include/ras/ras_event.h @@ -357,6 +357,7 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_KERNEL, "reserved kernel page" ) \ EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \ EM ( MF_MSG_SLAB, "kernel slab page" ) \ + EM ( MF_MSG_PAGETABLE, "page table page page" ) \ EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \ EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \ EM ( MF_MSG_HUGE, "huge page" ) \ diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index e7910386fc9c..30d6519ce203 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -708,6 +708,7 @@ static const char * const action_page_types[] = { [MF_MSG_KERNEL] = "reserved kernel page", [MF_MSG_KERNEL_HIGH_ORDER] = "high-order kernel page", [MF_MSG_SLAB] = "kernel slab page", + [MF_MSG_PAGETABLE] = "page table page", [MF_MSG_DIFFERENT_COMPOUND] = "different compound page after locking", [MF_MSG_POISONED_HUGE] = "huge page already hardware poisoned", [MF_MSG_HUGE] = "huge page", From patchwork Mon Jun 14 02:12:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2275FC48BDF for ; Mon, 14 Jun 2021 02:12:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D3DC9613AB for ; Mon, 14 Jun 2021 02:12:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3DC9613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 74CCE6B0078; Sun, 13 Jun 2021 22:12:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FCDC6B007B; Sun, 13 Jun 2021 22:12:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 528646B007D; Sun, 13 Jun 2021 22:12:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 20C466B0078 for ; Sun, 13 Jun 2021 22:12:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B8D1E5DD6 for ; Mon, 14 Jun 2021 02:12:37 +0000 (UTC) X-FDA: 78250705554.19.F0F49B3 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf17.hostedemail.com (Postfix) with ESMTP id B6B3B40002C1 for ; Mon, 14 Jun 2021 02:12:31 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id y15so9423428pfl.4 for ; Sun, 13 Jun 2021 19:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hc5tE0rYCbS37ZgBxKFPNr3nuu+6cVzWda11nQdq3iM=; b=Vh+7NPD40igcWMA8ZxCKb882Omc6aDgbk/irfaju7R6OY9JHsN4hyxBDkVJB/XXQeb vtzEuQVTi62SnxT6OobcfTLjOhUpuods3mnG6KdDw+Z59+x3hjUfsydiYzV2Br0XLibk HmBowFSmZoqqKF/uRr4SBf7/xG3uxM+6OYL4WSZ7iCDcvycMF8DCOo1wHBC4eIZvAfjm NQnCbAh1eLGVojwwuV7yl/Yzmj5Zt93GlIJ5JGMNA/QomFnvWoPayMRUSANzoMO/nX38 nMmm0LEQ0/F02e2wKpIbuhG+KZp+R0MDP6rNv6KNnifZP7HcdMmBfBsdO1sUQIQrMs4c Ol4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hc5tE0rYCbS37ZgBxKFPNr3nuu+6cVzWda11nQdq3iM=; b=fRDfs6NtE63aGGAYDHSaQqNX2OtLglZ7ivJqPyLhyqvuTybDn3NFukjQ6bkUem2yXo r+vIixSthKraqGo9n0edSlHuneEWiqFtsMAn9DXD/OL+DZLVmYckfqxhQbU+79iGjU++ X34sSRJo6hD4+P17eqfMW9STpQzr6bmxtbg0XPJIqs2EKHdzDdhJzN/3FAZwyQ5JtjbR 6jqoUoSB3rCi4pP7BR53TFpbWY2268phx8KA6VTbNJ8juQxKWgPwcmY7Hf2D9OGaxDRu iAzGE+nykBW6ANg3q+bV8BsJjGUrUl5sVoSeNiKynNgJbvXDzZa2jPibi7jTWOe3DhUP Y2+g== X-Gm-Message-State: AOAM530oPHGdmbq0gFECOddAvWV5oHSN1xeacUdIrdu+k/UJ/cu/SrEr EBN1yC1FyI+sYdFfGBOkHAKZc9Zo6oZ3 X-Google-Smtp-Source: ABdhPJw9PDSjTntjgblnpRRtXcC12ps1LpPVexLCN0hoszoS8nN9Si7jFc9Ikr9TWPNAO/xM0yrnhw== X-Received: by 2002:a63:ae01:: with SMTP id q1mr14567258pgf.216.1623636756646; Sun, 13 Jun 2021 19:12:36 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:36 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/6] mm/hwpoison: remove MF_MSG_BUDDY_2ND and MF_MSG_POISONED_HUGE Date: Mon, 14 Jun 2021 11:12:10 +0900 Message-Id: <20210614021212.223326-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B6B3B40002C1 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Vh+7NPD4; spf=pass (imf17.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 9qg8sbjmqbzusbx65ebpr63c5boahjkf X-HE-Tag: 1623636751-668677 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: From: Naoya Horiguchi These action_page_types are no longer used, so remove them. Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 2 -- include/ras/ras_event.h | 2 -- mm/memory-failure.c | 2 -- 3 files changed, 6 deletions(-) diff --git v5.13-rc5/include/linux/mm.h v5.13-rc5_patched/include/linux/mm.h index 45008654f695..f1e3b82e1a93 100644 --- v5.13-rc5/include/linux/mm.h +++ v5.13-rc5_patched/include/linux/mm.h @@ -3105,7 +3105,6 @@ enum mf_action_page_type { MF_MSG_SLAB, MF_MSG_PAGETABLE, MF_MSG_DIFFERENT_COMPOUND, - MF_MSG_POISONED_HUGE, MF_MSG_HUGE, MF_MSG_FREE_HUGE, MF_MSG_NON_PMD_HUGE, @@ -3120,7 +3119,6 @@ enum mf_action_page_type { MF_MSG_CLEAN_LRU, MF_MSG_TRUNCATED_LRU, MF_MSG_BUDDY, - MF_MSG_BUDDY_2ND, MF_MSG_DAX, MF_MSG_UNSPLIT_THP, MF_MSG_UNKNOWN, diff --git v5.13-rc5/include/ras/ras_event.h v5.13-rc5_patched/include/ras/ras_event.h index 2f459f6f87fb..23306428f5e6 100644 --- v5.13-rc5/include/ras/ras_event.h +++ v5.13-rc5_patched/include/ras/ras_event.h @@ -359,7 +359,6 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_SLAB, "kernel slab page" ) \ EM ( MF_MSG_PAGETABLE, "page table page page" ) \ EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \ - EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \ EM ( MF_MSG_HUGE, "huge page" ) \ EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ EM ( MF_MSG_NON_PMD_HUGE, "non-pmd-sized huge page" ) \ @@ -374,7 +373,6 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \ EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \ EM ( MF_MSG_BUDDY, "free buddy page" ) \ - EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \ EM ( MF_MSG_DAX, "dax page" ) \ EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ EMe ( MF_MSG_UNKNOWN, "unknown page" ) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index 30d6519ce203..b986936e50eb 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -710,7 +710,6 @@ static const char * const action_page_types[] = { [MF_MSG_SLAB] = "kernel slab page", [MF_MSG_PAGETABLE] = "page table page", [MF_MSG_DIFFERENT_COMPOUND] = "different compound page after locking", - [MF_MSG_POISONED_HUGE] = "huge page already hardware poisoned", [MF_MSG_HUGE] = "huge page", [MF_MSG_FREE_HUGE] = "free huge page", [MF_MSG_NON_PMD_HUGE] = "non-pmd-sized huge page", @@ -725,7 +724,6 @@ static const char * const action_page_types[] = { [MF_MSG_CLEAN_LRU] = "clean LRU page", [MF_MSG_TRUNCATED_LRU] = "already truncated LRU page", [MF_MSG_BUDDY] = "free buddy page", - [MF_MSG_BUDDY_2ND] = "free buddy page (2nd try)", [MF_MSG_DAX] = "dax page", [MF_MSG_UNSPLIT_THP] = "unsplit thp", [MF_MSG_UNKNOWN] = "unknown page", From patchwork Mon Jun 14 02:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 334A4C48BDF for ; Mon, 14 Jun 2021 02:12:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFB836128B for ; Mon, 14 Jun 2021 02:12:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFB836128B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 74D186B007B; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 723846B007D; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5762E6B007E; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 239226B007B for ; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B0EF68249980 for ; Mon, 14 Jun 2021 02:12:40 +0000 (UTC) X-FDA: 78250704714.01.319C766 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf30.hostedemail.com (Postfix) with ESMTP id 45D1AE000255 for ; Mon, 14 Jun 2021 02:12:35 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id 11so5733312plk.12 for ; Sun, 13 Jun 2021 19:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=06DPK/DIEfCFono0yuu1MCmhjq2CI/XtitXHneoP5fU=; b=oWnsV+BezW5KT/QArk9QVETWeqDfJl2d0xSVEz5fNV0UeDg3N0nGB6rHIPLkhFMd/l 3CDyZjxsWdP0wNJJ09O9ZUkWN3NL2fnd92bwl6sjl34LSCcfK8bguFt6wZlcqfswg9pa mrveVeMvidjJcKOLFf9eeAQvIRJIi+VnGYGTvCwf0dF3a7NbNRUWrYk9ECL8+s6chqk1 uLXgBjnhawBe2UKbquoCWVnptyLHUIzTBgkTIjQlAEB2Tf4+ytkwIMOFcaGUdA+d/jS+ Wgt2DoNznNULS4i12VJM4IW/Y+bRX5LXLjw4GXcc7LGQ5Wa4Xmhz2nx2xvY4ocpBGps4 dqpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=06DPK/DIEfCFono0yuu1MCmhjq2CI/XtitXHneoP5fU=; b=E4gcYo/7o14ABdGlewhW5IYz48qJp4P0CdyUH+cgD5Ya99nHj1c+SXIiHdWYfOEtqD KUQe2WsdBCMiEra9yXvlLudzygf4HyXbi+dNYkZkYnHCfNWAoWnWZ4tAwRAaKDcdDIdB 4XnJvcq7RUNXDGdK1N6hyEbmoAiZDqs6dqPvdHgvHj1afw7dzRcEs87f9jpzAcV8JbX1 FxM8tdSAGFV+NtWUuXoqGT6bH54K3JTgMHqiAXtAMy47kdR4QRiJVa7iinEaXjX7nRf8 LdS2efvr1SSUjzZQz0hgZ95CAY0/+AKMVjpleMd98+awHW7F9eEZghcSvsukcUp42XTV p8kA== X-Gm-Message-State: AOAM5333OMD+kKibgXoYJtjmwDsmPQrxE2WtJWFbQf0Sw+8Tk/NRp15t KpsmDTMCP0AX0P8DjSmjDH4eIRxD6oGr X-Google-Smtp-Source: ABdhPJyvl4bHahHn/RdmP86pL4VEvHOHD7AGza4lyMnl4KqJiAGuiYT+fHhiTBjNKFUP12KiHPsRMA== X-Received: by 2002:a17:90a:8816:: with SMTP id s22mr16662503pjn.231.1623636759326; Sun, 13 Jun 2021 19:12:39 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:39 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/6] mm/hwpoison: make some kernel pages handlable Date: Mon, 14 Jun 2021 11:12:11 +0900 Message-Id: <20210614021212.223326-6-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 45D1AE000255 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=oWnsV+Be; spf=pass (imf30.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: w8mxxn5px4gxhi9455nqzh4g9qby164d X-HE-Tag: 1623636755-77406 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: From: Naoya Horiguchi HWPoisonHandlable() introduced by patch "mm,hwpoison: fix race with hugetlb page allocation" filters error events by page type, and only limited events reach get_page_unless_zero() to avoid race. Actually this is too restictive because get_hwpoison_page always fails to take refcount for any types of kernel page, leading to MF_MSG_KERNEL_HIGH_ORDER. This is not critical (no panic), but less informative than MF_MSG_SLAB or MF_MSG_PAGETABLE, so extend HWPoisonHandlable() to some basic types of kernel pages (slab, pgtable, and reserved pages). The "handling" for these types are still primitive (just taking refcount and setting PG_hwpoison) and some more aggressive actions for memory error containment are possible and wanted. But compared to the older code, these cases never enter the code block of page locks (note that page locks is not well-defined on these pages), so it's a little safer for functions intended for user pages not to be called for kernel pages. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index b986936e50eb..0d51067f0129 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1113,7 +1113,8 @@ static int page_action(struct page_state *ps, struct page *p, */ static inline bool HWPoisonHandlable(struct page *page) { - return PageLRU(page) || __PageMovable(page); + return PageLRU(page) || __PageMovable(page) || + PageSlab(page) || PageTable(page) || PageReserved(page); } static int __get_hwpoison_page(struct page *page) @@ -1260,12 +1261,6 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, struct page *hpage = *hpagep; bool mlocked = PageMlocked(hpage); - /* - * Here we are interested only in user-mapped pages, so skip any - * other types of pages. - */ - if (PageReserved(p) || PageSlab(p)) - return true; if (!(PageLRU(hpage) || PageHuge(p))) return true; @@ -1670,7 +1665,10 @@ int memory_failure(unsigned long pfn, int flags) action_result(pfn, MF_MSG_BUDDY, res); res = res == MF_RECOVERED ? 0 : -EBUSY; } else { - action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); + if (PageCompound(p)) + action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); + else + action_result(pfn, MF_MSG_KERNEL, MF_IGNORED); res = -EBUSY; } goto unlock_mutex; @@ -1681,6 +1679,20 @@ int memory_failure(unsigned long pfn, int flags) } } + if (PageSlab(p)) { + action_result(pfn, MF_MSG_SLAB, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } else if (PageTable(p)) { + action_result(pfn, MF_MSG_PAGETABLE, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } else if (PageReserved(p)) { + action_result(pfn, MF_MSG_KERNEL, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } + if (PageTransHuge(hpage)) { if (try_to_split_thp_page(p, "Memory Failure") < 0) { action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); From patchwork Mon Jun 14 02:12:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29654C48BDF for ; Mon, 14 Jun 2021 02:12:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BEC656128B for ; Mon, 14 Jun 2021 02:12:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEC656128B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 614276B007E; Sun, 13 Jun 2021 22:12:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59DF06B0080; Sun, 13 Jun 2021 22:12:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419476B0081; Sun, 13 Jun 2021 22:12:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 096E36B007E for ; Sun, 13 Jun 2021 22:12:43 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8F29D5DD6 for ; Mon, 14 Jun 2021 02:12:43 +0000 (UTC) X-FDA: 78250705806.22.630200C Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf15.hostedemail.com (Postfix) with ESMTP id DE8B4A0001CF for ; Mon, 14 Jun 2021 02:12:39 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id x10so5743804plg.3 for ; Sun, 13 Jun 2021 19:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BrhZvM3Zxn4NDLb/x2HzFv6RdjLYg2a3k6nkC/VHHoU=; b=FB6EvOE47KvKGS/eQwyikx8cKwYB8vvHOycaPK/IEurOyKzougUrGpf006LE8yekvk ZBi6gfzkzGImxrNgmmhy3K9RNXcqm68RTNlQYn6RvB40Tv1I6DWBPtFJfVhZm4YfXlcI 7lAR/FfsYvFl/SYZnHoByQw7VRuyydaJiV04KvvIoe5mVNvDLHkvcZpcEgsnF2AFNcKV VHO2IA8LjfsJVT1GMXkeFY01hOXgLsvBuuFOAYJQhDQwhQPxGD3/yeDDpM1lILiJLY0K gs+vJPA63rMzmsHTrhetuxnX433zw3yL79gqha1IXukUcLLW/0VX3du3wE9kc/dnwD3n 9Agg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BrhZvM3Zxn4NDLb/x2HzFv6RdjLYg2a3k6nkC/VHHoU=; b=dgObe6AEcOhn/xNEs5PzGZT3V/IilT4EYoF0ZnPib9VV2P6tCJrkjkWPeEPAHEB/VI 8P9A4HmlIENMdEnLOLtLcAZbJHNCWsoI2QMm8304aheoNkuGhiTFQNw3Pyx2JJXKrWKR C4g/qJRI6sCWTiiaw5a4SiYIl4ZvfcHiSDR+dovbW+QK2zakDY2rep4A0IR6fD2sm50i PDey/gKOTqxzEfT00nRRY9eMEKsmnhivmMXEyFMgMl6ZsUwwajmwnuEzfCOfFBL+5rV5 YfwBPAc+YkBM+hCU07gbovgEXo5f5O/WMfrb7z1CiB6jUkHTOzwnmLhTRFoXGiKg6u8z nbaQ== X-Gm-Message-State: AOAM531kIAP2e4b6gBMJ5G1NsrHLuINHmu8+dZxy5aBRaCH//f5T8K89 wZ8lbgwvwXso5A9DzwBVPWbw3H/46tXp X-Google-Smtp-Source: ABdhPJzORIxMD2qAA7ztYofQzs2tEKCNw11G+uyCPsBVMLYOKhLKBn2Z0A0CjJAliCmOqWZAF5B7tg== X-Received: by 2002:a17:90a:bb11:: with SMTP id u17mr20583831pjr.57.1623636762125; Sun, 13 Jun 2021 19:12:42 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:41 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 6/6] mm/hwpoison: fix unpoison_memory() Date: Mon, 14 Jun 2021 11:12:12 +0900 Message-Id: <20210614021212.223326-7-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DE8B4A0001CF Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=FB6EvOE4; spf=pass (imf15.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: foby3dz74rdeqehkgrgizdmx8ceutf3t X-HE-Tag: 1623636759-573127 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: From: Naoya Horiguchi After recent soft-offline rework, error pages can be taken off from buddy allocator, but the existing unpoison_memory() does not properly undo the operation. Moreover, due to the recent change on __get_hwpoison_page(), get_page_unless_zero() is hardly called for hwpoisoned pages. So __get_hwpoison_page() mostly returns zero (meaning to fail to grab page refcount) and unpoison just clears PG_hwpoison without releasing a refcount. That does not lead to a critical issue like kernel panic, but unpoisoned pages never get back to buddy (leaked permanently), which is not good. To fix this, we need to identify "taken off" pages from other types of hwpoisoned pages. We can't use refcount or page flags for this purpose, so a pseudo flag is defined by hacking ->private field. Sometimes hwpoisoned pages can be still in-use, where the refcount should be more than 1, so we can't unpoison them immediately and need to wait until the all users release their refcount. Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 + include/linux/page-flags.h | 4 ++ mm/memory-failure.c | 84 ++++++++++++++++++++++++++++---------- mm/page_alloc.c | 19 +++++++++ 4 files changed, 86 insertions(+), 22 deletions(-) diff --git v5.13-rc5/include/linux/mm.h v5.13-rc5_patched/include/linux/mm.h index f1e3b82e1a93..0baf3fc97415 100644 --- v5.13-rc5/include/linux/mm.h +++ v5.13-rc5_patched/include/linux/mm.h @@ -3077,6 +3077,7 @@ enum mf_flags { MF_ACTION_REQUIRED = 1 << 1, MF_MUST_KILL = 1 << 2, MF_SOFT_OFFLINE = 1 << 3, + MF_UNPOISON = 1 << 4, }; extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); diff --git v5.13-rc5/include/linux/page-flags.h v5.13-rc5_patched/include/linux/page-flags.h index 04a34c08e0a6..00bddb3a058d 100644 --- v5.13-rc5/include/linux/page-flags.h +++ v5.13-rc5_patched/include/linux/page-flags.h @@ -430,7 +430,11 @@ PAGEFLAG_FALSE(Uncached) PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) +#define MAGIC_HWPOISON 0x4857504f49534f4e +extern void SetPageHWPoisonTakenOff(struct page *page); +extern void ClearPageHWPoisonTakenOff(struct page *page); extern bool take_page_off_buddy(struct page *page); +extern void take_page_back_buddy(struct page *page); #else PAGEFLAG_FALSE(HWPoison) #define __PG_HWPOISON 0 diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index 0d51067f0129..41b0ef96e2aa 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1105,6 +1105,22 @@ static int page_action(struct page_state *ps, struct page *p, return (result == MF_RECOVERED || result == MF_DELAYED) ? 0 : -EBUSY; } +static inline bool PageHWPoisonTakenOff(struct page *page) +{ + return PageHWPoison(page) && page_private(page) == MAGIC_HWPOISON; +} + +void SetPageHWPoisonTakenOff(struct page *page) +{ + set_page_private(page, MAGIC_HWPOISON); +} + +void ClearPageHWPoisonTakenOff(struct page *page) +{ + if (PageHWPoison(page)) + set_page_private(page, 0); +} + /* * Return true if a page type of a given page is supported by hwpoison * mechanism (while handling could fail), otherwise false. This function @@ -1117,7 +1133,7 @@ static inline bool HWPoisonHandlable(struct page *page) PageSlab(page) || PageTable(page) || PageReserved(page); } -static int __get_hwpoison_page(struct page *page) +static int __get_hwpoison_page(struct page *page, unsigned long flags) { struct page *head = compound_head(page); int ret = 0; @@ -1127,12 +1143,19 @@ static int __get_hwpoison_page(struct page *page) if (hugetlb) return ret; + /* + * Finding taken-off pages, so it could be true only when called + * from unpoison_memory(). + */ + if (PageHWPoisonTakenOff(head)) + return -EHWPOISON; + /* * This check prevents from calling get_hwpoison_unless_zero() * for any unsupported type of page in order to reduce the risk of * unexpected races caused by taking a page refcount. */ - if (!HWPoisonHandlable(head)) + if (!(flags & MF_UNPOISON) && !HWPoisonHandlable(head)) return 0; if (PageTransHuge(head)) { @@ -1171,7 +1194,7 @@ static int get_any_page(struct page *p, unsigned long flags) try_again: if (!count_increased) { - ret = __get_hwpoison_page(p); + ret = __get_hwpoison_page(p, flags); if (!ret) { if (page_count(p)) { /* We raced with an allocation, retry. */ @@ -1190,6 +1213,8 @@ static int get_any_page(struct page *p, unsigned long flags) if (pass++ < 3) goto try_again; goto out; + } else if (ret == -EHWPOISON) { + goto out; } } @@ -1233,14 +1258,18 @@ static int get_any_page(struct page *p, unsigned long flags) * 1 on success for in-use pages in a well-defined state, * -EIO for pages on which we can not handle memory errors, * -EBUSY when get_hwpoison_page() has raced with page lifecycle - * operations like allocation and free. + * operations like allocation and free, + * -EHWPOISON when the page is hwpoisoned and taken off from buddy. */ static int get_hwpoison_page(struct page *p, unsigned long flags) { int ret; zone_pcp_disable(page_zone(p)); - ret = get_any_page(p, flags); + if (flags & MF_UNPOISON) + ret = __get_hwpoison_page(p, flags); + else + ret = get_any_page(p, flags); zone_pcp_enable(page_zone(p)); return ret; @@ -1895,6 +1924,17 @@ core_initcall(memory_failure_init); pr_info(fmt, pfn); \ }) +static inline int clear_page_hwpoison(struct ratelimit_state *rs, struct page *p) +{ + if (TestClearPageHWPoison(p)) { + unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n", + page_to_pfn(p), rs); + num_poisoned_pages_dec(); + return 1; + } + return 0; +} + /** * unpoison_memory - Unpoison a previously poisoned page * @pfn: Page number of the to be unpoisoned page @@ -1911,9 +1951,7 @@ int unpoison_memory(unsigned long pfn) { struct page *page; struct page *p; - int freeit = 0; int ret = 0; - unsigned long flags = 0; static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); @@ -1949,24 +1987,26 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (!get_hwpoison_page(p, flags)) { - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); - unpoison_pr_info("Unpoison: Software-unpoisoned free page %#lx\n", - pfn, &unpoison_rs); + ret = get_hwpoison_page(p, MF_UNPOISON); + if (!ret) { + clear_page_hwpoison(&unpoison_rs, p); goto unlock_mutex; - } - - if (TestClearPageHWPoison(page)) { - unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n", - pfn, &unpoison_rs); - num_poisoned_pages_dec(); - freeit = 1; - } + } else if (ret < 0) { + if (ret == -EHWPOISON) { + clear_page_hwpoison(&unpoison_rs, p); + take_page_back_buddy(p); + ret = 0; + } else + unpoison_pr_info("Unpoison: failed to grab page %#lx\n", + pfn, &unpoison_rs); + goto unlock_mutex; + } else { + int freeit = clear_page_hwpoison(&unpoison_rs, p); - put_page(page); - if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) put_page(page); + if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) + put_page(page); + } unlock_mutex: mutex_unlock(&mf_mutex); diff --git v5.13-rc5/mm/page_alloc.c v5.13-rc5_patched/mm/page_alloc.c index d1f5de1c1283..325e91d92b7e 100644 --- v5.13-rc5/mm/page_alloc.c +++ v5.13-rc5_patched/mm/page_alloc.c @@ -9158,6 +9158,7 @@ bool take_page_off_buddy(struct page *page) del_page_from_free_list(page_head, zone, page_order); break_down_buddy_pages(zone, page_head, page, 0, page_order, migratetype); + SetPageHWPoisonTakenOff(page); if (!is_migrate_isolate(migratetype)) __mod_zone_freepage_state(zone, -1, migratetype); ret = true; @@ -9169,4 +9170,22 @@ bool take_page_off_buddy(struct page *page) spin_unlock_irqrestore(&zone->lock, flags); return ret; } + +/* + * Cancel takeoff done by take_page_off_buddy(). + */ +void take_page_back_buddy(struct page *page) +{ + struct zone *zone = page_zone(page); + unsigned long pfn = page_to_pfn(page); + unsigned long flags; + int migratetype = get_pfnblock_migratetype(page, pfn); + + spin_lock_irqsave(&zone->lock, flags); + if (put_page_testzero(page)) { + ClearPageHWPoisonTakenOff(page); + __free_one_page(page, pfn, zone, 0, migratetype, FPI_NONE); + } + spin_unlock_irqrestore(&zone->lock, flags); +} #endif