diff mbox series

[2/5] mm: Rename PF_POISONED_PAGE to page_poison_check

Message ID 20200408150148.25290-3-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Improve page poisoning implementation | expand

Commit Message

Matthew Wilcox April 8, 2020, 3:01 p.m. UTC
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

The PF_POISONED_PAGE name is misleading because it's not a page flag
policy.  Switch from VM_BUG_ON_PGFLAGS to VM_BUG_ON_PAGE.  Move the
implementation further up in the file for the benefit of future patches.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/mm.h         |  2 +-
 include/linux/page-flags.h | 34 +++++++++++++++++-----------------
 2 files changed, 18 insertions(+), 18 deletions(-)

Comments

Pasha Tatashin April 8, 2020, 3:21 p.m. UTC | #1
On Wed, Apr 8, 2020 at 11:01 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> The PF_POISONED_PAGE name is misleading because it's not a page flag
> policy.  Switch from VM_BUG_ON_PGFLAGS to VM_BUG_ON_PAGE.  Move the
> implementation further up in the file for the benefit of future patches.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Kirill A . Shutemov April 9, 2020, 2:14 p.m. UTC | #2
On Wed, Apr 08, 2020 at 08:01:45AM -0700, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> The PF_POISONED_PAGE name is misleading because it's not a page flag
> policy.  Switch from VM_BUG_ON_PGFLAGS to VM_BUG_ON_PAGE.  Move the
> implementation further up in the file for the benefit of future patches.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
diff mbox series

Patch

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 61aa63449e7e..933450bdcfd4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1248,7 +1248,7 @@  static inline int page_to_nid(const struct page *page)
 {
 	struct page *p = (struct page *)page;
 
-	return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK;
+	return (page_poison_check(p)->flags >> NODES_PGSHIFT) & NODES_MASK;
 }
 #endif
 
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index f1ab1f2e6aba..331aef35f3e0 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -175,6 +175,18 @@  enum pageflags {
 
 #ifndef __GENERATING_BOUNDS_H
 
+#define	PAGE_POISON_PATTERN	-1l
+static inline int PagePoisoned(const struct page *page)
+{
+	return page->flags == PAGE_POISON_PATTERN;
+}
+
+#define page_poison_check(page) ({					\
+	__typeof__(page) ___page = page;				\
+	VM_BUG_ON_PAGE(PagePoisoned(___page), ___page);			\
+	___page;							\
+})
+
 #define compound_head(page) ({						\
 	__typeof__(page) _page = page;					\
 	unsigned long head = READ_ONCE(_page->compound_head);		\
@@ -193,12 +205,6 @@  static __always_inline int PageCompound(const struct page *page)
 	return test_bit(PG_head, &page->flags) || PageTail(page);
 }
 
-#define	PAGE_POISON_PATTERN	-1l
-static inline int PagePoisoned(const struct page *page)
-{
-	return page->flags == PAGE_POISON_PATTERN;
-}
-
 #ifdef CONFIG_DEBUG_VM
 void page_init_poison(struct page *page, size_t size);
 #else
@@ -210,9 +216,6 @@  static inline void page_init_poison(struct page *page, size_t size)
 /*
  * Page flags policies wrt compound pages
  *
- * PF_POISONED_CHECK
- *     check if this struct page poisoned/uninitialized
- *
  * PF_ANY:
  *     the page flag is relevant for small, head and tail pages.
  *
@@ -230,20 +233,17 @@  static inline void page_init_poison(struct page *page, size_t size)
  * PF_NO_COMPOUND:
  *     the page flag is not relevant for compound pages.
  */
-#define PF_POISONED_CHECK(page) ({					\
-		VM_BUG_ON_PGFLAGS(PagePoisoned(page), page);		\
-		page; })
-#define PF_ANY(page, enforce)	PF_POISONED_CHECK(page)
-#define PF_HEAD(page, enforce)	PF_POISONED_CHECK(compound_head(page))
+#define PF_ANY(page, enforce)	page_poison_check(page)
+#define PF_HEAD(page, enforce)	page_poison_check(compound_head(page))
 #define PF_ONLY_HEAD(page, enforce) ({					\
 		VM_BUG_ON_PGFLAGS(PageTail(page), page);		\
-		PF_POISONED_CHECK(page); })
+		page_poison_check(page); })
 #define PF_NO_TAIL(page, enforce) ({					\
 		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
-		PF_POISONED_CHECK(compound_head(page)); })
+		page_poison_check(compound_head(page)); })
 #define PF_NO_COMPOUND(page, enforce) ({				\
 		VM_BUG_ON_PGFLAGS(enforce && PageCompound(page), page);	\
-		PF_POISONED_CHECK(page); })
+		page_poison_check(page); })
 
 /*
  * Macros to create function definitions for page flags