Re: [PATCH v1] mm, pagemap: expose hwpoison entry

From: Peter Xu
Date: Tue Oct 12 2021 - 22:49:17 EST


Hi, Naoya,

On Mon, Oct 04, 2021 at 08:50:01PM +0900, Naoya Horiguchi wrote:
> +static inline struct page *hwpoison_entry_to_page(swp_entry_t entry)
> +{
> + struct page *p = pfn_to_page(swp_offset(entry));
> +
> + WARN_ON(!PageHWPoison(p));
> + return p;
> +}

This is more a pure question..

I'm wondering whether that WARN_ON() could trigger.

IOW, what if we poison an anonymous page and then unpoison it? Will there be a
hwpoison swap entry leftover in the ptes that it used to map? Will it crash
the program when the page is accessed?

I had a feeling that when handling the page fault in do_swap_page before we
SIGBUS the program, we should double-check the PageHWPoison on the pfn page,
but I could be missing something..

Thanks,

--
Peter Xu