blob: 6440daab4ef879f96325e526ecdf221c1315fa3a [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);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080015
16static inline void reset_page_owner(struct page *page, unsigned int order)
17{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070018 if (static_branch_unlikely(&page_owner_inited))
19 __reset_page_owner(page, order);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080020}
21
22static inline void set_page_owner(struct page *page,
23 unsigned int order, gfp_t gfp_mask)
24{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070025 if (static_branch_unlikely(&page_owner_inited))
26 __set_page_owner(page, order, gfp_mask);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080027}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070028
29static inline gfp_t get_page_owner_gfp(struct page *page)
30{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070031 if (static_branch_unlikely(&page_owner_inited))
32 return __get_page_owner_gfp(page);
33 else
Joonsoo Kime2cfc912015-07-17 16:24:18 -070034 return 0;
Joonsoo Kime2cfc912015-07-17 16:24:18 -070035}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070036static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
37{
38 if (static_branch_unlikely(&page_owner_inited))
39 __copy_page_owner(oldpage, newpage);
40}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080041#else
42static inline void reset_page_owner(struct page *page, unsigned int order)
43{
44}
45static inline void set_page_owner(struct page *page,
46 unsigned int order, gfp_t gfp_mask)
47{
48}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070049static inline gfp_t get_page_owner_gfp(struct page *page)
50{
51 return 0;
52}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070053static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
54{
55}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080056#endif /* CONFIG_PAGE_OWNER */
57#endif /* __LINUX_PAGE_OWNER_H */