All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: Make PageType more efficient
@ 2020-03-10 18:56 Matthew Wilcox
  2020-03-10 20:17 ` Alexander Duyck
  2020-03-11  1:10 ` Andrew Morton
  0 siblings, 2 replies; 9+ messages in thread
From: Matthew Wilcox @ 2020-03-10 18:56 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, linux-mm; +Cc: Matthew Wilcox (Oracle)

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

PageType is a little hard for GCC to reason about, By checking
((~A) & flag) instead of (flag & (A | MASK) == MASK), GCC can do
better optimisations, saving 652 bytes in page_alloc.o (which is
a heavy user of PageBuddy).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/page-flags.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 1bf83c8fcaa7..8fc0876e2794 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -725,14 +725,14 @@ PAGEFLAG_FALSE(DoubleMap)
 #define PG_table	0x00000400
 #define PG_guard	0x00000800
 
-#define PageType(page, flag)						\
-	((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
-
 static inline int page_has_type(struct page *page)
 {
 	return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
 }
 
+#define PageType(page, flag)						\
+	(page_has_type(page) && (~page->page_type & flag))
+
 #define PAGE_TYPE_OPS(uname, lname)					\
 static __always_inline int Page##uname(struct page *page)		\
 {									\
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-11 17:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 18:56 [PATCH] mm: Make PageType more efficient Matthew Wilcox
2020-03-10 20:17 ` Alexander Duyck
2020-03-10 20:37   ` Matthew Wilcox
2020-03-10 21:50     ` Alexander Duyck
2020-03-11 13:13       ` Matthew Wilcox
2020-03-11 17:14         ` Ira Weiny
2020-03-11 17:22         ` Alexander Duyck
2020-03-11  1:10 ` Andrew Morton
2020-03-11 13:21   ` Matthew Wilcox

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.