[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230613102820.19153-2-vbabka@suse.cz>
Date: Tue, 13 Jun 2023 12:28:21 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Christoph Lameter <cl@...ux.com>,
David Rientjes <rientjes@...gle.com>,
Pekka Enberg <penberg@...nel.org>,
Joonsoo Kim <iamjoonsoo.kim@....com>
Cc: Hyeonggon Yoo <42.hyeyoo@...il.com>,
Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
patches@...ts.linux.dev, linux-kernel@...r.kernel.org,
Vlastimil Babka <vbabka@...e.cz>
Subject: [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount
When CONFIG_MEMCG_KMEM is enabled, we disable cache merging for
KMALLOC_NORMAL so they don't end up merged with a cache that uses ad-hoc
__GFP_ACCOUNT. This was implemented by setting refcount to -1, but now
we have a proper SLAB_NO_MERGE flag, so use that instead.
Signed-off-by: Vlastimil Babka <vbabka@...e.cz>
---
mm/slab_common.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 0e0a617eae7d..67caf0bc3194 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -878,17 +878,17 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
flags |= SLAB_CACHE_DMA;
}
- kmalloc_caches[type][idx] = create_kmalloc_cache(
- kmalloc_info[idx].name[type],
- kmalloc_info[idx].size, flags, 0,
- kmalloc_info[idx].size);
-
/*
* If CONFIG_MEMCG_KMEM is enabled, disable cache merging for
* KMALLOC_NORMAL caches.
*/
if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL))
- kmalloc_caches[type][idx]->refcount = -1;
+ flags |= SLAB_NO_MERGE;
+
+ kmalloc_caches[type][idx] = create_kmalloc_cache(
+ kmalloc_info[idx].name[type],
+ kmalloc_info[idx].size, flags, 0,
+ kmalloc_info[idx].size);
}
/*
--
2.41.0
Powered by blists - more mailing lists