Commit b2807f07 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

mm: memcontrol: add "sock" to cgroup2 memory.stat

Provide statistics on how much of a cgroup's memory footprint is made up
of socket buffers from network connections owned by the group.
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 587d9f72
...@@ -50,6 +50,9 @@ enum mem_cgroup_stat_index { ...@@ -50,6 +50,9 @@ enum mem_cgroup_stat_index {
MEM_CGROUP_STAT_WRITEBACK, /* # of pages under writeback */ MEM_CGROUP_STAT_WRITEBACK, /* # of pages under writeback */
MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */ MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */
MEM_CGROUP_STAT_NSTATS, MEM_CGROUP_STAT_NSTATS,
/* default hierarchy stats */
MEMCG_SOCK,
MEMCG_NR_STAT,
}; };
struct mem_cgroup_reclaim_cookie { struct mem_cgroup_reclaim_cookie {
...@@ -87,7 +90,7 @@ enum mem_cgroup_events_target { ...@@ -87,7 +90,7 @@ enum mem_cgroup_events_target {
#ifdef CONFIG_MEMCG #ifdef CONFIG_MEMCG
struct mem_cgroup_stat_cpu { struct mem_cgroup_stat_cpu {
long count[MEM_CGROUP_STAT_NSTATS]; long count[MEMCG_NR_STAT];
unsigned long events[MEMCG_NR_EVENTS]; unsigned long events[MEMCG_NR_EVENTS];
unsigned long nr_page_events; unsigned long nr_page_events;
unsigned long targets[MEM_CGROUP_NTARGETS]; unsigned long targets[MEM_CGROUP_NTARGETS];
......
...@@ -5128,6 +5128,8 @@ static int memory_stat_show(struct seq_file *m, void *v) ...@@ -5128,6 +5128,8 @@ static int memory_stat_show(struct seq_file *m, void *v)
(u64)tree_stat(memcg, MEM_CGROUP_STAT_RSS) * PAGE_SIZE); (u64)tree_stat(memcg, MEM_CGROUP_STAT_RSS) * PAGE_SIZE);
seq_printf(m, "file %llu\n", seq_printf(m, "file %llu\n",
(u64)tree_stat(memcg, MEM_CGROUP_STAT_CACHE) * PAGE_SIZE); (u64)tree_stat(memcg, MEM_CGROUP_STAT_CACHE) * PAGE_SIZE);
seq_printf(m, "sock %llu\n",
(u64)tree_stat(memcg, MEMCG_SOCK) * PAGE_SIZE);
seq_printf(m, "file_mapped %llu\n", seq_printf(m, "file_mapped %llu\n",
(u64)tree_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED) * (u64)tree_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED) *
...@@ -5631,6 +5633,8 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) ...@@ -5631,6 +5633,8 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
if (in_softirq()) if (in_softirq())
gfp_mask = GFP_NOWAIT; gfp_mask = GFP_NOWAIT;
this_cpu_add(memcg->stat->count[MEMCG_SOCK], nr_pages);
if (try_charge(memcg, gfp_mask, nr_pages) == 0) if (try_charge(memcg, gfp_mask, nr_pages) == 0)
return true; return true;
...@@ -5650,6 +5654,8 @@ void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) ...@@ -5650,6 +5654,8 @@ void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
return; return;
} }
this_cpu_sub(memcg->stat->count[MEMCG_SOCK], nr_pages);
page_counter_uncharge(&memcg->memory, nr_pages); page_counter_uncharge(&memcg->memory, nr_pages);
css_put_many(&memcg->css, nr_pages); css_put_many(&memcg->css, nr_pages);
} }
......
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