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