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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 3196AC2BB40 for ; Thu, 10 Dec 2020 03:59:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1057C23BC6 for ; Thu, 10 Dec 2020 03:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732139AbgLJD7f (ORCPT ); Wed, 9 Dec 2020 22:59:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732085AbgLJD7a (ORCPT ); Wed, 9 Dec 2020 22:59:30 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E0CC0611CE for ; Wed, 9 Dec 2020 19:58:37 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id bj5so2105508plb.4 for ; Wed, 09 Dec 2020 19:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cJ9Kpw9euvaWeMiz77W9dHgAhVUDo0j7sOjcwheIHew=; b=ghgjyxrsJ7T3/jqCtD+ypiLM9BEH2CLt5gtZONrJJTsdwKdYqavXofY8lXr9g8uc/t qUGReab7rPAaXR7HMv2iBiOxHdhbPlaIW5NIKQtub81/vpTu+Q4gPxTqai/7eH/fTMAY KVYDT3L0tGkj3Syi40CkpQoBAA+mVTuFSoenjCx6NiZeb2Lln2ajAkF6smCI0wTuGCgH iAaMLnc+T+In0bYzzZKbG4IzF3BC63yD8soDcWKY/VWCSRbwQ+lIJJnQ0pu6DxvcSv8f 5PcwsBg79Tc0gRGGgTMOTRnzu96UK/sRIAvV2WvrX9gkti1p24TUHyY4t3AGud40NeYU SmYw== 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=cJ9Kpw9euvaWeMiz77W9dHgAhVUDo0j7sOjcwheIHew=; b=VYW8tN2FcgKhjasdleW94oivUawugs+1t0U6meVB4cmTsJEaLnIDnpghCX2YUp+Y/B /iyTmtausoSLFamtZRh4ikrGZLoRbyKiWn/U4vL8tjtxq4dDzR+efT4GCmKLMpiL9VIl bbIJSijFpmZaKwyk7B46pA2W/9XN1yXJxDE4Ne3mv9HDefRvS3vxNdpYDOUJ99OOLE6+ ymqM0PKXxjnH6kuYPqcGOPJonyJ+28UMOni8T4R8HJDPCmoasCcJ7z3R+LaxGgYA+yhM QPjmfVP6zTLrIZhaH1iAqeoDdmmaK15tLvQk1QL3/T4kCs7MhEPXTX3599ikFDE6x/s+ kY7A== X-Gm-Message-State: AOAM532rxjUUCnKFlzUywgrRgW7wQI3baFbOCOmuHrYdrt0HhOWNpgRG CUq8NJt3KsYB2G9Y+HAHnVcBbg== X-Google-Smtp-Source: ABdhPJzw5hLUvQdTuLt9Uua9WZQksiCrIptpkpMT26lr/lIhMe4UXVimr/dNHo2MdPSc2Jv07kMXcQ== X-Received: by 2002:a17:902:b08a:b029:d9:eca:7d38 with SMTP id p10-20020a170902b08ab02900d90eca7d38mr4807254plr.72.1607572717228; Wed, 09 Dec 2020 19:58:37 -0800 (PST) Received: from localhost.localdomain ([103.136.220.85]) by smtp.gmail.com with ESMTPSA id f33sm4266535pgl.83.2020.12.09.19.58.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2020 19:58:36 -0800 (PST) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, osalvador@suse.de, mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com Cc: duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [PATCH v8 07/12] mm/hugetlb: Set the PageHWPoison to the raw error page Date: Thu, 10 Dec 2020 11:55:21 +0800 Message-Id: <20201210035526.38938-8-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201210035526.38938-1-songmuchun@bytedance.com> References: <20201210035526.38938-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because we reuse the first tail vmemmap page frame and remap it with read-only, we cannot set the PageHWPosion on a tail page. So we can use the head[4].mapping to record the real error page index and set the raw error page PageHWPoison later. Signed-off-by: Muchun Song --- mm/hugetlb.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 542e6cb81321..06157df08d8e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1347,6 +1347,47 @@ static inline void __update_and_free_page(struct hstate *h, struct page *page) schedule_work(&hpage_update_work); } +static inline void subpage_hwpoison_deliver(struct hstate *h, struct page *head) +{ + struct page *page = head; + + if (!free_vmemmap_pages_per_hpage(h)) + return; + + if (PageHWPoison(head)) + page = head + page_private(head + 4); + + /* + * Move PageHWPoison flag from head page to the raw error page, + * which makes any subpages rather than the error page reusable. + */ + if (page != head) { + SetPageHWPoison(page); + ClearPageHWPoison(head); + } +} + +static inline void set_subpage_hwpoison(struct hstate *h, struct page *head, + struct page *page) +{ + if (!PageHWPoison(head)) + return; + + if (free_vmemmap_pages_per_hpage(h)) { + set_page_private(head + 4, page - head); + return; + } + + /* + * Move PageHWPoison flag from head page to the raw error page, + * which makes any subpages rather than the error page reusable. + */ + if (page != head) { + SetPageHWPoison(page); + ClearPageHWPoison(head); + } +} + static void update_and_free_page(struct hstate *h, struct page *page) { if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) @@ -1363,6 +1404,7 @@ static void __free_hugepage(struct hstate *h, struct page *page) int i; alloc_huge_page_vmemmap(h, page); + subpage_hwpoison_deliver(h, page); for (i = 0; i < pages_per_huge_page(h); i++) { page[i].flags &= ~(1 << PG_locked | 1 << PG_error | @@ -1840,14 +1882,8 @@ int dissolve_free_huge_page(struct page *page) int nid = page_to_nid(head); if (h->free_huge_pages - h->resv_huge_pages == 0) goto out; - /* - * Move PageHWPoison flag from head page to the raw error page, - * which makes any subpages rather than the error page reusable. - */ - if (PageHWPoison(head) && page != head) { - SetPageHWPoison(page); - ClearPageHWPoison(head); - } + + set_subpage_hwpoison(h, head, page); list_del(&head->lru); h->free_huge_pages--; h->free_huge_pages_node[nid]--; -- 2.11.0