|
@@ -3274,12 +3274,14 @@ void memcg_register_cache(struct kmem_cache *s)
|
|
|
list_add(&s->memcg_params->list, &memcg->memcg_slab_caches);
|
|
|
mutex_unlock(&memcg->slab_caches_mutex);
|
|
|
|
|
|
- root->memcg_params->memcg_caches[id] = s;
|
|
|
/*
|
|
|
- * the readers won't lock, make sure everybody sees the updated value,
|
|
|
- * so they won't put stuff in the queue again for no reason
|
|
|
+ * Since readers won't lock (see cache_from_memcg_idx()), we need a
|
|
|
+ * barrier here to ensure nobody will see the kmem_cache partially
|
|
|
+ * initialized.
|
|
|
*/
|
|
|
- wmb();
|
|
|
+ smp_wmb();
|
|
|
+
|
|
|
+ root->memcg_params->memcg_caches[id] = s;
|
|
|
}
|
|
|
|
|
|
void memcg_unregister_cache(struct kmem_cache *s)
|
|
@@ -3605,7 +3607,7 @@ struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep,
|
|
|
gfp_t gfp)
|
|
|
{
|
|
|
struct mem_cgroup *memcg;
|
|
|
- int idx;
|
|
|
+ struct kmem_cache *memcg_cachep;
|
|
|
|
|
|
VM_BUG_ON(!cachep->memcg_params);
|
|
|
VM_BUG_ON(!cachep->memcg_params->is_root_cache);
|
|
@@ -3619,15 +3621,9 @@ struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep,
|
|
|
if (!memcg_can_account_kmem(memcg))
|
|
|
goto out;
|
|
|
|
|
|
- idx = memcg_cache_id(memcg);
|
|
|
-
|
|
|
- /*
|
|
|
- * barrier to mare sure we're always seeing the up to date value. The
|
|
|
- * code updating memcg_caches will issue a write barrier to match this.
|
|
|
- */
|
|
|
- read_barrier_depends();
|
|
|
- if (likely(cache_from_memcg_idx(cachep, idx))) {
|
|
|
- cachep = cache_from_memcg_idx(cachep, idx);
|
|
|
+ memcg_cachep = cache_from_memcg_idx(cachep, memcg_cache_id(memcg));
|
|
|
+ if (likely(memcg_cachep)) {
|
|
|
+ cachep = memcg_cachep;
|
|
|
goto out;
|
|
|
}
|
|
|
|