]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memcg: remove test for current->mm in memcg_stop/resume_kmem_account
authorGlauber Costa <glommer@parallels.com>
Thu, 29 Nov 2012 03:16:42 +0000 (14:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2012 05:22:58 +0000 (16:22 +1100)
The original reason for the existence of this test, was that
memcg_kmem_cache_create could be called from either softirq context (where
memcg_stop/resume_account is not needed), or process context, (where
memcg_stop/resume_account is needed).  Just skipping it in-function was
the cleanest way to merge both behaviors.  The reason for that is that we
would try to create caches right away through memcg_kmem_cache_create if
the context would allow us to.

However, the final version of the code that merged did not have this
behavior and we always queue up new cache creation.  Thus, instead of a
comment explaining why current->mm test is needed, my proposal in this
patch is to remove memcg_stop/resume_account from the worker thread and
make sure all callers have a valid mm context.

Signed-off-by: Glauber Costa <glommer@parallels.com>
Cc: Michal Hocko <mhocko@suse.cz>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index 7b5612ea7dac4fa63ccdd20e20d9548daf36d8dd..b095f7fa97c0a44bccf44cf9866e6911435701c7 100644 (file)
@@ -3047,17 +3047,13 @@ out:
  */
 static inline void memcg_stop_kmem_account(void)
 {
-       if (!current->mm)
-               return;
-
+       VM_BUG_ON(!current->mm);
        current->memcg_kmem_skip_account++;
 }
 
 static inline void memcg_resume_kmem_account(void)
 {
-       if (!current->mm)
-               return;
-
+       VM_BUG_ON(!current->mm);
        current->memcg_kmem_skip_account--;
 }
 
@@ -3119,11 +3115,7 @@ static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
        if (new_cachep)
                goto out;
 
-       /* Don't block progress to enqueue caches for internal infrastructure */
-       memcg_stop_kmem_account();
        new_cachep = kmem_cache_dup(memcg, cachep);
-       memcg_resume_kmem_account();
-
        if (new_cachep == NULL) {
                new_cachep = cachep;
                goto out;