linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Naoya Horiguchi <naoya.horiguchi@linux.dev>
To: luofei <luofei@unicloud.com>
Cc: akpm@linux-foundation.org, linmiaohe@huawei.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Naoya Horiguchi <naoya.horiguchi@nec.com>
Subject: Re: [PATCH v1] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page
Date: Thu, 4 Aug 2022 22:28:53 +0900	[thread overview]
Message-ID: <20220804131639.GA39205@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <20220804122819.2917249-1-luofei@unicloud.com>

On Thu, Aug 04, 2022 at 08:28:19AM -0400, luofei wrote:
> When software-poison a huge page, if dissolve_free_huge_page() failed,
> the huge page will be added to hugepage_freelists. In this case, the
> head page will hold the hwpoison flag, but the real poisoned tail page
> hwpoison flag is not set, this will cause unpoison_memory() fail to
> unpoison the previously poisoned page.

Hi luofei,

When you try to unpoison a hwpoisoned hugepage, you just have to pass the
pfn of the head page, not the pfn of raw poisoned subpage.  Note that the
position of raw error page is not exposed to userspace (dmesg shows it, but
saving and parsing it for unpoison is not that useful) and the related
utilities like page-types only checks PageHWpoison flag to find error pages,
so it seems to me that you're introducing an inconsistent assumption.

Thanks,
Naoya Horiguchi

> 
> So add a check on hugetlb head page, and also need to ensure the
> previously poisoned tail page in huge page raw_hwp_list.
> 
> Signed-off-by: luofei <luofei@unicloud.com>
> ---
>  mm/memory-failure.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 14439806b5ef..92dbeaa24afb 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2293,6 +2293,28 @@ core_initcall(memory_failure_init);
>  		pr_info(fmt, pfn);			\
>  })
>  
> +static bool hugetlb_page_head_poison(struct page *hpage, struct page *page)
> +{
> +	struct llist_head *head;
> +	struct llist_node *t, *tnode;
> +	struct raw_hwp_page *p;
> +
> +	if (!PageHuge(page) || !PageHWPoison(hpage) || !HPageFreed(hpage))
> +		return false;
> +
> +	if (HPageRawHwpUnreliable(hpage))
> +		return false;
> +
> +	head = raw_hwp_list_head(hpage);
> +	llist_for_each_safe(tnode, t, head->first) {
> +		p = container_of(tnode, struct raw_hwp_page, node);
> +		if (p->page == page)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  /**
>   * unpoison_memory - Unpoison a previously poisoned page
>   * @pfn: Page number of the to be unpoisoned page
> @@ -2330,7 +2352,7 @@ int unpoison_memory(unsigned long pfn)
>  		goto unlock_mutex;
>  	}
>  
> -	if (!PageHWPoison(p)) {
> +	if (!PageHWPoison(p) && !hugetlb_page_head_poison(page, p)) {
>  		unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n",
>  				 pfn, &unpoison_rs);
>  		goto unlock_mutex;
> -- 
> 2.27.0


      reply	other threads:[~2022-08-04 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 12:28 luofei
2022-08-04 13:28 ` Naoya Horiguchi [this message]

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=20220804131639.GA39205@hori.linux.bs1.fc.nec.co.jp \
    --to=naoya.horiguchi@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luofei@unicloud.com \
    --cc=naoya.horiguchi@nec.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