From patchwork Tue Sep 15 12:59:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11776527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A8D3746 for ; Tue, 15 Sep 2020 13:03:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EFF6820829 for ; Tue, 15 Sep 2020 13:03:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="cXXnrjbp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFF6820829 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 3C360900046; Tue, 15 Sep 2020 09:03:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3731A900041; Tue, 15 Sep 2020 09:03:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 260B4900046; Tue, 15 Sep 2020 09:03:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 0D6EC900041 for ; Tue, 15 Sep 2020 09:03:18 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C1811181AEF1E for ; Tue, 15 Sep 2020 13:03:17 +0000 (UTC) X-FDA: 77265311634.02.mass08_54006c927111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 71E07100AF080 for ; Tue, 15 Sep 2020 13:03:13 +0000 (UTC) X-Spam-Summary: 1,0,0,4ed7d49e92906db7,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3872:3874:4117:4385:5007:6120:6261:6653:6737:6738:7875:8957:10004:11026:11473:11658:11914:12043:12048:12291:12297:12438:12517:12519:12555:12683:12895:13894:14110:14181:14721:21080:21444:21451:21627:21990:30054:30090,0,RBL:209.85.216.67:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04y86abhk91h9694mgkt77ypr9fcxopcbobkh4ywq3kyyhpju51gnph6dk4ehay.gze6r3uqhiwxc5rzqsw9cuwodm5e5t4qmdb83hasfauayty3fmrfhftsf3nsfsp.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: mass08_54006c927111 X-Filterd-Recvd-Size: 6318 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:03:06 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id a9so1744739pjg.1 for ; Tue, 15 Sep 2020 06:03:06 -0700 (PDT) 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=X4BTtwaMtESewFNIOUy9zxHCLZirXUfq3fAtH3OWyA0=; b=cXXnrjbpWvONeQdtoAVhTZ1yEdWmSsnQjcHBSITYlGXfagXm3/IJgmyXBhneJ6FD7e RBdUN/kDepP9jC/FvRXoRJtKV3yp8pN7OHM1DHiC4YycfS5R5tW7UQm46HQw2bzjYntD ydYttZbIUk7Y7cp0efMhEeVtwpXC92brqjYiP6AsfeIp0gaHFUffOPUnYz1GAumIXGSt BqXqqefdlV3KyEVSMUu6lo2Y6hLkS6u9lNFi0Mok1IDjXxCUQse9upWTGu7yG/jDHyId juUbZp+JFrctB+XeE//2fQvtkKjeKle6+2zAKMxjOU6dksJTwyX1FTXYl3FgMtS6eHA+ T3UQ== 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=X4BTtwaMtESewFNIOUy9zxHCLZirXUfq3fAtH3OWyA0=; b=ck95tLM/AKb6WywMFNa4I9fbL9Uc6idz+UktfhZ2QFx87B0pBXYgCqpeXwsmg7qR32 1HdnWeUP3iKzGl5OwN8VtPUWu1KdQiw+DyLU0zvgmbIg6QmSdFX9NjwcGwE64lI29PET dT/WIZIck7IoSoGg0qbIH3IrCo1rL4N0ItXjR5UaG+n/Lj5gLYT+ubJCUoRjfRIeYJB6 W1alPd9Eec8FrrWCVM2upw3HQq4yNHeEqt5PJOA1ZWQlzuBJ2w4ox8re3PdBT7MMVYu/ 2E7p0+4PKio218th7+NEPPlv02Z7KSp3zB6SLFf/4HIB5GmMqIYaEnfCgOXzZpgUOqCw bAVw== X-Gm-Message-State: AOAM533s/wSymTxNJBWFg3rR9jQOOqWwVzbhnXxtPxEu72hcBmUfXJWe WaNhx7XyxjILdQC/h/2e7sfw3g== X-Google-Smtp-Source: ABdhPJzutEEVq5G6/7+ccPxCWjUDCELLq9lbv2LK9MvrA+j214YRs9JOfhtSh5/VK8gk1Qc8NYMz+A== X-Received: by 2002:a17:90b:3c3:: with SMTP id go3mr4345809pjb.64.1600174986059; Tue, 15 Sep 2020 06:03:06 -0700 (PDT) Received: from localhost.bytedance.net ([103.136.220.66]) by smtp.gmail.com with ESMTPSA id w185sm14269855pfc.36.2020.09.15.06.02.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 06:03:05 -0700 (PDT) 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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [RFC PATCH 18/24] mm/hugetlb: Clear PageHWPoison on the non-error memory page Date: Tue, 15 Sep 2020 20:59:41 +0800 Message-Id: <20200915125947.26204-19-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200915125947.26204-1-songmuchun@bytedance.com> References: <20200915125947.26204-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 71E07100AF080 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 page, if we set PageHWPosion on a tail page. It indicates that we may set PageHWPoison on a series of pages. So we need to clear PageHWPoison on the non-error pages. We use the head[3].mapping to record the real error page index and clear non-error page PageHWPoison later. Signed-off-by: Muchun Song --- mm/hugetlb.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 34706cec21ec..8666cedf9a7b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1847,6 +1847,21 @@ static inline void free_gigantic_page_comm(struct hstate *h, struct page *page) { free_gigantic_page(page, huge_page_order(h)); } + +static inline bool subpage_hwpoison(struct page *head, struct page *page) +{ + return page_private(head + 4) == page - head; +} + +static inline void set_subpage_hwpoison(struct page *head, struct page *page) +{ + set_page_private(head + 4, page - head); +} + +static inline void clear_subpage_hwpoison(struct page *head) +{ + set_page_private(head + 4, 0); +} #else static inline void hugetlb_vmemmap_init(struct hstate *h) { @@ -1894,6 +1909,19 @@ static inline void free_gigantic_page_comm(struct hstate *h, struct page *page) free_gigantic_page(page, huge_page_order(h)); spin_lock(&hugetlb_lock); } + +static inline bool subpage_hwpoison(struct page *head, struct page *page) +{ + return true; +} + +static inline void set_subpage_hwpoison(struct page *head, struct page *page) +{ +} + +static inline void clear_subpage_hwpoison(struct page *head) +{ +} #endif static void update_and_free_page(struct hstate *h, struct page *page) @@ -1918,6 +1946,9 @@ static void __free_hugepage(struct hstate *h, struct page *page) 1 << PG_referenced | 1 << PG_dirty | 1 << PG_active | 1 << PG_private | 1 << PG_writeback); + + if (PageHWPoison(page + i) && !subpage_hwpoison(page, page + i)) + ClearPageHWPoison(page + i); } VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page); VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page); @@ -2107,6 +2138,7 @@ static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) free_huge_page_vmemmap(h, page); /* Must be called before the initialization of @page->lru */ vmemmap_pgtable_free(h, page); + clear_subpage_hwpoison(page); INIT_LIST_HEAD(&page->lru); set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); @@ -2477,6 +2509,7 @@ int dissolve_free_huge_page(struct page *page) SetPageHWPoison(page); ClearPageHWPoison(head); } + set_subpage_hwpoison(head, page); list_del(&head->lru); h->free_huge_pages--; h->free_huge_pages_node[nid]--;