* [PATCH] mm: avoid endless recursion in dump_page()
@ 2016-09-08 8:21 Kirill A. Shutemov
2016-09-21 14:27 ` Vlastimil Babka
0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2016-09-08 8:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Kirill A. Shutemov
dump_page() uses page_mapcount() to get mapcount of the page.
page_mapcount() has VM_BUG_ON_PAGE(PageSlab(page)) as mapcount doesn't
make sense for slab pages and the field in struct page used for other
information.
It leads to recursion if dump_page() called for slub page and DEBUG_VM
is enabled:
dump_page() -> page_mapcount() -> VM_BUG_ON_PAGE() -> dump_page -> ...
Let's avoid calling page_mapcount() for slab pages in dump_page().
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
mm/debug.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/debug.c b/mm/debug.c
index 8865bfb41b0b..74c7cae4f683 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -42,9 +42,11 @@ const struct trace_print_flags vmaflag_names[] = {
void __dump_page(struct page *page, const char *reason)
{
+ int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
+
pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
- page, page_ref_count(page), page_mapcount(page),
- page->mapping, page->index);
+ page, page_ref_count(page), mapcount,
+ page->mapping, page_to_pgoff(page));
if (PageCompound(page))
pr_cont(" compound_mapcount: %d", compound_mapcount(page));
pr_cont("\n");
--
2.9.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: avoid endless recursion in dump_page()
2016-09-08 8:21 [PATCH] mm: avoid endless recursion in dump_page() Kirill A. Shutemov
@ 2016-09-21 14:27 ` Vlastimil Babka
2016-09-22 10:55 ` Kirill A. Shutemov
0 siblings, 1 reply; 4+ messages in thread
From: Vlastimil Babka @ 2016-09-21 14:27 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton; +Cc: linux-mm
On 09/08/2016 10:21 AM, Kirill A. Shutemov wrote:
> dump_page() uses page_mapcount() to get mapcount of the page.
> page_mapcount() has VM_BUG_ON_PAGE(PageSlab(page)) as mapcount doesn't
> make sense for slab pages and the field in struct page used for other
> information.
>
> It leads to recursion if dump_page() called for slub page and DEBUG_VM
> is enabled:
>
> dump_page() -> page_mapcount() -> VM_BUG_ON_PAGE() -> dump_page -> ...
>
> Let's avoid calling page_mapcount() for slab pages in dump_page().
How about instead splitting page_mapcount() so that there is a version
without VM_BUG_ON_PAGE()?
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
> mm/debug.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/debug.c b/mm/debug.c
> index 8865bfb41b0b..74c7cae4f683 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -42,9 +42,11 @@ const struct trace_print_flags vmaflag_names[] = {
>
> void __dump_page(struct page *page, const char *reason)
> {
At least there should be a comment explaining why.
> + int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
> +
> pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
> - page, page_ref_count(page), page_mapcount(page),
> - page->mapping, page->index);
> + page, page_ref_count(page), mapcount,
> + page->mapping, page_to_pgoff(page));
> if (PageCompound(page))
> pr_cont(" compound_mapcount: %d", compound_mapcount(page));
> pr_cont("\n");
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: avoid endless recursion in dump_page()
2016-09-21 14:27 ` Vlastimil Babka
@ 2016-09-22 10:55 ` Kirill A. Shutemov
2016-09-22 11:26 ` Vlastimil Babka
0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2016-09-22 10:55 UTC (permalink / raw)
To: Vlastimil Babka; +Cc: Kirill A. Shutemov, Andrew Morton, linux-mm
On Wed, Sep 21, 2016 at 04:27:31PM +0200, Vlastimil Babka wrote:
> On 09/08/2016 10:21 AM, Kirill A. Shutemov wrote:
> >dump_page() uses page_mapcount() to get mapcount of the page.
> >page_mapcount() has VM_BUG_ON_PAGE(PageSlab(page)) as mapcount doesn't
> >make sense for slab pages and the field in struct page used for other
> >information.
> >
> >It leads to recursion if dump_page() called for slub page and DEBUG_VM
> >is enabled:
> >
> >dump_page() -> page_mapcount() -> VM_BUG_ON_PAGE() -> dump_page -> ...
> >
> >Let's avoid calling page_mapcount() for slab pages in dump_page().
>
> How about instead splitting page_mapcount() so that there is a version
> without VM_BUG_ON_PAGE()?
Why? page->_mapping is garbage for slab page and might be confusing.
If you want the information from page->_mapping union for slab page to be
shown during dump_page() we should present in proper way.
>
> >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >---
> > mm/debug.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> >diff --git a/mm/debug.c b/mm/debug.c
> >index 8865bfb41b0b..74c7cae4f683 100644
> >--- a/mm/debug.c
> >+++ b/mm/debug.c
> >@@ -42,9 +42,11 @@ const struct trace_print_flags vmaflag_names[] = {
> >
> > void __dump_page(struct page *page, const char *reason)
> > {
>
> At least there should be a comment explaining why.
Fair enough.
> >+ int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: avoid endless recursion in dump_page()
2016-09-22 10:55 ` Kirill A. Shutemov
@ 2016-09-22 11:26 ` Vlastimil Babka
0 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2016-09-22 11:26 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: Kirill A. Shutemov, Andrew Morton, linux-mm
On 09/22/2016 12:55 PM, Kirill A. Shutemov wrote:
> On Wed, Sep 21, 2016 at 04:27:31PM +0200, Vlastimil Babka wrote:
>> On 09/08/2016 10:21 AM, Kirill A. Shutemov wrote:
>> >dump_page() uses page_mapcount() to get mapcount of the page.
>> >page_mapcount() has VM_BUG_ON_PAGE(PageSlab(page)) as mapcount doesn't
>> >make sense for slab pages and the field in struct page used for other
>> >information.
>> >
>> >It leads to recursion if dump_page() called for slub page and DEBUG_VM
>> >is enabled:
>> >
>> >dump_page() -> page_mapcount() -> VM_BUG_ON_PAGE() -> dump_page -> ...
>> >
>> >Let's avoid calling page_mapcount() for slab pages in dump_page().
>>
>> How about instead splitting page_mapcount() so that there is a version
>> without VM_BUG_ON_PAGE()?
>
> Why? page->_mapping is garbage for slab page and might be confusing.
>
> If you want the information from page->_mapping union for slab page to be
> shown during dump_page() we should present in proper way.
Hmm, fair enough.
>
>> >+ int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
>
> From d550530cc40ca2e9d60c84a893901c2dad6e7767 Mon Sep 17 00:00:00 2001
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Date: Thu, 22 Sep 2016 13:52:40 +0300
> Subject: [PATCH] mm: clarify why we avoid page_mapcount() for slab pages in
> dump_page()
>
> Let's add comment on why we skip page_mapcount() for sl[aou]b pages.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Thanks.
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/debug.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/mm/debug.c b/mm/debug.c
> index 74c7cae4f683..9feb699c5d25 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -42,6 +42,11 @@ const struct trace_print_flags vmaflag_names[] = {
>
> void __dump_page(struct page *page, const char *reason)
> {
> + /*
> + * Avoid VM_BUG_ON() in page_mapcount().
> + * page->_mapcount space in struct page is used by sl[aou]b pages to
> + * encode own info.
> + */
> int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
>
> pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-22 11:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 8:21 [PATCH] mm: avoid endless recursion in dump_page() Kirill A. Shutemov
2016-09-21 14:27 ` Vlastimil Babka
2016-09-22 10:55 ` Kirill A. Shutemov
2016-09-22 11:26 ` Vlastimil Babka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.