aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-12-18 17:23:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:14 -0500
commit749c54151a6e5b229e4ae067dbc651e54b161fbc (patch)
tree8d2d858e76e44d1bbf64439c189a57c18c8e60ae /mm/memcontrol.c
parent22933152934f30de6f05b600c03f8a08f853a8d2 (diff)
memcg: aggregate memcg cache values in slabinfo
When we create caches in memcgs, we need to display their usage information somewhere. We'll adopt a scheme similar to /proc/meminfo, with aggregate totals shown in the global file, and per-group information stored in the group itself. For the time being, only reads are allowed in the per-group cache. Signed-off-by: Glauber Costa <glommer@parallels.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Frederic Weisbecker <fweisbec@redhat.com> Cc: Greg Thelen <gthelen@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: JoonSoo Kim <js1304@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Michal Hocko <mhocko@suse.cz> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Rik van Riel <riel@redhat.com> Cc: Suleiman Souhlal <suleiman@google.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>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7633e0d429e0..a32d83c2e353 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -572,7 +572,8 @@ static void disarm_sock_keys(struct mem_cgroup *memcg)
572 * increase it. 572 * increase it.
573 */ 573 */
574static DEFINE_IDA(kmem_limited_groups); 574static DEFINE_IDA(kmem_limited_groups);
575static int memcg_limited_groups_array_size; 575int memcg_limited_groups_array_size;
576
576/* 577/*
577 * MIN_SIZE is different than 1, because we would like to avoid going through 578 * MIN_SIZE is different than 1, because we would like to avoid going through
578 * the alloc/free process all the time. In a small machine, 4 kmem-limited 579 * the alloc/free process all the time. In a small machine, 4 kmem-limited
@@ -2794,6 +2795,27 @@ static struct kmem_cache *memcg_params_to_cache(struct memcg_cache_params *p)
2794 return cachep->memcg_params->memcg_caches[memcg_cache_id(p->memcg)]; 2795 return cachep->memcg_params->memcg_caches[memcg_cache_id(p->memcg)];
2795} 2796}
2796 2797
2798#ifdef CONFIG_SLABINFO
2799static int mem_cgroup_slabinfo_read(struct cgroup *cont, struct cftype *cft,
2800 struct seq_file *m)
2801{
2802 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
2803 struct memcg_cache_params *params;
2804
2805 if (!memcg_can_account_kmem(memcg))
2806 return -EIO;
2807
2808 print_slabinfo_header(m);
2809
2810 mutex_lock(&memcg->slab_caches_mutex);
2811 list_for_each_entry(params, &memcg->memcg_slab_caches, list)
2812 cache_show(memcg_params_to_cache(params), m);
2813 mutex_unlock(&memcg->slab_caches_mutex);
2814
2815 return 0;
2816}
2817#endif
2818
2797static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, u64 size) 2819static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, u64 size)
2798{ 2820{
2799 struct res_counter *fail_res; 2821 struct res_counter *fail_res;
@@ -5822,6 +5844,12 @@ static struct cftype mem_cgroup_files[] = {
5822 .trigger = mem_cgroup_reset, 5844 .trigger = mem_cgroup_reset,
5823 .read = mem_cgroup_read, 5845 .read = mem_cgroup_read,
5824 }, 5846 },
5847#ifdef CONFIG_SLABINFO
5848 {
5849 .name = "kmem.slabinfo",
5850 .read_seq_string = mem_cgroup_slabinfo_read,
5851 },
5852#endif
5825#endif 5853#endif
5826 { }, /* terminate */ 5854 { }, /* terminate */
5827}; 5855};