From patchwork Sun Nov 8 14:11:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11889647 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 5691A139F for ; Sun, 8 Nov 2020 14:14:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 12EA3221FA for ; Sun, 8 Nov 2020 14:14:29 +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="TQI4RgR+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12EA3221FA 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 491556B006C; Sun, 8 Nov 2020 09:14:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 464B46B0073; Sun, 8 Nov 2020 09:14:28 -0500 (EST) 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 3066B6B0074; Sun, 8 Nov 2020 09:14:28 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0036.hostedemail.com [216.40.44.36]) by kanga.kvack.org (Postfix) with ESMTP id 042016B006C for ; Sun, 8 Nov 2020 09:14:27 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A6B5E824999B for ; Sun, 8 Nov 2020 14:14:27 +0000 (UTC) X-FDA: 77461446174.08.help39_2513446272e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 8BFF51819E76B for ; Sun, 8 Nov 2020 14:14:27 +0000 (UTC) X-Spam-Summary: 1,0,0,54e2345fada7a8d1,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:3354:3865:3866:3867:3868:3872:3874:4117:4385:5007:6261:6653:6737:6738:7875:8957:10004:11026:11232:11658:11914:12043:12048:12291:12297:12438:12517:12519:12555:12683:12895:13894:14110:14181:14394:14721:21080:21444:21451:21627:30054:30090,0,RBL:209.85.215.193:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04y8o3ujw96wae579zauko5mj5sstopwuw4mb4p4abswg81z9dpi3x7yj8qu6z3.9esbxpnycc5bp4jd3aus9j1xxrccjrycwja6fy9s86hdkqptwd5efpajjquzfo6.4-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:491,LUA_SUMMARY:none X-HE-Tag: help39_2513446272e4 X-Filterd-Recvd-Size: 6536 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Sun, 8 Nov 2020 14:14:26 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id 62so4591246pgg.12 for ; Sun, 08 Nov 2020 06:14:26 -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=JQobaiL/2z+J7n7cUT8D73Vv1rVUSdnEtfcckH7xNUc=; b=TQI4RgR+eZKPIpHCcExujStJETh7EgtxIcThT90CaF/OshoASZBCYswpsMUlYJF1Ls F6QCz0qeeZ9bCkGft5YO/iHzAWqWKSn7E58avQlNL8NGabj7QhtvVnfMmHeSZBcYItci uFVAIgzooed5nMDoyuppTHMJal3MkK/QKMt7cMl0eJkyfkQYStJohj2dxygQ0QNtFrYj 35vu4IPC8iVHz8kgtbsqglpHt7SLRgVdVJRmN2viK5a66qVXQWjwlUE2hlvQjm6VEVXd CJwsZ5n/4hPxuEO23NtFXTUu7TOa9Bik/RNq4lbVaRRTcjlNAvIgqp8KQpix9WisNBTv zF/Q== 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=JQobaiL/2z+J7n7cUT8D73Vv1rVUSdnEtfcckH7xNUc=; b=Qkp8p6y7ETrEGvQkFpHoafr5KD6pj4fIsR0w9b/+3CI7nh1EqMUjMl4OeNpX0h2d0n sl1cnLzpFG1yuXHeim4/8MfJGnYWMVAyLNgCJh5hIj7gxQNDI6fDPWGimlx1f8cvadGw uPJoBAQ212P/DpaNMhVdfmuSTMR5nSTufPpjbRL0G7IsEcflhxq/lI0BNaX1ihZUSFEy VEaoDoJxDvDRfkN6BMcZ92GPBCH8pwS2nLZc8n9SohB9kt4CIVT/Vj/kV2qk/JcnfVWX aiQfT8nU8pMBZGaw/A6rYm0IpVFbOkuUwvVikKJYu1Rb/t4jzb5hJ3/vegY/5tfCO9VA E1ZA== X-Gm-Message-State: AOAM530hOjxAcSu34HJx6Rd7RbUJYjP6/hEBTQAhEiaYV2L7jyMiA7UH d+jsqfJGoNL5OxYL4oXcyz9+AQ== X-Google-Smtp-Source: ABdhPJzfdzQqKF1Uc7p58Hp6FF6AnMq9qsLXcQVTzmZlu+VVJFRP/h/1IY5DA4v2QatxdHbEd5Y3Xw== X-Received: by 2002:a63:4d64:: with SMTP id n36mr234404pgl.203.1604844865926; Sun, 08 Nov 2020 06:14:25 -0800 (PST) Received: from localhost.localdomain ([103.136.220.94]) by smtp.gmail.com with ESMTPSA id z11sm8754047pfk.52.2020.11.08.06.14.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2020 06:14:25 -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 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 v3 16/21] mm/hugetlb: Set the PageHWPoison to the raw error page Date: Sun, 8 Nov 2020 22:11:08 +0800 Message-Id: <20201108141113.65450-17-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201108141113.65450-1-songmuchun@bytedance.com> References: <20201108141113.65450-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 page, if we set PageHWPosion on a tail page. It indicates that we may set PageHWPoison on a series of pages. 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 | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 5aaa274b0684..00a6e97629aa 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1794,6 +1794,29 @@ static inline void free_gigantic_page(struct hstate *h, struct page *page) { __free_gigantic_page(page, huge_page_order(h)); } + +static inline void subpage_hwpoison_deliver(struct page *head) +{ + struct page *page = head; + + 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 page *head, struct page *page) +{ + if (PageHWPoison(head)) + set_page_private(head + 4, page - head); +} #else static inline void hugetlb_vmemmap_init(struct hstate *h) { @@ -1841,6 +1864,22 @@ static inline void free_gigantic_page(struct hstate *h, struct page *page) __free_gigantic_page(page, huge_page_order(h)); spin_lock(&hugetlb_lock); } + +static inline void subpage_hwpoison_deliver(struct page *head) +{ +} + +static inline void set_subpage_hwpoison(struct page *head, struct page *page) +{ + /* + * 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); + } +} #endif static void update_and_free_page(struct hstate *h, struct page *page) @@ -1859,6 +1898,7 @@ static void __free_hugepage(struct hstate *h, struct page *page) int i; alloc_huge_page_vmemmap(h, page); + subpage_hwpoison_deliver(page); for (i = 0; i < pages_per_huge_page(h); i++) { page[i].flags &= ~(1 << PG_locked | 1 << PG_error | @@ -2416,14 +2456,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(head, page); list_del(&head->lru); h->free_huge_pages--; h->free_huge_pages_node[nid]--;