blob: 46f1b939948c58df206e8c8740ba08bcd5f7f114 [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);
Vlastimil Babka4e462112016-03-15 14:56:21 -070016extern void __dump_page_owner(struct page *page);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080017
18static inline void reset_page_owner(struct page *page, unsigned int order)
19{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070020 if (static_branch_unlikely(&page_owner_inited))
21 __reset_page_owner(page, order);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080022}
23
24static inline void set_page_owner(struct page *page,
25 unsigned int order, gfp_t gfp_mask)
26{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070027 if (static_branch_unlikely(&page_owner_inited))
28 __set_page_owner(page, order, gfp_mask);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080029}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070030
31static inline gfp_t get_page_owner_gfp(struct page *page)
32{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070033 if (static_branch_unlikely(&page_owner_inited))
34 return __get_page_owner_gfp(page);
35 else
Joonsoo Kime2cfc912015-07-17 16:24:18 -070036 return 0;
Joonsoo Kime2cfc912015-07-17 16:24:18 -070037}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070038static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
39{
40 if (static_branch_unlikely(&page_owner_inited))
41 __copy_page_owner(oldpage, newpage);
42}
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070043static inline void set_page_owner_migrate_reason(struct page *page, int reason)
44{
45 if (static_branch_unlikely(&page_owner_inited))
46 __set_page_owner_migrate_reason(page, reason);
47}
Vlastimil Babka4e462112016-03-15 14:56:21 -070048static inline void dump_page_owner(struct page *page)
49{
50 if (static_branch_unlikely(&page_owner_inited))
51 __dump_page_owner(page);
52}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080053#else
54static inline void reset_page_owner(struct page *page, unsigned int order)
55{
56}
57static inline void set_page_owner(struct page *page,
58 unsigned int order, gfp_t gfp_mask)
59{
60}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070061static inline gfp_t get_page_owner_gfp(struct page *page)
62{
63 return 0;
64}
Vlastimil Babkad435edc2016-03-15 14:56:15 -070065static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
66{
67}
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070068static inline void set_page_owner_migrate_reason(struct page *page, int reason)
69{
70}
Vlastimil Babka4e462112016-03-15 14:56:21 -070071static inline void dump_page_owner(struct page *page)
72{
73}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080074#endif /* CONFIG_PAGE_OWNER */
75#endif /* __LINUX_PAGE_OWNER_H */