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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 5B6B0C433E0 for ; Wed, 10 Mar 2021 15:28:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF6DF64F81 for ; Wed, 10 Mar 2021 15:28:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF6DF64F81 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 058228D01BC; Wed, 10 Mar 2021 10:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 02DF18D01A6; Wed, 10 Mar 2021 10:28:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E38188D01BC; Wed, 10 Mar 2021 10:28:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id C9ABA8D01A6 for ; Wed, 10 Mar 2021 10:28:10 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 84CFF1EFD for ; Wed, 10 Mar 2021 15:28:10 +0000 (UTC) X-FDA: 77904345540.11.59E1556 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf27.hostedemail.com (Postfix) with ESMTP id 0F447801914F for ; Wed, 10 Mar 2021 15:27:57 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615390080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rV2+nGi9H+LnzHxy4iouC60dKrTmppkWVNroc466CSU=; b=YZL8nOyZeCwufqUC87IWBmJFM0SB1zh3XusV6PGa0yANnsbREDb4TQblLI/+0nUQ+xNf6X FTe8cUwCBbHK+MAdOrch4O6veeJXY6FKhGO+pIi6XwEXC5/Y0CwVxq2SgMsOg6WBK3Wcw9 bdM4pvcjyxGGdxAlmdOR0bLFzrh6AF0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 08259ABD7; Wed, 10 Mar 2021 15:28:00 +0000 (UTC) Date: Wed, 10 Mar 2021 16:27:59 +0100 From: Michal Hocko To: Muchun Song Cc: 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, song.bao.hua@hisilicon.com, david@redhat.com, naoya.horiguchi@nec.com, joao.m.martins@oracle.com, duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Chen Huang , Bodeddula Balasubramaniam Subject: Re: [PATCH v18 5/9] mm: hugetlb: set the PageHWPoison to the raw error page Message-ID: References: <20210308102807.59745-1-songmuchun@bytedance.com> <20210308102807.59745-6-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210308102807.59745-6-songmuchun@bytedance.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0F447801914F X-Stat-Signature: kifyouyhd6e3mjix5pspenykt1wg3xio Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615390077-83599 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: On Mon 08-03-21 18:28:03, Muchun Song wrote: > Because we reuse the first tail vmemmap page frame and remap it > with read-only, we cannot set the PageHWPosion on some tail pages. > So we can use the head[4].private (There are at least 128 struct > page structures associated with the optimized HugeTLB page, so > using head[4].private is safe) to record the real error page index > and set the raw error page PageHWPoison later. Can we have more poisoned tail pages? Also who does consume that index and set the HWPoison on the proper tail page? > Signed-off-by: Muchun Song > Reviewed-by: Oscar Salvador > Acked-by: David Rientjes > Tested-by: Chen Huang > Tested-by: Bodeddula Balasubramaniam > --- > mm/hugetlb.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 72 insertions(+), 8 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 377e0c1b283f..c0c1b7635ca9 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1304,6 +1304,74 @@ static inline void destroy_compound_gigantic_page(struct page *page, > unsigned int order) { } > #endif > > +#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP > +static inline void hwpoison_subpage_deliver(struct hstate *h, struct page *head) > +{ > + struct page *page; > + > + if (!PageHWPoison(head) || !free_vmemmap_pages_per_hpage(h)) > + return; > + > + 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 hwpoison_subpage_set(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); > + } else if (page != head) { > + /* > + * Move PageHWPoison flag from head page to the raw error page, > + * which makes any subpages rather than the error page reusable. > + */ > + SetPageHWPoison(page); > + ClearPageHWPoison(head); > + } > +} > + > +static inline void hwpoison_subpage_clear(struct hstate *h, struct page *head) > +{ > + if (!PageHWPoison(head) || !free_vmemmap_pages_per_hpage(h)) > + return; > + > + set_page_private(head + 4, 0); > +} > +#else > +static inline void hwpoison_subpage_deliver(struct hstate *h, struct page *head) > +{ > +} > + > +static inline void hwpoison_subpage_set(struct hstate *h, struct page *head, > + struct page *page) > +{ > + if (PageHWPoison(head) && page != head) { > + /* > + * Move PageHWPoison flag from head page to the raw error page, > + * which makes any subpages rather than the error page reusable. > + */ > + SetPageHWPoison(page); > + ClearPageHWPoison(head); > + } > +} > + > +static inline void hwpoison_subpage_clear(struct hstate *h, struct page *head) > +{ > +} > +#endif > + > static int update_and_free_page(struct hstate *h, struct page *page) > __releases(&hugetlb_lock) __acquires(&hugetlb_lock) > { > @@ -1357,6 +1425,8 @@ static int update_and_free_page(struct hstate *h, struct page *page) > return -ENOMEM; > } > > + hwpoison_subpage_deliver(h, page); > + > for (i = 0; i < pages_per_huge_page(h); > i++, subpage = mem_map_next(subpage, page, i)) { > subpage->flags &= ~(1 << PG_locked | 1 << PG_error | > @@ -1801,14 +1871,7 @@ int dissolve_free_huge_page(struct page *page) > goto retry; > } > > - /* > - * 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); > - } > + hwpoison_subpage_set(h, head, page); > list_del(&head->lru); > h->free_huge_pages--; > h->free_huge_pages_node[nid]--; > @@ -1818,6 +1881,7 @@ int dissolve_free_huge_page(struct page *page) > h->surplus_huge_pages--; > h->surplus_huge_pages_node[nid]--; > h->max_huge_pages++; > + hwpoison_subpage_clear(h, head); > } > } > out: > -- > 2.11.0 > -- Michal Hocko SUSE Labs