diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2016-01-20 18:03:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-20 20:09:18 -0500 |
commit | b2807f07f4f87362925b8a5b8cbb7b624da10f03 (patch) | |
tree | e0ecb241a359fdca288bb1a3e8fb964a453b074b | |
parent | 587d9f726aaec52157e4156e50363dbe6cb82bdb (diff) |
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: Johannes 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/memcontrol.h | 5 | ||||
-rw-r--r-- | mm/memcontrol.c | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 166661708410..9ae48d4aeb5e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -50,6 +50,9 @@ enum mem_cgroup_stat_index { | |||
50 | MEM_CGROUP_STAT_WRITEBACK, /* # of pages under writeback */ | 50 | MEM_CGROUP_STAT_WRITEBACK, /* # of pages under writeback */ |
51 | MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */ | 51 | MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */ |
52 | MEM_CGROUP_STAT_NSTATS, | 52 | MEM_CGROUP_STAT_NSTATS, |
53 | /* default hierarchy stats */ | ||
54 | MEMCG_SOCK, | ||
55 | MEMCG_NR_STAT, | ||
53 | }; | 56 | }; |
54 | 57 | ||
55 | struct mem_cgroup_reclaim_cookie { | 58 | struct mem_cgroup_reclaim_cookie { |
@@ -87,7 +90,7 @@ enum mem_cgroup_events_target { | |||
87 | 90 | ||
88 | #ifdef CONFIG_MEMCG | 91 | #ifdef CONFIG_MEMCG |
89 | struct mem_cgroup_stat_cpu { | 92 | struct mem_cgroup_stat_cpu { |
90 | long count[MEM_CGROUP_STAT_NSTATS]; | 93 | long count[MEMCG_NR_STAT]; |
91 | unsigned long events[MEMCG_NR_EVENTS]; | 94 | unsigned long events[MEMCG_NR_EVENTS]; |
92 | unsigned long nr_page_events; | 95 | unsigned long nr_page_events; |
93 | unsigned long targets[MEM_CGROUP_NTARGETS]; | 96 | unsigned long targets[MEM_CGROUP_NTARGETS]; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 98f4109bff6c..ca052f2a4a0b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -5128,6 +5128,8 @@ static int memory_stat_show(struct seq_file *m, void *v) | |||
5128 | (u64)tree_stat(memcg, MEM_CGROUP_STAT_RSS) * PAGE_SIZE); | 5128 | (u64)tree_stat(memcg, MEM_CGROUP_STAT_RSS) * PAGE_SIZE); |
5129 | seq_printf(m, "file %llu\n", | 5129 | seq_printf(m, "file %llu\n", |
5130 | (u64)tree_stat(memcg, MEM_CGROUP_STAT_CACHE) * PAGE_SIZE); | 5130 | (u64)tree_stat(memcg, MEM_CGROUP_STAT_CACHE) * PAGE_SIZE); |
5131 | seq_printf(m, "sock %llu\n", | ||
5132 | (u64)tree_stat(memcg, MEMCG_SOCK) * PAGE_SIZE); | ||
5131 | 5133 | ||
5132 | seq_printf(m, "file_mapped %llu\n", | 5134 | seq_printf(m, "file_mapped %llu\n", |
5133 | (u64)tree_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED) * | 5135 | (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 | if (in_softirq()) | 5633 | if (in_softirq()) |
5632 | gfp_mask = GFP_NOWAIT; | 5634 | gfp_mask = GFP_NOWAIT; |
5633 | 5635 | ||
5636 | this_cpu_add(memcg->stat->count[MEMCG_SOCK], nr_pages); | ||
5637 | |||
5634 | if (try_charge(memcg, gfp_mask, nr_pages) == 0) | 5638 | if (try_charge(memcg, gfp_mask, nr_pages) == 0) |
5635 | return true; | 5639 | return true; |
5636 | 5640 | ||
@@ -5650,6 +5654,8 @@ void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) | |||
5650 | return; | 5654 | return; |
5651 | } | 5655 | } |
5652 | 5656 | ||
5657 | this_cpu_sub(memcg->stat->count[MEMCG_SOCK], nr_pages); | ||
5658 | |||
5653 | page_counter_uncharge(&memcg->memory, nr_pages); | 5659 | page_counter_uncharge(&memcg->memory, nr_pages); |
5654 | css_put_many(&memcg->css, nr_pages); | 5660 | css_put_many(&memcg->css, nr_pages); |
5655 | } | 5661 | } |