pinctrl: at91: enhance (debugfs) at91_gpio_dbg_show
[cascardo/linux.git] / include / linux / page_cgroup.h
1 #ifndef __LINUX_PAGE_CGROUP_H
2 #define __LINUX_PAGE_CGROUP_H
3
4 enum {
5         /* flags for mem_cgroup */
6         PCG_USED = 0x01,        /* This page is charged to a memcg */
7         PCG_MEM = 0x02,         /* This page holds a memory charge */
8         PCG_MEMSW = 0x04,       /* This page holds a memory+swap charge */
9 };
10
11 struct pglist_data;
12
13 #ifdef CONFIG_MEMCG
14 struct mem_cgroup;
15
16 /*
17  * Page Cgroup can be considered as an extended mem_map.
18  * A page_cgroup page is associated with every page descriptor. The
19  * page_cgroup helps us identify information about the cgroup
20  * All page cgroups are allocated at boot or memory hotplug event,
21  * then the page cgroup for pfn always exists.
22  */
23 struct page_cgroup {
24         unsigned long flags;
25         struct mem_cgroup *mem_cgroup;
26 };
27
28 extern void pgdat_page_cgroup_init(struct pglist_data *pgdat);
29
30 #ifdef CONFIG_SPARSEMEM
31 static inline void page_cgroup_init_flatmem(void)
32 {
33 }
34 extern void page_cgroup_init(void);
35 #else
36 extern void page_cgroup_init_flatmem(void);
37 static inline void page_cgroup_init(void)
38 {
39 }
40 #endif
41
42 struct page_cgroup *lookup_page_cgroup(struct page *page);
43
44 static inline int PageCgroupUsed(struct page_cgroup *pc)
45 {
46         return !!(pc->flags & PCG_USED);
47 }
48 #else /* !CONFIG_MEMCG */
49 struct page_cgroup;
50
51 static inline void pgdat_page_cgroup_init(struct pglist_data *pgdat)
52 {
53 }
54
55 static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
56 {
57         return NULL;
58 }
59
60 static inline void page_cgroup_init(void)
61 {
62 }
63
64 static inline void page_cgroup_init_flatmem(void)
65 {
66 }
67 #endif /* CONFIG_MEMCG */
68
69 #include <linux/swap.h>
70
71 #ifdef CONFIG_MEMCG_SWAP
72 extern unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
73                                         unsigned short old, unsigned short new);
74 extern unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id);
75 extern unsigned short lookup_swap_cgroup_id(swp_entry_t ent);
76 extern int swap_cgroup_swapon(int type, unsigned long max_pages);
77 extern void swap_cgroup_swapoff(int type);
78 #else
79
80 static inline
81 unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
82 {
83         return 0;
84 }
85
86 static inline
87 unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
88 {
89         return 0;
90 }
91
92 static inline int
93 swap_cgroup_swapon(int type, unsigned long max_pages)
94 {
95         return 0;
96 }
97
98 static inline void swap_cgroup_swapoff(int type)
99 {
100         return;
101 }
102
103 #endif /* CONFIG_MEMCG_SWAP */
104
105 #endif /* __LINUX_PAGE_CGROUP_H */