Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 1 | #ifndef __LINUX_PAGE_OWNER_H |
| 2 | #define __LINUX_PAGE_OWNER_H |
| 3 | |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame^] | 4 | #include <linux/jump_label.h> |
| 5 | |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 6 | #ifdef CONFIG_PAGE_OWNER |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame^] | 7 | extern struct static_key_false page_owner_inited; |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 8 | extern struct page_ext_operations page_owner_ops; |
| 9 | |
| 10 | extern void __reset_page_owner(struct page *page, unsigned int order); |
| 11 | extern void __set_page_owner(struct page *page, |
| 12 | unsigned int order, gfp_t gfp_mask); |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 13 | extern gfp_t __get_page_owner_gfp(struct page *page); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 14 | |
| 15 | static inline void reset_page_owner(struct page *page, unsigned int order) |
| 16 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame^] | 17 | if (static_branch_unlikely(&page_owner_inited)) |
| 18 | __reset_page_owner(page, order); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static inline void set_page_owner(struct page *page, |
| 22 | unsigned int order, gfp_t gfp_mask) |
| 23 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame^] | 24 | if (static_branch_unlikely(&page_owner_inited)) |
| 25 | __set_page_owner(page, order, gfp_mask); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 26 | } |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 27 | |
| 28 | static inline gfp_t get_page_owner_gfp(struct page *page) |
| 29 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame^] | 30 | if (static_branch_unlikely(&page_owner_inited)) |
| 31 | return __get_page_owner_gfp(page); |
| 32 | else |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 33 | return 0; |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 34 | } |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 35 | #else |
| 36 | static inline void reset_page_owner(struct page *page, unsigned int order) |
| 37 | { |
| 38 | } |
| 39 | static inline void set_page_owner(struct page *page, |
| 40 | unsigned int order, gfp_t gfp_mask) |
| 41 | { |
| 42 | } |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 43 | static inline gfp_t get_page_owner_gfp(struct page *page) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 47 | |
| 48 | #endif /* CONFIG_PAGE_OWNER */ |
| 49 | #endif /* __LINUX_PAGE_OWNER_H */ |