blob: 555893bf13d703335c95133c6c9dcfb2b49bea0b [file] [log] [blame]
Joonsoo Kim48c96a32014-12-12 16:56:01 -08001#ifndef __LINUX_PAGE_OWNER_H
2#define __LINUX_PAGE_OWNER_H
3
Vlastimil Babka7dd80b82016-03-15 14:56:12 -07004#include <linux/jump_label.h>
5
Joonsoo Kim48c96a32014-12-12 16:56:01 -08006#ifdef CONFIG_PAGE_OWNER
Vlastimil Babka7dd80b82016-03-15 14:56:12 -07007extern struct static_key_false page_owner_inited;
Joonsoo Kim48c96a32014-12-12 16:56:01 -08008extern struct page_ext_operations page_owner_ops;
9
10extern void __reset_page_owner(struct page *page, unsigned int order);
11extern void __set_page_owner(struct page *page,
12 unsigned int order, gfp_t gfp_mask);
Joonsoo Kime2cfc912015-07-17 16:24:18 -070013extern gfp_t __get_page_owner_gfp(struct page *page);
Vlastimil Babkad435edc2016-03-15 14:56:15 -070014extern void __copy_page_owner(struct page *oldpage, struct page *newpage);
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070015extern void __set_page_owner_migrate_reason(struct page *page, int reason);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080016
17static inline void reset_page_owner(struct page *page, unsigned int order)
18{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070019 if (static_branch_unlikely(&page_owner_inited))
20 __reset_page_owner(page, order);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080021}
22
23static inline void set_page_owner(struct page *page,
24 unsigned int order, gfp_t gfp_mask)
25{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070026 if (static_branch_unlikely(&page_owner_inited))
27 __set_page_owner(page, order, gfp_mask);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080028}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070029
30static inline gfp_t get_page_owner_gfp(struct page *page)
31{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070032 if (static_branch_unlikely(&page_owner_inited))
33 return __get_page_owner_gfp(page);
34 else
Joonsoo Kime2cfc912015-07-17 16:24:18 -070035 return 0;
Joonsoo Kime2cfc912015-07-17 16:24:18 -070036}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070037static 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 Babka7cd12b42016-03-15 14:56:18 -070042static 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 Kim48c96a32014-12-12 16:56:01 -080047#else
48static inline void reset_page_owner(struct page *page, unsigned int order)
49{
50}
51static inline void set_page_owner(struct page *page,
52 unsigned int order, gfp_t gfp_mask)
53{
54}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070055static inline gfp_t get_page_owner_gfp(struct page *page)
56{
57 return 0;
58}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070059static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
60{
61}
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070062static inline void set_page_owner_migrate_reason(struct page *page, int reason)
63{
64}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080065#endif /* CONFIG_PAGE_OWNER */
66#endif /* __LINUX_PAGE_OWNER_H */