2023-07-20 01:30:58

by Naoya Horiguchi

[permalink] [raw]
Subject: Re: [PATCH 4/4] mm: memory-failure: add PageOffline() check

On Sat, Jul 15, 2023 at 11:17:29AM +0800, Miaohe Lin wrote:
> Memory failure is not interested in logically offlined page. Skip this
> type of pages.
>
> Signed-off-by: Miaohe Lin <[email protected]>
> ---
> mm/memory-failure.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 42e63b0ab5f7..ed79b69837de 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1559,7 +1559,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
> * Here we are interested only in user-mapped pages, so skip any
> * other types of pages.
> */
> - if (PageReserved(p) || PageSlab(p) || PageTable(p))
> + if (PageReserved(p) || PageSlab(p) || PageTable(p) || PageOffline(p))

hwpoison_user_mappings() is called after some checks are done, so I'm not
sure that it's the right place to check PageOffline().
We could check it before setting PageHWPoison() as we do at the beginning of
memory_failure() around pfn_to_online_page(). Does it make sense?

Thanks,
Naoya Horiguchi

> return true;
> if (!(PageLRU(hpage) || PageHuge(p)))
> return true;
> @@ -2513,7 +2513,8 @@ int unpoison_memory(unsigned long pfn)
> goto unlock_mutex;
> }
>
> - if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio))
> + if (folio_test_slab(folio) || PageTable(&folio->page) ||
> + folio_test_reserved(folio) || PageOffline(&folio->page))
> goto unlock_mutex;
>
> /*
> --
> 2.33.0
>
>
>