diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2009-04-02 19:57:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-02 22:04:56 -0400 |
commit | a3b2d692690aef228e493b1beaafe5364cab3237 (patch) | |
tree | d3ad99c5370462861a1b918b4136e7bd7ad78e52 /include/linux | |
parent | 3c776e64660028236313f0e54f3a9945764422df (diff) |
cgroups: use css id in swap cgroup for saving memory v5
Try to use CSS ID for records in swap_cgroup. By this, on 64bit machine,
size of swap_cgroup goes down to 2 bytes from 8bytes.
This means, when 2GB of swap is equipped, (assume the page size is 4096bytes)
From size of swap_cgroup = 2G/4k * 8 = 4Mbytes.
To size of swap_cgroup = 2G/4k * 2 = 1Mbytes.
Reduction is large. Of course, there are trade-offs. This CSS ID will
add overhead to swap-in/swap-out/swap-free.
But in general,
- swap is a resource which the user tend to avoid use.
- If swap is never used, swap_cgroup area is not used.
- Reading traditional manuals, size of swap should be proportional to
size of memory. Memory size of machine is increasing now.
I think reducing size of swap_cgroup makes sense.
Note:
- ID->CSS lookup routine has no locks, it's under RCU-Read-Side.
- memcg can be obsolete at rmdir() but not freed while refcnt from
swap_cgroup is available.
Changelog v4->v5:
- reworked on to memcg-charge-swapcache-to-proper-memcg.patch
Changlog ->v4:
- fixed not configured case.
- deleted unnecessary comments.
- fixed NULL pointer bug.
- fixed message in dmesg.
[nishimura@mxp.nes.nec.co.jp: css_tryget can be called twice in !PageCgroupUsed case]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/page_cgroup.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h index 602cc1fdee90..7339c7bf7331 100644 --- a/include/linux/page_cgroup.h +++ b/include/linux/page_cgroup.h | |||
@@ -91,24 +91,23 @@ static inline void page_cgroup_init(void) | |||
91 | 91 | ||
92 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP | 92 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP |
93 | #include <linux/swap.h> | 93 | #include <linux/swap.h> |
94 | extern struct mem_cgroup * | 94 | extern unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id); |
95 | swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem); | 95 | extern unsigned short lookup_swap_cgroup(swp_entry_t ent); |
96 | extern struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent); | ||
97 | extern int swap_cgroup_swapon(int type, unsigned long max_pages); | 96 | extern int swap_cgroup_swapon(int type, unsigned long max_pages); |
98 | extern void swap_cgroup_swapoff(int type); | 97 | extern void swap_cgroup_swapoff(int type); |
99 | #else | 98 | #else |
100 | #include <linux/swap.h> | 99 | #include <linux/swap.h> |
101 | 100 | ||
102 | static inline | 101 | static inline |
103 | struct mem_cgroup *swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem) | 102 | unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id) |
104 | { | 103 | { |
105 | return NULL; | 104 | return 0; |
106 | } | 105 | } |
107 | 106 | ||
108 | static inline | 107 | static inline |
109 | struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent) | 108 | unsigned short lookup_swap_cgroup(swp_entry_t ent) |
110 | { | 109 | { |
111 | return NULL; | 110 | return 0; |
112 | } | 111 | } |
113 | 112 | ||
114 | static inline int | 113 | static inline int |