linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Vlastimil Babka <vbabka@suse.cz>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Minchan Kim <minchan@kernel.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@suse.cz>
Subject: [PATCH v3 14/14] mm, debug: move bad flags printing to bad_page()
Date: Fri, 18 Dec 2015 10:03:26 +0100	[thread overview]
Message-ID: <1450429406-7081-15-git-send-email-vbabka@suse.cz> (raw)
In-Reply-To: <1450429406-7081-1-git-send-email-vbabka@suse.cz>

Since bad_page() is the only user of the badflags parameter of
dump_page_badflags(), we can move the code to bad_page() and simplify a bit.

The dump_page_badflags() function is renamed to __dump_page() and can still be
called separately from dump_page() for temporary debug prints where page_owner
info is not desired.

The only user-visible change is that page->mem_cgroup is printed before the bad
flags.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
---
 include/linux/mmdebug.h |  3 +--
 mm/debug.c              | 10 +++-------
 mm/page_alloc.c         | 10 +++++++---
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index 2c8286cf162e..9b0dc2161f7a 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -14,8 +14,7 @@ extern const struct trace_print_flags vmaflag_names[];
 extern const struct trace_print_flags gfpflag_names[];
 
 extern void dump_page(struct page *page, const char *reason);
-extern void dump_page_badflags(struct page *page, const char *reason,
-			       unsigned long badflags);
+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 7260644d8cc1..4c03b6d07c82 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -40,8 +40,7 @@ const struct trace_print_flags vmaflag_names[] = {
 	{0, NULL}
 };
 
-void dump_page_badflags(struct page *page, const char *reason,
-		unsigned long badflags)
+void __dump_page(struct page *page, const char *reason)
 {
 	pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
 		  page, atomic_read(&page->_count), page_mapcount(page),
@@ -50,15 +49,12 @@ 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 + 1);
+
 	pr_emerg("flags: %#lx(%pgp)\n", page->flags, &page->flags);
 
 	if (reason)
 		pr_alert("page dumped because: %s\n", reason);
 
-	badflags &= page->flags;
-	if (badflags)
-		pr_alert("bad because of flags: %#lx(%pgp)\n", badflags,
-								&badflags);
 #ifdef CONFIG_MEMCG
 	if (page->mem_cgroup)
 		pr_alert("page->mem_cgroup:%p\n", page->mem_cgroup);
@@ -67,7 +63,7 @@ void dump_page_badflags(struct page *page, const char *reason,
 
 void dump_page(struct page *page, const char *reason)
 {
-	dump_page_badflags(page, reason, 0);
+	__dump_page(page, reason);
 	dump_page_owner(page);
 }
 EXPORT_SYMBOL(dump_page);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7718ee40726a..bac8842d4fcf 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -428,7 +428,7 @@ static void bad_page(struct page *page, const char *reason,
 			goto out;
 		}
 		if (nr_unshown) {
-			printk(KERN_ALERT
+			pr_alert(
 			      "BUG: Bad page state: %lu messages suppressed\n",
 				nr_unshown);
 			nr_unshown = 0;
@@ -438,9 +438,13 @@ static void bad_page(struct page *page, const char *reason,
 	if (nr_shown++ == 0)
 		resume = jiffies + 60 * HZ;
 
-	printk(KERN_ALERT "BUG: Bad page state in process %s  pfn:%05lx\n",
+	pr_alert("BUG: Bad page state in process %s  pfn:%05lx\n",
 		current->comm, page_to_pfn(page));
-	dump_page_badflags(page, reason, bad_flags);
+	__dump_page(page, reason);
+	bad_flags &= page->flags;
+	if (bad_flags)
+		pr_alert("bad because of flags: %#lx(%pgp)\n",
+						bad_flags, &bad_flags);
 	dump_page_owner(page);
 
 	print_modules();
-- 
2.6.3


  parent reply	other threads:[~2015-12-18  9:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18  9:03 [PATCH v3 00/14] mm flags in printk, page_owner improvements for debugging Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 01/14] tracepoints: move trace_print_flags definitions to tracepoint-defs.h Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 02/14] mm, tracing: make show_gfp_flags() up to date Vlastimil Babka
2016-01-07  9:29   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 03/14] tools, perf: make gfp_compact_table " Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 04/14] mm, tracing: unify mm flags handling in tracepoints and printk Vlastimil Babka
2016-01-07  9:46   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 05/14] mm, printk: introduce new format string for flags Vlastimil Babka
2016-01-07  9:53   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 06/14] mm, debug: replace dump_flags() with the new printk formats Vlastimil Babka
2016-01-07  9:57   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 07/14] mm, page_alloc: print symbolic gfp_flags on allocation failure Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 08/14] mm, oom: print symbolic gfp_flags in oom warning Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 09/14] mm, page_owner: print migratetype of page and pageblock, symbolic flags Vlastimil Babka
2016-01-07 10:06   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 10/14] mm, page_owner: convert page_owner_inited to static key Vlastimil Babka
2016-01-07 10:21   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 11/14] mm, page_owner: copy page owner info during migration Vlastimil Babka
2016-01-07 10:44   ` Michal Hocko
2015-12-18  9:03 ` [PATCH v3 12/14] mm, page_owner: track and print last migrate reason Vlastimil Babka
2016-01-07 10:54   ` Michal Hocko
2016-01-07 13:17     ` Vlastimil Babka
2015-12-18  9:03 ` [PATCH v3 13/14] mm, page_owner: dump page owner info from dump_page() Vlastimil Babka
2015-12-18  9:03 ` Vlastimil Babka [this message]
2016-01-07 13:10   ` [PATCH v3 14/14] mm, debug: move bad flags printing to bad_page() Michal Hocko

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=1450429406-7081-15-git-send-email-vbabka@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.cz \
    --cc=minchan@kernel.org \
    --cc=sasha.levin@oracle.com \
    /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).