]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - mm/slab.h
memcg, slab: fix barrier usage when accessing memcg_caches
[mirror_ubuntu-artful-kernel.git] / mm / slab.h
index 0859c4241ba10b2ee602eca48af4e34dd82d6ae3..72d1f9df71bddba1463a1e4851918bb301fdad4c 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -163,9 +163,19 @@ static inline const char *cache_name(struct kmem_cache *s)
 static inline struct kmem_cache *
 cache_from_memcg_idx(struct kmem_cache *s, int idx)
 {
+       struct kmem_cache *cachep;
+
        if (!s->memcg_params)
                return NULL;
-       return s->memcg_params->memcg_caches[idx];
+       cachep = s->memcg_params->memcg_caches[idx];
+
+       /*
+        * Make sure we will access the up-to-date value. The code updating
+        * memcg_caches issues a write barrier to match this (see
+        * memcg_register_cache()).
+        */
+       smp_read_barrier_depends();
+       return cachep;
 }
 
 static inline struct kmem_cache *memcg_root_cache(struct kmem_cache *s)