Message ID | 20210430145549.2662354-4-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Folio Prequel patches | expand |
On 2021/4/30 22:55, Matthew Wilcox (Oracle) wrote: > Move the PagePoisoned test into dump_page(). Skip the hex print > for poisoned pages -- we know they're full of ffffffff. Move the > reason printing from __dump_page() to dump_page(). > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > Reviewed-by: William Kucharski <william.kucharski@oracle.com> > Reviewed-by: Vlastimil Babka <vbabka@suse.cz> > Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > mm/debug.c | 25 +++++++------------------ > 1 file changed, 7 insertions(+), 18 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 84cdcd0f7bd3..e73fe0a8ec3d 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -42,11 +42,10 @@ const struct trace_print_flags vmaflag_names[] = { > {0, NULL} > }; > > -static void __dump_page(struct page *page, const char *reason) > +static void __dump_page(struct page *page) > { > struct page *head = compound_head(page); > struct address_space *mapping; > - bool page_poisoned = PagePoisoned(page); > bool compound = PageCompound(page); > /* > * Accessing the pageblock without the zone lock. It could change to > @@ -58,16 +57,6 @@ static void __dump_page(struct page *page, const char *reason) > int mapcount; > char *type = ""; > > - /* > - * If struct page is poisoned don't access Page*() functions as that > - * leads to recursive loop. Page*() check for poisoned pages, and calls > - * dump_page() when detected. > - */ > - if (page_poisoned) { > - pr_warn("page:%px is uninitialized and poisoned", page); > - goto hex_only; > - } > - > if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > /* > * Corrupt page, so we cannot call page_mapping. Instead, do a > @@ -173,8 +162,6 @@ static void __dump_page(struct page *page, const char *reason) > > pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags, > page_cma ? " CMA" : ""); > - > -hex_only: > print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), page, > sizeof(struct page), false); > @@ -182,14 +169,16 @@ static void __dump_page(struct page *page, const char *reason) > print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), head, > sizeof(struct page), false); > - > - if (reason) > - pr_warn("page dumped because: %s\n", reason); > } > > void dump_page(struct page *page, const char *reason) > { > - __dump_page(page, reason); > + if (PagePoisoned(page)) > + pr_warn("page:%p is uninitialized and poisoned", page); > + else > + __dump_page(page); Hi Matthew, dump_page_owenr() should be called when !PagePoisoned, right? > + if (reason) > + pr_warn("page dumped because: %s\n", reason); > dump_page_owner(page); > } > EXPORT_SYMBOL(dump_page); >
On Wed, May 12, 2021 at 11:29:06AM +0800, Kefeng Wang wrote: > > void dump_page(struct page *page, const char *reason) > > { > > - __dump_page(page, reason); > > + if (PagePoisoned(page)) > > + pr_warn("page:%p is uninitialized and poisoned", page); > > + else > > + __dump_page(page); > > Hi Matthew, dump_page_owenr() should be called when !PagePoisoned, right? > > > > + if (reason) > > + pr_warn("page dumped because: %s\n", reason); > > dump_page_owner(page); > > } > > EXPORT_SYMBOL(dump_page); dump_page_owner() is called whether the page is Poisoned or not ... both before and after this patch. Is there a problem with that?
On 2021/5/12 11:38, Matthew Wilcox wrote: > On Wed, May 12, 2021 at 11:29:06AM +0800, Kefeng Wang wrote: >>> void dump_page(struct page *page, const char *reason) >>> { >>> - __dump_page(page, reason); >>> + if (PagePoisoned(page)) >>> + pr_warn("page:%p is uninitialized and poisoned", page); >>> + else >>> + __dump_page(page); >> >> Hi Matthew, dump_page_owenr() should be called when !PagePoisoned, right? >> >> >>> + if (reason) >>> + pr_warn("page dumped because: %s\n", reason); >>> dump_page_owner(page); >>> } >>> EXPORT_SYMBOL(dump_page); > > dump_page_owner() is called whether the page is Poisoned or not ... > both before and after this patch. Is there a problem with that? struct page_ext *page_ext = lookup_page_ext(page); unsigned long pfn = page_to_pfn(page); struct mem_section *section = __pfn_to_section(pfn); if (!section->page_ext) If page is Poisoned, I guess the section maybe NULL, so section->page_ext may meet NULL pointer dereference, is it possible? > > . >
diff --git a/mm/debug.c b/mm/debug.c index 84cdcd0f7bd3..e73fe0a8ec3d 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -42,11 +42,10 @@ const struct trace_print_flags vmaflag_names[] = { {0, NULL} }; -static void __dump_page(struct page *page, const char *reason) +static void __dump_page(struct page *page) { struct page *head = compound_head(page); struct address_space *mapping; - bool page_poisoned = PagePoisoned(page); bool compound = PageCompound(page); /* * Accessing the pageblock without the zone lock. It could change to @@ -58,16 +57,6 @@ static void __dump_page(struct page *page, const char *reason) int mapcount; char *type = ""; - /* - * If struct page is poisoned don't access Page*() functions as that - * leads to recursive loop. Page*() check for poisoned pages, and calls - * dump_page() when detected. - */ - if (page_poisoned) { - pr_warn("page:%px is uninitialized and poisoned", page); - goto hex_only; - } - if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { /* * Corrupt page, so we cannot call page_mapping. Instead, do a @@ -173,8 +162,6 @@ static void __dump_page(struct page *page, const char *reason) pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags, page_cma ? " CMA" : ""); - -hex_only: print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, sizeof(struct page), false); @@ -182,14 +169,16 @@ static void __dump_page(struct page *page, const char *reason) print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), head, sizeof(struct page), false); - - if (reason) - pr_warn("page dumped because: %s\n", reason); } void dump_page(struct page *page, const char *reason) { - __dump_page(page, reason); + if (PagePoisoned(page)) + pr_warn("page:%p is uninitialized and poisoned", page); + else + __dump_page(page); + if (reason) + pr_warn("page dumped because: %s\n", reason); dump_page_owner(page); } EXPORT_SYMBOL(dump_page);