From patchwork Thu Dec 10 03:55:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11963239 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 6123CC4361B for ; Thu, 10 Dec 2020 03:58:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D7D4123BAC for ; Thu, 10 Dec 2020 03:58:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7D4123BAC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3AC6E6B005D; Wed, 9 Dec 2020 22:58:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35B6F6B0071; Wed, 9 Dec 2020 22:58:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FDB66B0072; Wed, 9 Dec 2020 22:58:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 098886B005D for ; Wed, 9 Dec 2020 22:58:39 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CD2AB8249980 for ; Thu, 10 Dec 2020 03:58:38 +0000 (UTC) X-FDA: 77576015916.09.bun20_34038ef273f5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id AF58A180AD81F for ; Thu, 10 Dec 2020 03:58:38 +0000 (UTC) X-HE-Tag: bun20_34038ef273f5 X-Filterd-Recvd-Size: 6415 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 03:58:38 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id t18so2112185plo.0 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=WCiJksPMthVv7/PLJyhJ24BT3GQiDel6L2zB3jyjV9fvqppdn/N5J551XzbN2pjcFT M0GQRpUSHU6Nzeowq25T2dRDTVWzpfhrHediyH2hreqfcqLOAPRbVnDpYZXo+dAftlB+ 4/ZIunibiDVp7C3z4oDOMq/HpR5RVDpyfQd5s0ZZFvd194I0ea8eS9k1IPcWVapGPM2r S5uZTuECsxlVEp+N2dhiZw4rLlzeAoA/5YnBuW6HbIgNqCuRstHeGjZvI6pMmcM9AVQv ohegos7CE1g3BPmgFFnTonTXnK3/arv2l03fzHJi0MK42Z3B+ag576KoEjJUTU08f/u/ rWyA== X-Gm-Message-State: AOAM5330ZszqiDr1dbZRI+59RQCb5eif0YPWXYW6PSRWOrPW7kYCh8Lx P48EPxuy5IJcFcIuOKETiXn93w== 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 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: 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]--;