linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Liu Shixin <liushixin2@huawei.com>,
	Yang Shi <shy828301@gmail.com>,
	Oscar Salvador <osalvador@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/9] mm, hwpoison, hugetlb: support saving mechanism of raw error pages
Date: Tue, 28 Jun 2022 18:37:18 +0800	[thread overview]
Message-ID: <YrrZ3hZlqEb3rlM0@FVFYT0MHHV2J> (raw)
In-Reply-To: <20220628081754.GA2206088@hori.linux.bs1.fc.nec.co.jp>

On Tue, Jun 28, 2022 at 08:17:55AM +0000, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Tue, Jun 28, 2022 at 02:26:47PM +0800, Muchun Song wrote:
> > On Tue, Jun 28, 2022 at 02:41:22AM +0000, HORIGUCHI NAOYA(堀口 直也) wrote:
> > > On Mon, Jun 27, 2022 at 05:26:01PM +0800, Muchun Song wrote:
> > > > On Fri, Jun 24, 2022 at 08:51:48AM +0900, Naoya Horiguchi wrote:
> > > > > From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> ...
> > > > > +	} else {
> > > > > +		/*
> > > > > +		 * Failed to save raw error info.  We no longer trace all
> > > > > +		 * hwpoisoned subpages, and we need refuse to free/dissolve
> > > > > +		 * this hwpoisoned hugepage.
> > > > > +		 */
> > > > > +		set_raw_hwp_unreliable(hpage);
> > > > > +		return ret;
> > > > > +	}
> > > > > +	return ret;
> > > > > +}
> > > > > +
> > > > > +inline int hugetlb_clear_page_hwpoison(struct page *hpage)
> > > > > +{
> > > > > +	struct llist_head *head;
> > > > > +	struct llist_node *t, *tnode;
> > > > > +
> > > > > +	if (raw_hwp_unreliable(hpage))
> > > > > +		return -EBUSY;
> > > > 
> > > > IIUC, we use head page's PageHWPoison to synchronize hugetlb_clear_page_hwpoison()
> > > > and hugetlb_set_page_hwpoison(), right? If so, who can set hwp_unreliable here?
> > > 
> > > Sorry if I might miss your point, but raw_hwp_unreliable is set when
> > > allocating raw_hwp_page failed.  hugetlb_set_page_hwpoison() can be called
> > 
> > Sorry. I have missed this. Thanks for your clarification.
> > 
> > > multiple times on a hugepage and if one of the calls fails, the hwpoisoned
> > > hugepage becomes unreliable.
> > > 
> > > BTW, as you pointed out above, if we switch to passing GFP_ATOMIC to kmalloc(),
> > > the kmalloc() never fails, so we no longer have to implement this unreliable
> > 
> > No. kmalloc() with GFP_ATOMIC can fail unless I miss something important.
> 
> OK, I've interpretted the comment about GFP_ATOMIC wrongly.
> 
>  * %GFP_ATOMIC users can not sleep and need the allocation to succeed. A lower
>  * watermark is applied to allow access to "atomic reserves".
>  
> 
> > > flag, so things get simpler.
> > > 
> > > > 
> > > > > +	ClearPageHWPoison(hpage);
> > > > > +	head = raw_hwp_list_head(hpage);
> > > > > +	llist_for_each_safe(tnode, t, head->first) {
> > > > 
> > > > Is it possible that a new item is added hugetlb_set_page_hwpoison()  and we do not
> > > > traverse it (we have cleared page's PageHWPoison)? Then we ignored a real hwpoison
> > > > page, right?
> > > 
> > > Maybe you are mentioning the race like below. Yes, that's possible.
> > >
> > 
> > Sorry, ignore my previous comments, I'm thinking something wrong.
> > 
> > >   CPU 0                            CPU 1
> > > 
> > >                                    free_huge_page
> > >                                      lock hugetlb_lock
> > >                                      ClearHPageMigratable
> > 				       remove_hugetlb_page()
> > 				       // the page is non-HugeTLB now
> 
> Oh, I missed that.
> 
> > >                                      unlock hugetlb_lock
> > >   get_huge_page_for_hwpoison
> > >     lock hugetlb_lock
> > >     __get_huge_page_for_hwpoison
> > 
> > 	// cannot reach here since it is not a HugeTLB page now.
> > 	// So this race is impossible. Then we fallback to normal
> > 	// page handling. Seems there is a new issue here.
> > 	//
> > 	// memory_failure()
> > 	//	try_memory_failure_hugetlb()
> > 	//	if (hugetlb)
> > 	//		goto unlock_mutex;
> > 	//	if (TestSetPageHWPoison(p)) {
> > 	//	// This non-HugeTLB page's vmemmap is still optimized.
> > 	
> > Setting COMPOUND_PAGE_DTOR after hugetlb_vmemmap_restore() might fix this
> > issue, but we will encounter this race as you mentioned below.
> 
> I don't have clear ideas about this now (I don't test vmemmap-optimized case
> yet), so I will think more about this case. Maybe memory_failure() need
> detect it because memory_failure() heaviliy depends on the status of struct
> page.
>

Because HVO (HugeTLB Vmemmap Optimization) will map all tail vmemmap pages
with read-only, we cannot write any data to some tail struct pages. It is
a new issue unrelated to this patch.

Thanks.
 
> Thanks,
> Naoya Horiguchi
> 
> > 
> > Thanks.
> > 	
> > >       hugetlb_set_page_hwpoison
> > >         allocate raw_hwp_page
> > >         TestSetPageHWPoison
> > >                                      update_and_free_page
> > >                                        __update_and_free_page
> > >                                          if (PageHWPoison)
> > >                                            hugetlb_clear_page_hwpoison
> > >                                              TestClearPageHWPoison
> > >                                              // remove all list items
> > >         llist_add
> > >     unlock hugetlb_lock
> > > 
> > > 
> > > The end result seems not critical (leaking raced raw_hwp_page?), but
> > > we need fix.


  reply	other threads:[~2022-06-28 10:37 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 23:51 [PATCH v2 0/9] mm, hwpoison: enable 1GB hugepage support (v2) Naoya Horiguchi
2022-06-23 23:51 ` [PATCH v2 1/9] mm/hugetlb: remove checking hstate_is_gigantic() in return_unused_surplus_pages() Naoya Horiguchi
2022-06-24  2:25   ` Miaohe Lin
2022-06-24  8:03     ` Muchun Song
2022-06-24  8:15       ` Miaohe Lin
2022-06-24  8:34         ` HORIGUCHI NAOYA(堀口 直也)
2022-06-24 19:11           ` Mike Kravetz
2022-06-27  6:02             ` HORIGUCHI NAOYA(堀口 直也)
2022-06-27 17:25               ` Mike Kravetz
2022-06-28  3:01                 ` Miaohe Lin
2022-06-28  8:38                 ` HORIGUCHI NAOYA(堀口 直也)
2022-06-30  2:27                   ` HORIGUCHI NAOYA(堀口 直也)
2022-06-23 23:51 ` [PATCH v2 2/9] mm/hugetlb: separate path for hwpoison entry in copy_hugetlb_page_range() Naoya Horiguchi
2022-06-24  9:23   ` Miaohe Lin
2022-06-27  6:06     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-24 20:57   ` Mike Kravetz
2022-06-27  6:48     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-27  7:57   ` Muchun Song
2022-06-23 23:51 ` [PATCH v2 3/9] mm/hugetlb: make pud_huge() and huge_pud() aware of non-present pud entry Naoya Horiguchi
2022-06-24  8:40   ` HORIGUCHI NAOYA(堀口 直也)
2022-06-25  0:02   ` Mike Kravetz
2022-06-27  7:07     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-25  9:42   ` Miaohe Lin
2022-06-27  7:24     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-23 23:51 ` [PATCH v2 4/9] mm, hwpoison, hugetlb: support saving mechanism of raw error pages Naoya Horiguchi
2022-06-27  3:16   ` Miaohe Lin
2022-06-27  7:56     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-27  9:26   ` Muchun Song
2022-06-28  2:41     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-28  6:26       ` Muchun Song
2022-06-28  7:51         ` Muchun Song
2022-06-28  8:17         ` HORIGUCHI NAOYA(堀口 直也)
2022-06-28 10:37           ` Muchun Song [this message]
2022-06-23 23:51 ` [PATCH v2 5/9] mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage Naoya Horiguchi
2022-06-27  8:32   ` Miaohe Lin
2022-06-27 11:48     ` Miaohe Lin
2022-06-23 23:51 ` [PATCH v2 6/9] mm, hwpoison: set PG_hwpoison for busy hugetlb pages Naoya Horiguchi
2022-06-27  8:39   ` Miaohe Lin
2022-06-23 23:51 ` [PATCH v2 7/9] mm, hwpoison: make __page_handle_poison returns int Naoya Horiguchi
2022-06-27  9:02   ` Miaohe Lin
2022-06-28  6:02     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-23 23:51 ` [PATCH v2 8/9] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage Naoya Horiguchi
2022-06-27 12:24   ` Miaohe Lin
2022-06-23 23:51 ` [PATCH v2 9/9] mm, hwpoison: enable memory error handling on " Naoya Horiguchi
2022-06-28  2:06   ` Miaohe Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrrZ3hZlqEb3rlM0@FVFYT0MHHV2J \
    --to=songmuchun@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liushixin2@huawei.com \
    --cc=mike.kravetz@oracle.com \
    --cc=nao.horiguchi@gmail.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    --cc=shy828301@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).