blob: 8e2eb153c7b9284ecddd77e40b8566e0a798705d [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);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080014
15static inline void reset_page_owner(struct page *page, unsigned int order)
16{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070017 if (static_branch_unlikely(&page_owner_inited))
18 __reset_page_owner(page, order);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080019}
20
21static inline void set_page_owner(struct page *page,
22 unsigned int order, gfp_t gfp_mask)
23{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070024 if (static_branch_unlikely(&page_owner_inited))
25 __set_page_owner(page, order, gfp_mask);
Joonsoo Kim48c96a32014-12-12 16:56:01 -080026}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070027
28static inline gfp_t get_page_owner_gfp(struct page *page)
29{
Vlastimil Babka7dd80b82016-03-15 14:56:12 -070030 if (static_branch_unlikely(&page_owner_inited))
31 return __get_page_owner_gfp(page);
32 else
Joonsoo Kime2cfc912015-07-17 16:24:18 -070033 return 0;
Joonsoo Kime2cfc912015-07-17 16:24:18 -070034}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080035#else
36static inline void reset_page_owner(struct page *page, unsigned int order)
37{
38}
39static inline void set_page_owner(struct page *page,
40 unsigned int order, gfp_t gfp_mask)
41{
42}
Joonsoo Kime2cfc912015-07-17 16:24:18 -070043static inline gfp_t get_page_owner_gfp(struct page *page)
44{
45 return 0;
46}
Joonsoo Kim48c96a32014-12-12 16:56:01 -080047
48#endif /* CONFIG_PAGE_OWNER */
49#endif /* __LINUX_PAGE_OWNER_H */