aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/page-flags.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/page-flags.h')
-rw-r--r--include/linux/page-flags.h42
1 files changed, 33 insertions, 9 deletions
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 2b87acfc5f87..6b202b173955 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -51,6 +51,9 @@
51 * PG_buddy is set to indicate that the page is free and in the buddy system 51 * PG_buddy is set to indicate that the page is free and in the buddy system
52 * (see mm/page_alloc.c). 52 * (see mm/page_alloc.c).
53 * 53 *
54 * PG_hwpoison indicates that a page got corrupted in hardware and contains
55 * data with incorrect ECC bits that triggered a machine check. Accessing is
56 * not safe since it may cause another machine check. Don't touch!
54 */ 57 */
55 58
56/* 59/*
@@ -102,6 +105,9 @@ enum pageflags {
102#ifdef CONFIG_ARCH_USES_PG_UNCACHED 105#ifdef CONFIG_ARCH_USES_PG_UNCACHED
103 PG_uncached, /* Page has been mapped as uncached */ 106 PG_uncached, /* Page has been mapped as uncached */
104#endif 107#endif
108#ifdef CONFIG_MEMORY_FAILURE
109 PG_hwpoison, /* hardware poisoned page. Don't touch */
110#endif
105 __NR_PAGEFLAGS, 111 __NR_PAGEFLAGS,
106 112
107 /* Filesystems */ 113 /* Filesystems */
@@ -158,6 +164,9 @@ static inline int TestSetPage##uname(struct page *page) \
158static inline int TestClearPage##uname(struct page *page) \ 164static inline int TestClearPage##uname(struct page *page) \
159 { return test_and_clear_bit(PG_##lname, &page->flags); } 165 { return test_and_clear_bit(PG_##lname, &page->flags); }
160 166
167#define __TESTCLEARFLAG(uname, lname) \
168static inline int __TestClearPage##uname(struct page *page) \
169 { return __test_and_clear_bit(PG_##lname, &page->flags); }
161 170
162#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \ 171#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
163 SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname) 172 SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
@@ -184,6 +193,9 @@ static inline void __ClearPage##uname(struct page *page) { }
184#define TESTCLEARFLAG_FALSE(uname) \ 193#define TESTCLEARFLAG_FALSE(uname) \
185static inline int TestClearPage##uname(struct page *page) { return 0; } 194static inline int TestClearPage##uname(struct page *page) { return 0; }
186 195
196#define __TESTCLEARFLAG_FALSE(uname) \
197static inline int __TestClearPage##uname(struct page *page) { return 0; }
198
187struct page; /* forward declaration */ 199struct page; /* forward declaration */
188 200
189TESTPAGEFLAG(Locked, locked) TESTSETFLAG(Locked, locked) 201TESTPAGEFLAG(Locked, locked) TESTSETFLAG(Locked, locked)
@@ -250,11 +262,11 @@ PAGEFLAG(Unevictable, unevictable) __CLEARPAGEFLAG(Unevictable, unevictable)
250#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT 262#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
251#define MLOCK_PAGES 1 263#define MLOCK_PAGES 1
252PAGEFLAG(Mlocked, mlocked) __CLEARPAGEFLAG(Mlocked, mlocked) 264PAGEFLAG(Mlocked, mlocked) __CLEARPAGEFLAG(Mlocked, mlocked)
253 TESTSCFLAG(Mlocked, mlocked) 265 TESTSCFLAG(Mlocked, mlocked) __TESTCLEARFLAG(Mlocked, mlocked)
254#else 266#else
255#define MLOCK_PAGES 0 267#define MLOCK_PAGES 0
256PAGEFLAG_FALSE(Mlocked) 268PAGEFLAG_FALSE(Mlocked) SETPAGEFLAG_NOOP(Mlocked)
257 SETPAGEFLAG_NOOP(Mlocked) TESTCLEARFLAG_FALSE(Mlocked) 269 TESTCLEARFLAG_FALSE(Mlocked) __TESTCLEARFLAG_FALSE(Mlocked)
258#endif 270#endif
259 271
260#ifdef CONFIG_ARCH_USES_PG_UNCACHED 272#ifdef CONFIG_ARCH_USES_PG_UNCACHED
@@ -263,6 +275,15 @@ PAGEFLAG(Uncached, uncached)
263PAGEFLAG_FALSE(Uncached) 275PAGEFLAG_FALSE(Uncached)
264#endif 276#endif
265 277
278#ifdef CONFIG_MEMORY_FAILURE
279PAGEFLAG(HWPoison, hwpoison)
280TESTSETFLAG(HWPoison, hwpoison)
281#define __PG_HWPOISON (1UL << PG_hwpoison)
282#else
283PAGEFLAG_FALSE(HWPoison)
284#define __PG_HWPOISON 0
285#endif
286
266static inline int PageUptodate(struct page *page) 287static inline int PageUptodate(struct page *page)
267{ 288{
268 int ret = test_bit(PG_uptodate, &(page)->flags); 289 int ret = test_bit(PG_uptodate, &(page)->flags);
@@ -387,7 +408,7 @@ static inline void __ClearPageTail(struct page *page)
387 1 << PG_private | 1 << PG_private_2 | \ 408 1 << PG_private | 1 << PG_private_2 | \
388 1 << PG_buddy | 1 << PG_writeback | 1 << PG_reserved | \ 409 1 << PG_buddy | 1 << PG_writeback | 1 << PG_reserved | \
389 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ 410 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \
390 1 << PG_unevictable | __PG_MLOCKED) 411 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON)
391 412
392/* 413/*
393 * Flags checked when a page is prepped for return by the page allocator. 414 * Flags checked when a page is prepped for return by the page allocator.
@@ -396,8 +417,8 @@ static inline void __ClearPageTail(struct page *page)
396 */ 417 */
397#define PAGE_FLAGS_CHECK_AT_PREP ((1 << NR_PAGEFLAGS) - 1) 418#define PAGE_FLAGS_CHECK_AT_PREP ((1 << NR_PAGEFLAGS) - 1)
398 419
399#endif /* !__GENERATING_BOUNDS_H */ 420#define PAGE_FLAGS_PRIVATE \
400 421 (1 << PG_private | 1 << PG_private_2)
401/** 422/**
402 * page_has_private - Determine if page has private stuff 423 * page_has_private - Determine if page has private stuff
403 * @page: The page to be checked 424 * @page: The page to be checked
@@ -405,8 +426,11 @@ static inline void __ClearPageTail(struct page *page)
405 * Determine if a page has private stuff, indicating that release routines 426 * Determine if a page has private stuff, indicating that release routines
406 * should be invoked upon it. 427 * should be invoked upon it.
407 */ 428 */
408#define page_has_private(page) \ 429static inline int page_has_private(struct page *page)
409 ((page)->flags & ((1 << PG_private) | \ 430{
410 (1 << PG_private_2))) 431 return !!(page->flags & PAGE_FLAGS_PRIVATE);
432}
433
434#endif /* !__GENERATING_BOUNDS_H */
411 435
412#endif /* PAGE_FLAGS_H */ 436#endif /* PAGE_FLAGS_H */