Re: [PATCH] mm: skip checking poison pattern for page_to_nid()

From: Michal Hocko
Date: Wed Dec 19 2018 - 05:20:16 EST


On Tue 18-12-18 20:57:32, Qian Cai wrote:
[...]
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5411de93a363..f083f366ea90 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -985,9 +985,7 @@ extern int page_to_nid(const struct page *page);
> #else
> static inline int page_to_nid(const struct page *page)
> {
> - struct page *p = (struct page *)page;
> -
> - return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK;
> + return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
> }
> #endif

I didn't get to think about a proper fix but this is clearly worng. If
the page is still poisoned then flags are clearly bogus and the node you
get is a garbage as well. Have you actually tested this patch?
--
Michal Hocko
SUSE Labs