]> git.karo-electronics.de Git - linux-beck.git/blob - include/linux/page_cgroup.h
page-cgroup: trivial cleanup
[linux-beck.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         __NR_PCG_FLAGS,
10 };
11
12 #ifndef __GENERATING_BOUNDS_H
13 #include <generated/bounds.h>
14
15 struct pglist_data;
16
17 #ifdef CONFIG_MEMCG
18 struct mem_cgroup;
19
20 /*
21  * Page Cgroup can be considered as an extended mem_map.
22  * A page_cgroup page is associated with every page descriptor. The
23  * page_cgroup helps us identify information about the cgroup
24  * All page cgroups are allocated at boot or memory hotplug event,
25  * then the page cgroup for pfn always exists.
26  */
27 struct page_cgroup {
28         unsigned long flags;
29         struct mem_cgroup *mem_cgroup;
30 };
31
32 extern void pgdat_page_cgroup_init(struct pglist_data *pgdat);
33
34 #ifdef CONFIG_SPARSEMEM
35 static inline void page_cgroup_init_flatmem(void)
36 {
37 }
38 extern void page_cgroup_init(void);
39 #else
40 extern void page_cgroup_init_flatmem(void);
41 static inline void page_cgroup_init(void)
42 {
43 }
44 #endif
45
46 struct page_cgroup *lookup_page_cgroup(struct page *page);
47 struct page *lookup_cgroup_page(struct page_cgroup *pc);
48
49 static inline int PageCgroupUsed(struct page_cgroup *pc)
50 {
51         return !!(pc->flags & PCG_USED);
52 }
53 #else /* !CONFIG_MEMCG */
54 struct page_cgroup;
55
56 static inline void pgdat_page_cgroup_init(struct pglist_data *pgdat)
57 {
58 }
59
60 static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
61 {
62         return NULL;
63 }
64
65 static inline void page_cgroup_init(void)
66 {
67 }
68
69 static inline void page_cgroup_init_flatmem(void)
70 {
71 }
72 #endif /* CONFIG_MEMCG */
73
74 #include <linux/swap.h>
75
76 #ifdef CONFIG_MEMCG_SWAP
77 extern unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
78                                         unsigned short old, unsigned short new);
79 extern unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id);
80 extern unsigned short lookup_swap_cgroup_id(swp_entry_t ent);
81 extern int swap_cgroup_swapon(int type, unsigned long max_pages);
82 extern void swap_cgroup_swapoff(int type);
83 #else
84
85 static inline
86 unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
87 {
88         return 0;
89 }
90
91 static inline
92 unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
93 {
94         return 0;
95 }
96
97 static inline int
98 swap_cgroup_swapon(int type, unsigned long max_pages)
99 {
100         return 0;
101 }
102
103 static inline void swap_cgroup_swapoff(int type)
104 {
105         return;
106 }
107
108 #endif /* CONFIG_MEMCG_SWAP */
109
110 #endif /* !__GENERATING_BOUNDS_H */
111
112 #endif /* __LINUX_PAGE_CGROUP_H */