linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Miaohe Lin <linmiaohe@huawei.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Oscar Salvador <osalvador@suse.de>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Naoya Horiguchi <naoya.horiguchi@nec.com>
Subject: Re: [PATCH] mm/memory_hotplug: avoid consuming corrupted data when offline pages
Date: Thu, 21 Apr 2022 16:20:13 +0200	[thread overview]
Message-ID: <8fae51af-b12f-4232-1330-54f7b0943907@redhat.com> (raw)
In-Reply-To: <20220421135129.19767-1-linmiaohe@huawei.com>

On 21.04.22 15:51, Miaohe Lin wrote:
> When trying to offline pages, HWPoisoned hugepage is migrated without
> checking PageHWPoison first. So corrupted data could be consumed. Fix
> it by deferring isolate_huge_page until PageHWPoison is handled.
> 

CCing Oscar, Mike and Naoya

> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/memory_hotplug.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 4c6065e5d274..093f85ec5c5c 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1600,11 +1600,9 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
>  		folio = page_folio(page);
>  		head = &folio->page;
>  
> -		if (PageHuge(page)) {
> +		if (PageHuge(page))
>  			pfn = page_to_pfn(head) + compound_nr(head) - 1;
> -			isolate_huge_page(head, &source);
> -			continue;
> -		} else if (PageTransHuge(page))
> +		else if (PageTransHuge(page))
>  			pfn = page_to_pfn(head) + thp_nr_pages(page) - 1;
>  
>  		/*
> @@ -1622,6 +1620,11 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
>  			continue;
>  		}
>  
> +		if (PageHuge(page)) {
> +			isolate_huge_page(head, &source);
> +			continue;
> +		}
> +
>  		if (!get_page_unless_zero(page))
>  			continue;
>  		/*

The problem statement makes sense to me but I am not sure about the
details if we run into the "PageHWPoison" path with a huge page. I have
the gut feeling that we have to do more for huge pages in the
PageHWPoison() path, because we might be dealing with a free huge page
after unmap succeeds. I might be wrong.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-04-21 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 13:51 [PATCH] mm/memory_hotplug: avoid consuming corrupted data when offline pages Miaohe Lin
2022-04-21 14:20 ` David Hildenbrand [this message]
2022-04-21 22:04   ` Mike Kravetz
2022-04-22  6:53     ` Miaohe Lin
     [not found]       ` <20220425135555.GA3767079@hori.linux.bs1.fc.nec.co.jp>
2022-04-26 11:41         ` Miaohe Lin
2022-04-27  3:13           ` HORIGUCHI NAOYA(堀口 直也)

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=8fae51af-b12f-4232-1330-54f7b0943907@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    /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).