Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[deliverable/linux.git] / include / linux / page_cgroup.h
CommitLineData
52d4b9ac
KH
1#ifndef __LINUX_PAGE_CGROUP_H
2#define __LINUX_PAGE_CGROUP_H
3
6b3ae58e
JW
4enum {
5 /* flags for mem_cgroup */
0a31bc97
JW
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 */
6b3ae58e
JW
9};
10
434584fe
VD
11struct pglist_data;
12
c255a458 13#ifdef CONFIG_MEMCG
434584fe 14struct mem_cgroup;
6b3ae58e 15
52d4b9ac
KH
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 */
23struct page_cgroup {
24 unsigned long flags;
25 struct mem_cgroup *mem_cgroup;
52d4b9ac
KH
26};
27
434584fe 28extern void pgdat_page_cgroup_init(struct pglist_data *pgdat);
ca371c0d
KH
29
30#ifdef CONFIG_SPARSEMEM
434584fe 31static inline void page_cgroup_init_flatmem(void)
ca371c0d
KH
32{
33}
434584fe 34extern void page_cgroup_init(void);
ca371c0d 35#else
434584fe
VD
36extern void page_cgroup_init_flatmem(void);
37static inline void page_cgroup_init(void)
ca371c0d
KH
38{
39}
40#endif
41
52d4b9ac 42struct page_cgroup *lookup_page_cgroup(struct page *page);
52d4b9ac 43
0a31bc97 44static inline int PageCgroupUsed(struct page_cgroup *pc)
52d4b9ac 45{
0a31bc97 46 return !!(pc->flags & PCG_USED);
52d4b9ac 47}
434584fe 48#else /* !CONFIG_MEMCG */
52d4b9ac
KH
49struct page_cgroup;
50
434584fe 51static inline void pgdat_page_cgroup_init(struct pglist_data *pgdat)
52d4b9ac
KH
52{
53}
54
55static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
56{
57 return NULL;
58}
94b6da5a
KH
59
60static inline void page_cgroup_init(void)
61{
62}
63
434584fe 64static inline void page_cgroup_init_flatmem(void)
ca371c0d
KH
65{
66}
c255a458 67#endif /* CONFIG_MEMCG */
27a7faa0 68
27a7faa0 69#include <linux/swap.h>
97572751 70
c255a458 71#ifdef CONFIG_MEMCG_SWAP
02491447
DN
72extern unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
73 unsigned short old, unsigned short new);
a3b2d692 74extern unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id);
9fb4b7cc 75extern unsigned short lookup_swap_cgroup_id(swp_entry_t ent);
27a7faa0
KH
76extern int swap_cgroup_swapon(int type, unsigned long max_pages);
77extern void swap_cgroup_swapoff(int type);
78#else
27a7faa0
KH
79
80static inline
a3b2d692 81unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
27a7faa0 82{
a3b2d692 83 return 0;
27a7faa0
KH
84}
85
86static inline
9fb4b7cc 87unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
27a7faa0 88{
a3b2d692 89 return 0;
27a7faa0
KH
90}
91
92static inline int
93swap_cgroup_swapon(int type, unsigned long max_pages)
94{
95 return 0;
96}
97
98static inline void swap_cgroup_swapoff(int type)
99{
100 return;
101}
102
c255a458 103#endif /* CONFIG_MEMCG_SWAP */
6b3ae58e 104
6b3ae58e 105#endif /* __LINUX_PAGE_CGROUP_H */
This page took 0.690512 seconds and 5 git commands to generate.