Commit 9798e8cd authored by Balbir Singh's avatar Balbir Singh Committed by James Toy

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>

Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 9c251cc7
...@@ -496,7 +496,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, ...@@ -496,7 +496,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
struct page_cgroup *pc, struct page_cgroup *pc,
bool charge) bool charge)
{ {
int val = (charge)? 1 : -1; int val = (charge) ? 1 : -1;
struct mem_cgroup_stat *stat = &mem->stat; struct mem_cgroup_stat *stat = &mem->stat;
struct mem_cgroup_stat_cpu *cpustat; struct mem_cgroup_stat_cpu *cpustat;
int cpu = get_cpu(); int cpu = get_cpu();
...@@ -1889,7 +1889,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype) ...@@ -1889,7 +1889,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
(ctype != MEM_CGROUP_CHARGE_TYPE_SWAPOUT)) (ctype != MEM_CGROUP_CHARGE_TYPE_SWAPOUT))
res_counter_uncharge(&mem->memsw, PAGE_SIZE, NULL); res_counter_uncharge(&mem->memsw, PAGE_SIZE, NULL);
} }
if (ctype == MEM_CGROUP_CHARGE_TYPE_SWAPOUT && mem_cgroup_is_root(mem)) if (ctype == MEM_CGROUP_CHARGE_TYPE_SWAPOUT)
mem_cgroup_swap_statistics(mem, true); mem_cgroup_swap_statistics(mem, true);
mem_cgroup_charge_statistics(mem, pc, false); mem_cgroup_charge_statistics(mem, pc, false);
...@@ -2486,10 +2486,34 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft, ...@@ -2486,10 +2486,34 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,
return retval; return retval;
} }
struct mem_cgroup_idx_data {
s64 val;
enum mem_cgroup_stat_index idx;
};
static int
mem_cgroup_get_idx_stat(struct mem_cgroup *mem, void *data)
{
struct mem_cgroup_idx_data *d = data;
d->val += mem_cgroup_read_stat(&mem->stat, d->idx);
return 0;
}
static void
mem_cgroup_get_recursive_idx_stat(struct mem_cgroup *mem,
enum mem_cgroup_stat_index idx, s64 *val)
{
struct mem_cgroup_idx_data d;
d.idx = idx;
d.val = 0;
mem_cgroup_walk_tree(mem, &d, mem_cgroup_get_idx_stat);
*val = d.val;
}
static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft) static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
{ {
struct mem_cgroup *mem = mem_cgroup_from_cont(cont); struct mem_cgroup *mem = mem_cgroup_from_cont(cont);
u64 val = 0; u64 idx_val, val;
int type, name; int type, name;
type = MEMFILE_TYPE(cft->private); type = MEMFILE_TYPE(cft->private);
...@@ -2497,22 +2521,26 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft) ...@@ -2497,22 +2521,26 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
switch (type) { switch (type) {
case _MEM: case _MEM:
if (name == RES_USAGE && mem_cgroup_is_root(mem)) { if (name == RES_USAGE && mem_cgroup_is_root(mem)) {
val = mem_cgroup_read_stat(&mem->stat, mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_CACHE); MEM_CGROUP_STAT_CACHE, &idx_val);
val += mem_cgroup_read_stat(&mem->stat, val = idx_val;
MEM_CGROUP_STAT_RSS); mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_RSS, &idx_val);
val += idx_val;
val <<= PAGE_SHIFT; val <<= PAGE_SHIFT;
} else } else
val = res_counter_read_u64(&mem->res, name); val = res_counter_read_u64(&mem->res, name);
break; break;
case _MEMSWAP: case _MEMSWAP:
if (name == RES_USAGE && mem_cgroup_is_root(mem)) { if (name == RES_USAGE && mem_cgroup_is_root(mem)) {
val = mem_cgroup_read_stat(&mem->stat, mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_CACHE); MEM_CGROUP_STAT_CACHE, &idx_val);
val += mem_cgroup_read_stat(&mem->stat, val = idx_val;
MEM_CGROUP_STAT_RSS); mem_cgroup_get_recursive_idx_stat(mem,
val += mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS, &idx_val);
MEM_CGROUP_STAT_SWAPOUT); val += idx_val;
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_SWAPOUT, &idx_val);
val <<= PAGE_SHIFT; val <<= PAGE_SHIFT;
} else } else
val = res_counter_read_u64(&mem->memsw, name); val = res_counter_read_u64(&mem->memsw, name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment