* [PATCH 1/3] mm/page_alloc: Use dump_page() directly
@ 2021-05-12 3:10 Kefeng Wang
2021-05-12 3:10 ` [PATCH 2/3] mm: Make __dump_page() static Kefeng Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Kefeng Wang @ 2021-05-12 3:10 UTC (permalink / raw)
To: Andrew Morton; +Cc: willy, linux-mm, linux-kernel, Kefeng Wang
Simplfy use dump_page().
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/page_alloc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a2fe714aed93..f23702e7c564 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -658,8 +658,7 @@ static void bad_page(struct page *page, const char *reason)
pr_alert("BUG: Bad page state in process %s pfn:%05lx\n",
current->comm, page_to_pfn(page));
- __dump_page(page, reason);
- dump_page_owner(page);
+ dump_page(page, reason);
print_modules();
dump_stack();
--
2.26.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/3] mm: Make __dump_page() static 2021-05-12 3:10 [PATCH 1/3] mm/page_alloc: Use dump_page() directly Kefeng Wang @ 2021-05-12 3:10 ` Kefeng Wang 2021-05-12 3:10 ` [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() Kefeng Wang 2021-05-12 3:14 ` [PATCH 1/3] mm/page_alloc: Use dump_page() directly Matthew Wilcox 2 siblings, 0 replies; 6+ messages in thread From: Kefeng Wang @ 2021-05-12 3:10 UTC (permalink / raw) To: Andrew Morton; +Cc: willy, linux-mm, linux-kernel, Kefeng Wang No __dump_page() caller, so make it static. Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> --- include/linux/mmdebug.h | 1 - mm/debug.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 5d0767cb424a..9086157b46f3 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -10,7 +10,6 @@ struct vm_area_struct; struct mm_struct; extern void dump_page(struct page *page, const char *reason); -extern void __dump_page(struct page *page, const char *reason); void dump_vma(const struct vm_area_struct *vma); void dump_mm(const struct mm_struct *mm); diff --git a/mm/debug.c b/mm/debug.c index 0bdda8407f71..84cdcd0f7bd3 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -42,7 +42,7 @@ const struct trace_print_flags vmaflag_names[] = { {0, NULL} }; -void __dump_page(struct page *page, const char *reason) +static void __dump_page(struct page *page, const char *reason) { struct page *head = compound_head(page); struct address_space *mapping; -- 2.26.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() 2021-05-12 3:10 [PATCH 1/3] mm/page_alloc: Use dump_page() directly Kefeng Wang 2021-05-12 3:10 ` [PATCH 2/3] mm: Make __dump_page() static Kefeng Wang @ 2021-05-12 3:10 ` Kefeng Wang 2021-05-12 3:15 ` Matthew Wilcox 2021-05-12 3:14 ` [PATCH 1/3] mm/page_alloc: Use dump_page() directly Matthew Wilcox 2 siblings, 1 reply; 6+ messages in thread From: Kefeng Wang @ 2021-05-12 3:10 UTC (permalink / raw) To: Andrew Morton; +Cc: willy, linux-mm, linux-kernel, Kefeng Wang If page is poisoned, it will crash when we call some page related functions, so must check whether the page is poisoned or not firstly. Fixes: 6197ab984b41 ("mm: improve dump_page() for compound pages") Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> --- mm/debug.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/debug.c b/mm/debug.c index 84cdcd0f7bd3..cf84cd9df527 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -44,20 +44,19 @@ const struct trace_print_flags vmaflag_names[] = { static void __dump_page(struct page *page, const char *reason) { - struct page *head = compound_head(page); + struct page *head = NULL; struct address_space *mapping; - bool page_poisoned = PagePoisoned(page); - bool compound = PageCompound(page); + bool compound; /* * Accessing the pageblock without the zone lock. It could change to * "isolate" again in the meantime, but since we are just dumping the * state for debugging, it should be fine to accept a bit of * inaccuracy here due to racing. */ - bool page_cma = is_migrate_cma_page(page); + bool page_cma; int mapcount; char *type = ""; - + bool page_poisoned = PagePoisoned(page); /* * If struct page is poisoned don't access Page*() functions as that * leads to recursive loop. Page*() check for poisoned pages, and calls @@ -68,6 +67,10 @@ static void __dump_page(struct page *page, const char *reason) goto hex_only; } + head = compound_head(page); + page_poisoned = PagePoisoned(page); + page_cma = is_migrate_cma_page(page); + if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { /* * Corrupt page, so we cannot call page_mapping. Instead, do a @@ -178,7 +181,7 @@ static void __dump_page(struct page *page, const char *reason) print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, sizeof(struct page), false); - if (head != page) + if (head && head != page) print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), head, sizeof(struct page), false); -- 2.26.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() 2021-05-12 3:10 ` [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() Kefeng Wang @ 2021-05-12 3:15 ` Matthew Wilcox 2021-05-12 3:23 ` Kefeng Wang 0 siblings, 1 reply; 6+ messages in thread From: Matthew Wilcox @ 2021-05-12 3:15 UTC (permalink / raw) To: Kefeng Wang; +Cc: Andrew Morton, linux-mm, linux-kernel On Wed, May 12, 2021 at 11:10:57AM +0800, Kefeng Wang wrote: > If page is poisoned, it will crash when we call some page related > functions, so must check whether the page is poisoned or not firstly. https://lore.kernel.org/linux-mm/20210430145549.2662354-4-willy@infradead.org/ > Fixes: 6197ab984b41 ("mm: improve dump_page() for compound pages") > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > mm/debug.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 84cdcd0f7bd3..cf84cd9df527 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -44,20 +44,19 @@ const struct trace_print_flags vmaflag_names[] = { > > static void __dump_page(struct page *page, const char *reason) > { > - struct page *head = compound_head(page); > + struct page *head = NULL; > struct address_space *mapping; > - bool page_poisoned = PagePoisoned(page); > - bool compound = PageCompound(page); > + bool compound; > /* > * Accessing the pageblock without the zone lock. It could change to > * "isolate" again in the meantime, but since we are just dumping the > * state for debugging, it should be fine to accept a bit of > * inaccuracy here due to racing. > */ > - bool page_cma = is_migrate_cma_page(page); > + bool page_cma; > int mapcount; > char *type = ""; > - > + bool page_poisoned = PagePoisoned(page); > /* > * If struct page is poisoned don't access Page*() functions as that > * leads to recursive loop. Page*() check for poisoned pages, and calls > @@ -68,6 +67,10 @@ static void __dump_page(struct page *page, const char *reason) > goto hex_only; > } > > + head = compound_head(page); > + page_poisoned = PagePoisoned(page); > + page_cma = is_migrate_cma_page(page); > + > if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > /* > * Corrupt page, so we cannot call page_mapping. Instead, do a > @@ -178,7 +181,7 @@ static void __dump_page(struct page *page, const char *reason) > print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), page, > sizeof(struct page), false); > - if (head != page) > + if (head && head != page) > print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), head, > sizeof(struct page), false); > -- > 2.26.2 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() 2021-05-12 3:15 ` Matthew Wilcox @ 2021-05-12 3:23 ` Kefeng Wang 0 siblings, 0 replies; 6+ messages in thread From: Kefeng Wang @ 2021-05-12 3:23 UTC (permalink / raw) To: Matthew Wilcox; +Cc: Andrew Morton, linux-mm, linux-kernel On 2021/5/12 11:15, Matthew Wilcox wrote: > On Wed, May 12, 2021 at 11:10:57AM +0800, Kefeng Wang wrote: >> If page is poisoned, it will crash when we call some page related >> functions, so must check whether the page is poisoned or not firstly. > > https://lore.kernel.org/linux-mm/20210430145549.2662354-4-willy@infradead.org/ OK, please ignore them, I found this when debug arm issue in lts5.10, thanks. > >> Fixes: 6197ab984b41 ("mm: improve dump_page() for compound pages") >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >> --- >> mm/debug.c | 15 +++++++++------ >> 1 file changed, 9 insertions(+), 6 deletions(-) >> >> diff --git a/mm/debug.c b/mm/debug.c >> index 84cdcd0f7bd3..cf84cd9df527 100644 >> --- a/mm/debug.c >> +++ b/mm/debug.c >> @@ -44,20 +44,19 @@ const struct trace_print_flags vmaflag_names[] = { >> >> static void __dump_page(struct page *page, const char *reason) >> { >> - struct page *head = compound_head(page); >> + struct page *head = NULL; >> struct address_space *mapping; >> - bool page_poisoned = PagePoisoned(page); >> - bool compound = PageCompound(page); >> + bool compound; >> /* >> * Accessing the pageblock without the zone lock. It could change to >> * "isolate" again in the meantime, but since we are just dumping the >> * state for debugging, it should be fine to accept a bit of >> * inaccuracy here due to racing. >> */ >> - bool page_cma = is_migrate_cma_page(page); >> + bool page_cma; >> int mapcount; >> char *type = ""; >> - >> + bool page_poisoned = PagePoisoned(page); >> /* >> * If struct page is poisoned don't access Page*() functions as that >> * leads to recursive loop. Page*() check for poisoned pages, and calls >> @@ -68,6 +67,10 @@ static void __dump_page(struct page *page, const char *reason) >> goto hex_only; >> } >> >> + head = compound_head(page); >> + page_poisoned = PagePoisoned(page); >> + page_cma = is_migrate_cma_page(page); >> + >> if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { >> /* >> * Corrupt page, so we cannot call page_mapping. Instead, do a >> @@ -178,7 +181,7 @@ static void __dump_page(struct page *page, const char *reason) >> print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, >> sizeof(unsigned long), page, >> sizeof(struct page), false); >> - if (head != page) >> + if (head && head != page) >> print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, >> sizeof(unsigned long), head, >> sizeof(struct page), false); >> -- >> 2.26.2 >> >> > . > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mm/page_alloc: Use dump_page() directly 2021-05-12 3:10 [PATCH 1/3] mm/page_alloc: Use dump_page() directly Kefeng Wang 2021-05-12 3:10 ` [PATCH 2/3] mm: Make __dump_page() static Kefeng Wang 2021-05-12 3:10 ` [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() Kefeng Wang @ 2021-05-12 3:14 ` Matthew Wilcox 2 siblings, 0 replies; 6+ messages in thread From: Matthew Wilcox @ 2021-05-12 3:14 UTC (permalink / raw) To: Kefeng Wang; +Cc: Andrew Morton, linux-mm, linux-kernel On Wed, May 12, 2021 at 11:10:55AM +0800, Kefeng Wang wrote: > Simplfy use dump_page(). https://lore.kernel.org/linux-mm/20210430145549.2662354-3-willy@infradead.org/ > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > mm/page_alloc.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index a2fe714aed93..f23702e7c564 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -658,8 +658,7 @@ static void bad_page(struct page *page, const char *reason) > > pr_alert("BUG: Bad page state in process %s pfn:%05lx\n", > current->comm, page_to_pfn(page)); > - __dump_page(page, reason); > - dump_page_owner(page); > + dump_page(page, reason); > > print_modules(); > dump_stack(); > -- > 2.26.2 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-05-12 3:23 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-05-12 3:10 [PATCH 1/3] mm/page_alloc: Use dump_page() directly Kefeng Wang 2021-05-12 3:10 ` [PATCH 2/3] mm: Make __dump_page() static Kefeng Wang 2021-05-12 3:10 ` [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() Kefeng Wang 2021-05-12 3:15 ` Matthew Wilcox 2021-05-12 3:23 ` Kefeng Wang 2021-05-12 3:14 ` [PATCH 1/3] mm/page_alloc: Use dump_page() directly Matthew Wilcox
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox