Commit 9b1a75ab 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 3e6e8789
......@@ -496,7 +496,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
struct page_cgroup *pc,
bool charge)
{
int val = (charge)? 1 : -1;
int val = (charge) ? 1 : -1;
struct mem_cgroup_stat *stat = &mem->stat;
struct mem_cgroup_stat_cpu *cpustat;
int cpu = get_cpu();
......@@ -1893,7 +1893,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
(ctype != MEM_CGROUP_CHARGE_TYPE_SWAPOUT))
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_charge_statistics(mem, pc, false);
......@@ -2499,10 +2499,34 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,
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)
{
struct mem_cgroup *mem = mem_cgroup_from_cont(cont);
u64 val = 0;
u64 idx_val, val;
int type, name;
type = MEMFILE_TYPE(cft->private);
......@@ -2510,22 +2534,26 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
switch (type) {
case _MEM:
if (name == RES_USAGE && mem_cgroup_is_root(mem)) {
val = mem_cgroup_read_stat(&mem->stat,
MEM_CGROUP_STAT_CACHE);
val += mem_cgroup_read_stat(&mem->stat,
MEM_CGROUP_STAT_RSS);
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_CACHE, &idx_val);
val = idx_val;
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_RSS, &idx_val);
val += idx_val;
val <<= PAGE_SHIFT;
} else
val = res_counter_read_u64(&mem->res, name);
break;
case _MEMSWAP:
if (name == RES_USAGE && mem_cgroup_is_root(mem)) {
val = mem_cgroup_read_stat(&mem->stat,
MEM_CGROUP_STAT_CACHE);
val += mem_cgroup_read_stat(&mem->stat,
MEM_CGROUP_STAT_RSS);
val += mem_cgroup_read_stat(&mem->stat,
MEM_CGROUP_STAT_SWAPOUT);
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_CACHE, &idx_val);
val = idx_val;
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_RSS, &idx_val);
val += idx_val;
mem_cgroup_get_recursive_idx_stat(mem,
MEM_CGROUP_STAT_SWAPOUT, &idx_val);
val <<= PAGE_SHIFT;
} else
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