Joonsoo Kim | eefa864 | 2014-12-12 16:55:46 -0800 | [diff] [blame] | 1 | #ifndef __LINUX_PAGE_EXT_H |
| 2 | #define __LINUX_PAGE_EXT_H |
| 3 | |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 4 | #include <linux/types.h> |
| 5 | #include <linux/stacktrace.h> |
| 6 | |
Joonsoo Kim | eefa864 | 2014-12-12 16:55:46 -0800 | [diff] [blame] | 7 | struct pglist_data; |
| 8 | struct page_ext_operations { |
| 9 | bool (*need)(void); |
| 10 | void (*init)(void); |
| 11 | }; |
| 12 | |
| 13 | #ifdef CONFIG_PAGE_EXTENSION |
| 14 | |
| 15 | /* |
Joonsoo Kim | e30825f | 2014-12-12 16:55:49 -0800 | [diff] [blame] | 16 | * page_ext->flags bits: |
| 17 | * |
| 18 | * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to |
| 19 | * implement generic debug pagealloc feature. The pages are filled with |
| 20 | * poison patterns and set this flag after free_pages(). The poisoned |
| 21 | * pages are verified whether the patterns are not corrupted and clear |
| 22 | * the flag before alloc_pages(). |
| 23 | */ |
| 24 | |
| 25 | enum page_ext_flags { |
| 26 | PAGE_EXT_DEBUG_POISON, /* Page is poisoned */ |
| 27 | PAGE_EXT_DEBUG_GUARD, |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 28 | PAGE_EXT_OWNER, |
Vladimir Davydov | 33c3fc7 | 2015-09-09 15:35:45 -0700 | [diff] [blame] | 29 | #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT) |
| 30 | PAGE_EXT_YOUNG, |
| 31 | PAGE_EXT_IDLE, |
| 32 | #endif |
Joonsoo Kim | e30825f | 2014-12-12 16:55:49 -0800 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | /* |
Joonsoo Kim | eefa864 | 2014-12-12 16:55:46 -0800 | [diff] [blame] | 36 | * Page Extension can be considered as an extended mem_map. |
| 37 | * A page_ext page is associated with every page descriptor. The |
| 38 | * page_ext helps us add more information about the page. |
| 39 | * All page_ext are allocated at boot or memory hotplug event, |
| 40 | * then the page_ext for pfn always exists. |
| 41 | */ |
| 42 | struct page_ext { |
| 43 | unsigned long flags; |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 44 | #ifdef CONFIG_PAGE_OWNER |
| 45 | unsigned int order; |
| 46 | gfp_t gfp_mask; |
Sergei Rogachev | 94f759d6 | 2015-02-11 15:28:34 -0800 | [diff] [blame] | 47 | unsigned int nr_entries; |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 48 | unsigned long trace_entries[8]; |
| 49 | #endif |
Joonsoo Kim | eefa864 | 2014-12-12 16:55:46 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | extern void pgdat_page_ext_init(struct pglist_data *pgdat); |
| 53 | |
| 54 | #ifdef CONFIG_SPARSEMEM |
| 55 | static inline void page_ext_init_flatmem(void) |
| 56 | { |
| 57 | } |
| 58 | extern void page_ext_init(void); |
| 59 | #else |
| 60 | extern void page_ext_init_flatmem(void); |
| 61 | static inline void page_ext_init(void) |
| 62 | { |
| 63 | } |
| 64 | #endif |
| 65 | |
| 66 | struct page_ext *lookup_page_ext(struct page *page); |
| 67 | |
| 68 | #else /* !CONFIG_PAGE_EXTENSION */ |
| 69 | struct page_ext; |
| 70 | |
| 71 | static inline void pgdat_page_ext_init(struct pglist_data *pgdat) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | static inline struct page_ext *lookup_page_ext(struct page *page) |
| 76 | { |
| 77 | return NULL; |
| 78 | } |
| 79 | |
| 80 | static inline void page_ext_init(void) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | static inline void page_ext_init_flatmem(void) |
| 85 | { |
| 86 | } |
| 87 | #endif /* CONFIG_PAGE_EXTENSION */ |
| 88 | #endif /* __LINUX_PAGE_EXT_H */ |