Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753581AbbKXMgu (ORCPT ); Tue, 24 Nov 2015 07:36:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:51619 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753471AbbKXMgo (ORCPT ); Tue, 24 Nov 2015 07:36:44 -0500 From: Vlastimil Babka To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Joonsoo Kim , Minchan Kim , Sasha Levin , "Kirill A. Shutemov" , Mel Gorman , Michal Hocko , Vlastimil Babka Subject: [PATCH v2 1/9] mm, debug: fix wrongly filtered flags in dump_vma() Date: Tue, 24 Nov 2015 13:36:13 +0100 Message-Id: <1448368581-6923-2-git-send-email-vbabka@suse.cz> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1448368581-6923-1-git-send-email-vbabka@suse.cz> References: <1448368581-6923-1-git-send-email-vbabka@suse.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3683 Lines: 104 The dump_vma() function uses dump_flags() for printing the flags as symbolic names. That function however does a page-flags specific filtering of bits higher than NR_PAGEFLAGS in order to remove the zone id part. For dump_vma() this results in removing several VM_* flags from the symbolic translation. Fix this by refactoring dump_flags() to dump_flag_names(), which only prints the symbolic names in parentheses. Printing the raw flag value with a prefix, and any filtering is left to the caller. In addition to fixing the bug, this allows better flexibility, which will be useful to print gfp_flags by a later patch. Signed-off-by: Vlastimil Babka --- mm/debug.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/mm/debug.c b/mm/debug.c index 8362765..d9718fc 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -46,17 +46,14 @@ static const struct trace_print_flags pageflag_names[] = { #endif }; -static void dump_flags(unsigned long flags, +static void dump_flag_names(unsigned long flags, const struct trace_print_flags *names, int count) { const char *delim = ""; unsigned long mask; int i; - pr_emerg("flags: %#lx(", flags); - - /* remove zone id */ - flags &= (1UL << NR_PAGEFLAGS) - 1; + pr_cont("("); for (i = 0; i < count && flags; i++) { @@ -79,6 +76,8 @@ static void dump_flags(unsigned long flags, void dump_page_badflags(struct page *page, const char *reason, unsigned long badflags) { + unsigned long printflags = page->flags; + pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx", page, atomic_read(&page->_count), page_mapcount(page), page->mapping, page->index); @@ -86,13 +85,19 @@ void dump_page_badflags(struct page *page, const char *reason, pr_cont(" compound_mapcount: %d", compound_mapcount(page)); pr_cont("\n"); BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS); - dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names)); + + pr_emerg("flags: %#lx", printflags); + /* remove zone id */ + printflags &= (1UL << NR_PAGEFLAGS) - 1; + dump_flag_names(printflags, pageflag_names, ARRAY_SIZE(pageflag_names)); + if (reason) pr_alert("page dumped because: %s\n", reason); if (page->flags & badflags) { - pr_alert("bad because of flags:\n"); - dump_flags(page->flags & badflags, - pageflag_names, ARRAY_SIZE(pageflag_names)); + printflags = page->flags & badflags; + pr_alert("bad because of flags: %#lx:", printflags); + dump_flag_names(printflags, pageflag_names, + ARRAY_SIZE(pageflag_names)); } #ifdef CONFIG_MEMCG if (page->mem_cgroup) @@ -162,7 +167,9 @@ void dump_vma(const struct vm_area_struct *vma) (unsigned long)pgprot_val(vma->vm_page_prot), vma->anon_vma, vma->vm_ops, vma->vm_pgoff, vma->vm_file, vma->vm_private_data); - dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); + pr_emerg("flags: %#lx", vma->vm_flags); + dump_flag_names(vma->vm_flags, vmaflags_names, + ARRAY_SIZE(vmaflags_names)); } EXPORT_SYMBOL(dump_vma); @@ -233,8 +240,9 @@ void dump_mm(const struct mm_struct *mm) "" /* This is here to not have a comma! */ ); - dump_flags(mm->def_flags, vmaflags_names, - ARRAY_SIZE(vmaflags_names)); + pr_emerg("def_flags: %#lx(", mm->def_flags); + dump_flag_names(mm->def_flags, vmaflags_names, + ARRAY_SIZE(vmaflags_names)); } #endif /* CONFIG_DEBUG_VM */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/