linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount
@ 2023-06-13 10:28 Vlastimil Babka
  2023-06-13 23:15 ` David Rientjes
  0 siblings, 1 reply; 2+ messages in thread
From: Vlastimil Babka @ 2023-06-13 10:28 UTC (permalink / raw)
  To: Christoph Lameter, David Rientjes, Pekka Enberg, Joonsoo Kim
  Cc: Hyeonggon Yoo, Roman Gushchin, linux-mm, patches, linux-kernel,
	Vlastimil Babka

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@suse.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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount
  2023-06-13 10:28 [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount Vlastimil Babka
@ 2023-06-13 23:15 ` David Rientjes
  0 siblings, 0 replies; 2+ messages in thread
From: David Rientjes @ 2023-06-13 23:15 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, Hyeonggon Yoo,
	Roman Gushchin, linux-mm, patches, linux-kernel

On Tue, 13 Jun 2023, Vlastimil Babka wrote:

> 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@suse.cz>

Acked-by: David Rientjes <rientjes@google.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-13 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 10:28 [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount Vlastimil Babka
2023-06-13 23:15 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox