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); |
Vlastimil Babka | d435edc | 2016-03-15 14:56:15 -0700 | [diff] [blame] | 14 | extern void __copy_page_owner(struct page *oldpage, struct page *newpage); |
Vlastimil Babka | 7cd12b4 | 2016-03-15 14:56:18 -0700 | [diff] [blame^] | 15 | extern void __set_page_owner_migrate_reason(struct page *page, int reason); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 16 | |
| 17 | static inline void reset_page_owner(struct page *page, unsigned int order) |
| 18 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame] | 19 | if (static_branch_unlikely(&page_owner_inited)) |
| 20 | __reset_page_owner(page, order); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | static inline void set_page_owner(struct page *page, |
| 24 | unsigned int order, gfp_t gfp_mask) |
| 25 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame] | 26 | if (static_branch_unlikely(&page_owner_inited)) |
| 27 | __set_page_owner(page, order, gfp_mask); |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 28 | } |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 29 | |
| 30 | static inline gfp_t get_page_owner_gfp(struct page *page) |
| 31 | { |
Vlastimil Babka | 7dd80b8 | 2016-03-15 14:56:12 -0700 | [diff] [blame] | 32 | if (static_branch_unlikely(&page_owner_inited)) |
| 33 | return __get_page_owner_gfp(page); |
| 34 | else |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 35 | return 0; |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 36 | } |
Vlastimil Babka | d435edc | 2016-03-15 14:56:15 -0700 | [diff] [blame] | 37 | static inline void copy_page_owner(struct page *oldpage, struct page *newpage) |
| 38 | { |
| 39 | if (static_branch_unlikely(&page_owner_inited)) |
| 40 | __copy_page_owner(oldpage, newpage); |
| 41 | } |
Vlastimil Babka | 7cd12b4 | 2016-03-15 14:56:18 -0700 | [diff] [blame^] | 42 | static inline void set_page_owner_migrate_reason(struct page *page, int reason) |
| 43 | { |
| 44 | if (static_branch_unlikely(&page_owner_inited)) |
| 45 | __set_page_owner_migrate_reason(page, reason); |
| 46 | } |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 47 | #else |
| 48 | static inline void reset_page_owner(struct page *page, unsigned int order) |
| 49 | { |
| 50 | } |
| 51 | static inline void set_page_owner(struct page *page, |
| 52 | unsigned int order, gfp_t gfp_mask) |
| 53 | { |
| 54 | } |
Joonsoo Kim | e2cfc91 | 2015-07-17 16:24:18 -0700 | [diff] [blame] | 55 | static inline gfp_t get_page_owner_gfp(struct page *page) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
Vlastimil Babka | d435edc | 2016-03-15 14:56:15 -0700 | [diff] [blame] | 59 | static inline void copy_page_owner(struct page *oldpage, struct page *newpage) |
| 60 | { |
| 61 | } |
Vlastimil Babka | 7cd12b4 | 2016-03-15 14:56:18 -0700 | [diff] [blame^] | 62 | static inline void set_page_owner_migrate_reason(struct page *page, int reason) |
| 63 | { |
| 64 | } |
Joonsoo Kim | 48c96a3 | 2014-12-12 16:56:01 -0800 | [diff] [blame] | 65 | #endif /* CONFIG_PAGE_OWNER */ |
| 66 | #endif /* __LINUX_PAGE_OWNER_H */ |