1 #ifndef __LINUX_PAGE_CGROUP_H
2 #define __LINUX_PAGE_CGROUP_H
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 */
12 #ifndef __GENERATING_BOUNDS_H
13 #include <generated/bounds.h>
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.
29 struct mem_cgroup *mem_cgroup;
32 extern void pgdat_page_cgroup_init(struct pglist_data *pgdat);
34 #ifdef CONFIG_SPARSEMEM
35 static inline void page_cgroup_init_flatmem(void)
38 extern void page_cgroup_init(void);
40 extern void page_cgroup_init_flatmem(void);
41 static inline void page_cgroup_init(void)
46 struct page_cgroup *lookup_page_cgroup(struct page *page);
47 struct page *lookup_cgroup_page(struct page_cgroup *pc);
49 static inline int PageCgroupUsed(struct page_cgroup *pc)
51 return !!(pc->flags & PCG_USED);
53 #else /* !CONFIG_MEMCG */
56 static inline void pgdat_page_cgroup_init(struct pglist_data *pgdat)
60 static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
65 static inline void page_cgroup_init(void)
69 static inline void page_cgroup_init_flatmem(void)
72 #endif /* CONFIG_MEMCG */
74 #include <linux/swap.h>
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);
86 unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
92 unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
98 swap_cgroup_swapon(int type, unsigned long max_pages)
103 static inline void swap_cgroup_swapoff(int type)
108 #endif /* CONFIG_MEMCG_SWAP */
110 #endif /* !__GENERATING_BOUNDS_H */
112 #endif /* __LINUX_PAGE_CGROUP_H */