]> git.karo-electronics.de Git - linux-beck.git/blobdiff - mm/memcontrol.c
Merge remote-tracking branch 'asoc/fix/sgtl5000' into tmp
[linux-beck.git] / mm / memcontrol.c
index 7633e0d429e05bfde1ddfb116931e4d0e87d61a4..09255ec8159c459624e66ee5ac17ca092d2fcd6b 100644 (file)
@@ -572,7 +572,8 @@ static void disarm_sock_keys(struct mem_cgroup *memcg)
  * increase it.
  */
 static DEFINE_IDA(kmem_limited_groups);
-static int memcg_limited_groups_array_size;
+int memcg_limited_groups_array_size;
+
 /*
  * MIN_SIZE is different than 1, because we would like to avoid going through
  * 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)
        return cachep->memcg_params->memcg_caches[memcg_cache_id(p->memcg)];
 }
 
+#ifdef CONFIG_SLABINFO
+static int mem_cgroup_slabinfo_read(struct cgroup *cont, struct cftype *cft,
+                                       struct seq_file *m)
+{
+       struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
+       struct memcg_cache_params *params;
+
+       if (!memcg_can_account_kmem(memcg))
+               return -EIO;
+
+       print_slabinfo_header(m);
+
+       mutex_lock(&memcg->slab_caches_mutex);
+       list_for_each_entry(params, &memcg->memcg_slab_caches, list)
+               cache_show(memcg_params_to_cache(params), m);
+       mutex_unlock(&memcg->slab_caches_mutex);
+
+       return 0;
+}
+#endif
+
 static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, u64 size)
 {
        struct res_counter *fail_res;
@@ -2990,7 +3012,8 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups)
        return 0;
 }
 
-int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s)
+int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
+                        struct kmem_cache *root_cache)
 {
        size_t size = sizeof(struct memcg_cache_params);
 
@@ -3004,8 +3027,10 @@ int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s)
        if (!s->memcg_params)
                return -ENOMEM;
 
-       if (memcg)
+       if (memcg) {
                s->memcg_params->memcg = memcg;
+               s->memcg_params->root_cache = root_cache;
+       }
        return 0;
 }
 
@@ -3164,7 +3189,7 @@ static struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg,
                return NULL;
 
        new = kmem_cache_create_memcg(memcg, name, s->object_size, s->align,
-                                     (s->flags & ~SLAB_PANIC), s->ctor);
+                                     (s->flags & ~SLAB_PANIC), s->ctor, s);
 
        if (new)
                new->allocflags |= __GFP_KMEMCG;
@@ -3204,7 +3229,6 @@ static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
        }
 
        mem_cgroup_get(memcg);
-       new_cachep->memcg_params->root_cache = cachep;
        atomic_set(&new_cachep->memcg_params->nr_pages , 0);
 
        cachep->memcg_params->memcg_caches[idx] = new_cachep;
@@ -5822,6 +5846,12 @@ static struct cftype mem_cgroup_files[] = {
                .trigger = mem_cgroup_reset,
                .read = mem_cgroup_read,
        },
+#ifdef CONFIG_SLABINFO
+       {
+               .name = "kmem.slabinfo",
+               .read_seq_string = mem_cgroup_slabinfo_read,
+       },
+#endif
 #endif
        { },    /* terminate */
 };
@@ -6060,7 +6090,6 @@ mem_cgroup_css_alloc(struct cgroup *cont)
                                                &per_cpu(memcg_stock, cpu);
                        INIT_WORK(&stock->work, drain_local_stock);
                }
-               hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
        } else {
                parent = mem_cgroup_from_cont(cont->parent);
                memcg->use_hierarchy = parent->use_hierarchy;
@@ -6726,6 +6755,19 @@ struct cgroup_subsys mem_cgroup_subsys = {
        .use_id = 1,
 };
 
+/*
+ * The rest of init is performed during ->css_alloc() for root css which
+ * happens before initcalls.  hotcpu_notifier() can't be done together as
+ * it would introduce circular locking by adding cgroup_lock -> cpu hotplug
+ * dependency.  Do it from a subsys_initcall().
+ */
+static int __init mem_cgroup_init(void)
+{
+       hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
+       return 0;
+}
+subsys_initcall(mem_cgroup_init);
+
 #ifdef CONFIG_MEMCG_SWAP
 static int __init enable_swap_account(char *s)
 {