All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Petr Mladek <pmladek@suse.com>
Cc: linux-mm@kvack.org
Subject: [PATCH] Do not print page type when the page has no type
Date: Sat, 27 May 2023 17:48:32 +0100	[thread overview]
Message-ID: <ZHI0YKzZADjr1nyq@casper.infradead.org> (raw)

It is confusing and unnecessary to print the page type when the
page has no type.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

---

I did not run the test-suite.  I'm in the middle of debugging something
else and this is an unwelcome distraction.  If this doesn't work quite
right, please fix it.

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 1c68d67b832f..3ac7b7e697a3 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -903,14 +903,9 @@ static inline bool is_page_hwpoison(struct page *page)
 #define PageType(page, flag)						\
 	((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
 
-static inline int page_type_has_type(unsigned int page_type)
-{
-	return (int)page_type < PAGE_MAPCOUNT_RESERVE;
-}
-
 static inline int page_has_type(struct page *page)
 {
-	return page_type_has_type(page->page_type);
+	return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
 }
 
 #define PAGE_TYPE_OPS(uname, lname)					\
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 7677ebccf3c3..442e4c41bccb 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -648,9 +648,7 @@ static void __init page_type_test(unsigned int page_type, const char *name,
 	unsigned long size;
 
 	size = scnprintf(cmp_buf, BUF_SIZE, "%#x(", page_type);
-	if (page_type_has_type(page_type))
-		size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name);
-
+	size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name);
 	snprintf(cmp_buf + size, BUF_SIZE - size, ")");
 	test(cmp_buf, "%pGt", &page_type);
 }
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 40f560959b16..0a0e5c4cffc9 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2061,8 +2061,7 @@ char *format_page_type(char *buf, char *end, unsigned int page_type)
 		*buf = '(';
 	buf++;
 
-	if (page_type_has_type(page_type))
-		buf = format_flags(buf, end, ~page_type, pagetype_names);
+	buf = format_flags(buf, end, ~page_type, pagetype_names);
 
 	if (buf < end)
 		*buf = ')';
diff --git a/mm/debug.c b/mm/debug.c
index c7b228097bd9..6eb0ecb9b368 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -120,7 +120,8 @@ static void __dump_page(struct page *page)
 
 	pr_warn("%sflags: %pGp%s\n", type, &head->flags,
 		page_cma ? " CMA" : "");
-	pr_warn("page_type: %pGt\n", &head->page_type);
+	if (page_has_type(head))
+		pr_warn("page_type: %pGt\n", &head->page_type);
 
 	print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32,
 			sizeof(unsigned long), page,


             reply	other threads:[~2023-05-27 16:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27 16:48 Matthew Wilcox [this message]
2023-05-28  8:01 ` [PATCH] Do not print page type when the page has no type Hyeonggon Yoo
2023-05-29 15:27   ` Petr Mladek
2023-05-29 15:42     ` Matthew Wilcox
2023-05-30  7:35       ` Petr Mladek

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=ZHI0YKzZADjr1nyq@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=pmladek@suse.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 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.