Skip to content

Commit d5bf485

Browse files
committed
mm/slab_common: use SLAB_NO_MERGE instead of negative refcount
When CONFIG_MEMCG_KMEM is enabled, we disable cache merging for KMALLOC_NORMAL caches so they don't end up merged with a cache that uses ad-hoc __GFP_ACCOUNT when allocating. This was implemented by setting the refcount to -1, but now we have a proper SLAB_NO_MERGE flag, so use that instead. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: David Rientjes <rientjes@google.com>
1 parent d0bf7d5 commit d5bf485

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

mm/slab_common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -878,17 +878,17 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
878878
flags |= SLAB_CACHE_DMA;
879879
}
880880

881-
kmalloc_caches[type][idx] = create_kmalloc_cache(
882-
kmalloc_info[idx].name[type],
883-
kmalloc_info[idx].size, flags, 0,
884-
kmalloc_info[idx].size);
885-
886881
/*
887882
* If CONFIG_MEMCG_KMEM is enabled, disable cache merging for
888883
* KMALLOC_NORMAL caches.
889884
*/
890885
if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL))
891-
kmalloc_caches[type][idx]->refcount = -1;
886+
flags |= SLAB_NO_MERGE;
887+
888+
kmalloc_caches[type][idx] = create_kmalloc_cache(
889+
kmalloc_info[idx].name[type],
890+
kmalloc_info[idx].size, flags, 0,
891+
kmalloc_info[idx].size);
892892
}
893893

894894
/*

0 commit comments

Comments
 (0)