diff options
Diffstat (limited to 'include/linux/page_cgroup.h')
-rw-r--r-- | include/linux/page_cgroup.h | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h index 777a524716db..9bfb8e68a595 100644 --- a/include/linux/page_cgroup.h +++ b/include/linux/page_cgroup.h | |||
@@ -3,9 +3,9 @@ | |||
3 | 3 | ||
4 | enum { | 4 | enum { |
5 | /* flags for mem_cgroup */ | 5 | /* flags for mem_cgroup */ |
6 | PCG_LOCK, /* Lock for pc->mem_cgroup and following bits. */ | 6 | PCG_USED = 0x01, /* This page is charged to a memcg */ |
7 | PCG_USED, /* this object is in use. */ | 7 | PCG_MEM = 0x02, /* This page holds a memory charge */ |
8 | PCG_MIGRATION, /* under page migration */ | 8 | PCG_MEMSW = 0x04, /* This page holds a memory+swap charge */ |
9 | __NR_PCG_FLAGS, | 9 | __NR_PCG_FLAGS, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -44,42 +44,9 @@ static inline void __init page_cgroup_init(void) | |||
44 | struct page_cgroup *lookup_page_cgroup(struct page *page); | 44 | struct page_cgroup *lookup_page_cgroup(struct page *page); |
45 | struct page *lookup_cgroup_page(struct page_cgroup *pc); | 45 | struct page *lookup_cgroup_page(struct page_cgroup *pc); |
46 | 46 | ||
47 | #define TESTPCGFLAG(uname, lname) \ | 47 | static inline int PageCgroupUsed(struct page_cgroup *pc) |
48 | static inline int PageCgroup##uname(struct page_cgroup *pc) \ | ||
49 | { return test_bit(PCG_##lname, &pc->flags); } | ||
50 | |||
51 | #define SETPCGFLAG(uname, lname) \ | ||
52 | static inline void SetPageCgroup##uname(struct page_cgroup *pc)\ | ||
53 | { set_bit(PCG_##lname, &pc->flags); } | ||
54 | |||
55 | #define CLEARPCGFLAG(uname, lname) \ | ||
56 | static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \ | ||
57 | { clear_bit(PCG_##lname, &pc->flags); } | ||
58 | |||
59 | #define TESTCLEARPCGFLAG(uname, lname) \ | ||
60 | static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \ | ||
61 | { return test_and_clear_bit(PCG_##lname, &pc->flags); } | ||
62 | |||
63 | TESTPCGFLAG(Used, USED) | ||
64 | CLEARPCGFLAG(Used, USED) | ||
65 | SETPCGFLAG(Used, USED) | ||
66 | |||
67 | SETPCGFLAG(Migration, MIGRATION) | ||
68 | CLEARPCGFLAG(Migration, MIGRATION) | ||
69 | TESTPCGFLAG(Migration, MIGRATION) | ||
70 | |||
71 | static inline void lock_page_cgroup(struct page_cgroup *pc) | ||
72 | { | ||
73 | /* | ||
74 | * Don't take this lock in IRQ context. | ||
75 | * This lock is for pc->mem_cgroup, USED, MIGRATION | ||
76 | */ | ||
77 | bit_spin_lock(PCG_LOCK, &pc->flags); | ||
78 | } | ||
79 | |||
80 | static inline void unlock_page_cgroup(struct page_cgroup *pc) | ||
81 | { | 48 | { |
82 | bit_spin_unlock(PCG_LOCK, &pc->flags); | 49 | return !!(pc->flags & PCG_USED); |
83 | } | 50 | } |
84 | 51 | ||
85 | #else /* CONFIG_MEMCG */ | 52 | #else /* CONFIG_MEMCG */ |