linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Michal Hocko <mhocko@suse.com>, Ingo Molnar <mingo@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller <syzkaller@googlegroups.com>
Subject: Re: mm: BUG in pgtable_pmd_page_dtor
Date: Fri, 25 Nov 2016 16:07:57 +0300	[thread overview]
Message-ID: <20161125130757.GC3439@node.shutemov.name> (raw)
In-Reply-To: <2ff6eee6-8828-821a-7dde-c2f68da697a5@suse.cz>

On Fri, Nov 25, 2016 at 01:58:57PM +0100, Vlastimil Babka wrote:
> On 11/25/2016 12:41 PM, Andrey Ryabinin wrote:
> > 
> > 
> > On 11/25/2016 11:42 AM, Vlastimil Babka wrote:
> > 
> >>  	pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
> >>  		  page, page_ref_count(page), mapcount,
> >> @@ -59,6 +61,21 @@ void __dump_page(struct page *page, const char *reason)
> >>  
> >>  	pr_emerg("flags: %#lx(%pGp)\n", page->flags, &page->flags);
> >>  
> >> +	pr_alert("raw struct page data:");
> >> +	for (i = 0; i < sizeof(struct page) / sizeof(unsigned long); i++) {
> >> +		unsigned long *word_ptr;
> >> +
> >> +		word_ptr = ((unsigned long *) page) + i;
> >> +
> >> +		if ((i % words_per_line) == 0) {
> >> +			pr_cont("\n");
> >> +			pr_alert(" %016lx", *word_ptr);
> >> +		} else {
> >> +			pr_cont(" %016lx", *word_ptr);
> >> +		}
> >> +	}
> >> +	pr_cont("\n");
> >> +
> > 
> > Single call to print_hex_dump() could replace this loop.
> 
> Ah, didn't know about that one, thanks!
> 
> This also addresses Kirill's comment:
> 
> -----8<-----
> From 417467521d0a68fb70dc2d5bd151524bf0c79437 Mon Sep 17 00:00:00 2001
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Fri, 25 Nov 2016 09:08:05 +0100
> Subject: [PATCH] mm, debug: print raw struct page data in __dump_page()
> 
> The __dump_page() function is used when a page metadata inconsistency is
> detected, either by standard runtime checks, or extra checks in CONFIG_DEBUG_VM
> builds. It prints some of the relevant metadata, but not the whole struct page,
> which is based on unions and interpretation is dependent on the context.
> 
> This means that sometimes e.g. a VM_BUG_ON_PAGE() checks certain field, which
> is however not printed by __dump_page() and the resulting bug report may then
> lack clues that could help in determining the root cause. This patch solves
> the problem by simply printing the whole struct page word by word, so no part
> is missing, but the interpretation of the data is left to developers. This is
> similar to e.g. x86_64 raw stack dumps.
> 
> Example output:
> 
>  page:ffffea00000475c0 count:1 mapcount:0 mapping:          (null) index:0x0
>  flags: 0x100000000000400(reserved)
>  raw: 0100000000000400 0000000000000000 0000000000000000 00000001ffffffff
>  raw: ffffea00000475e0 ffffea00000475e0 0000000000000000 0000000000000000
>  page dumped because: VM_BUG_ON_PAGE(1)
> 
> [aryabinin@virtuozzo.com: suggested print_hex_dump()]
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  mm/debug.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/mm/debug.c b/mm/debug.c
> index 9feb699c5d25..185c19bda078 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -59,6 +59,10 @@ void __dump_page(struct page *page, const char *reason)
>  
>  	pr_emerg("flags: %#lx(%pGp)\n", page->flags, &page->flags);
>  
> +	print_hex_dump(KERN_ALERT, "raw: ", DUMP_PREFIX_NONE,
> +			32, (sizeof(unsigned long) == 8) ? 8 : 4,

That's a very fancy way to write sizeof(unsigned long) ;)

-- 
 Kirill A. Shutemov

  reply	other threads:[~2016-11-25 13:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 10:19 mm: BUG in pgtable_pmd_page_dtor Dmitry Vyukov
2016-11-18 10:52 ` Kirill A. Shutemov
2016-11-24 13:49 ` Vlastimil Babka
2016-11-24 14:23   ` Dmitry Vyukov
2016-11-25  8:42     ` Vlastimil Babka
2016-11-25 10:48       ` Kirill A. Shutemov
2016-11-25 11:41       ` Andrey Ryabinin
2016-11-25 12:58         ` Vlastimil Babka
2016-11-25 13:07           ` Kirill A. Shutemov [this message]
2016-11-25 14:08             ` Vlastimil Babka
2016-11-25 14:15               ` Kirill A. Shutemov
2016-11-25 16:03               ` Andrey Ryabinin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161125130757.GC3439@node.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).