aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/page_cgroup.h
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-01-07 21:07:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:05 -0500
commit27a7faa0779dd13729196c1a818c294f44bbd1ee (patch)
tree30837689bf39eb734a8917f2c912e1b8ac0c28c0 /include/linux/page_cgroup.h
parentc077719be8e9e6b55702117513d1b5f41d80404a (diff)
memcg: swap cgroup for remembering usage
For accounting swap, we need a record per swap entry, at least. This patch adds following function. - swap_cgroup_swapon() .... called from swapon - swap_cgroup_swapoff() ... called at the end of swapoff. - swap_cgroup_record() .... record information of swap entry. - swap_cgroup_lookup() .... lookup information of swap entry. This patch just implements "how to record information". No actual method for limit the usage of swap. These routine uses flat table to record and lookup. "wise" lookup system like radix-tree requires requires memory allocation at new records but swap-out is usually called under memory shortage (or memcg hits limit.) So, I used static allocation. (maybe dynamic allocation is not very hard but it adds additional memory allocation in memory shortage path.) Note1: In this, we use pointer to record information and this means 8bytes per swap entry. I think we can reduce this when we create "id of cgroup" in the range of 0-65535 or 0-255. Reported-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Tested-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Reported-by: Hugh Dickins <hugh@veritas.com> Reported-by: Balbir Singh <balbir@linux.vnet.ibm.com> Reported-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/page_cgroup.h')
-rw-r--r--include/linux/page_cgroup.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
index 1e6d34bfa094..d754b2dfbf2d 100644
--- a/include/linux/page_cgroup.h
+++ b/include/linux/page_cgroup.h
@@ -105,4 +105,39 @@ static inline void page_cgroup_init(void)
105} 105}
106 106
107#endif 107#endif
108
109#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
110#include <linux/swap.h>
111extern struct mem_cgroup *
112swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem);
113extern struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent);
114extern int swap_cgroup_swapon(int type, unsigned long max_pages);
115extern void swap_cgroup_swapoff(int type);
116#else
117#include <linux/swap.h>
118
119static inline
120struct mem_cgroup *swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem)
121{
122 return NULL;
123}
124
125static inline
126struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent)
127{
128 return NULL;
129}
130
131static inline int
132swap_cgroup_swapon(int type, unsigned long max_pages)
133{
134 return 0;
135}
136
137static inline void swap_cgroup_swapoff(int type)
138{
139 return;
140}
141
142#endif
108#endif 143#endif