Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by "Harry Yoo (Meta)"
Wed, 25 Nov 2026 21:37
[PATCH slab/for-next v2 01/14] mm/slab: allow passing SLAB_MAY_ACCOUNT to kmem_cache_create()
Author: "Harry Yoo (Meta)"
Date: Wed, 25 Nov 2026 21:37
Date: Wed, 25 Nov 2026 21:37
69 lines
11567 bytes
11567 bytes
Callers will specify SLAB_MAY_ACCOUNT for caches whose objects may be
allocated with __GFP_ACCOUNT. Accept the flag in SLAB_CORE_FLAGS.
SLAB_MAY_ACCOUNT prevents merging but is not part of the sysfs ID. This
was fine while all mergeable caches had the flag. Now that callers may
specify it, encode it in create_unique_id() to keep the ID unique.
Define the flag in tools/ as well to avoid breaking the userspace tests.
Signed-off-by: Harry Yoo (Meta) <harry@kernel.org>
---
mm/slab.h | 2 +-
mm/slub.c | 2 ++
tools/include/linux/slab.h | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/mm/slab.h b/mm/slab.h
index 47a6cc8b22ff..168c394ac73f 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -484,7 +484,7 @@ void flush_rcu_sheaves_on_cache(struct kmem_cache *s);
SLAB_CACHE_DMA32 | SLAB_PANIC | \
SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS | \
SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \
- SLAB_TEMPORARY | SLAB_ACCOUNT | \
+ SLAB_TEMPORARY | SLAB_ACCOUNT | SLAB_MAY_ACCOUNT | \
SLAB_NO_USER_FLAGS | SLAB_KMALLOC | SLAB_NO_MERGE)
#define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
diff --git a/mm/slub.c b/mm/slub.c
index 47a664427c50..3187e78e2e09 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -9833,6 +9833,8 @@ static char *create_unique_id(struct kmem_cache *s)
*p++ = 'a';
if (s->flags & SLAB_ACCOUNT)
*p++ = 'A';
+ if (s->flags & SLAB_MAY_ACCOUNT)
+ *p++ = 'M';
if (s->flags & SLAB_DEBUG_NOOP)
*p++ = 'N';
if (p != name + 1)
diff --git a/tools/include/linux/slab.h b/tools/include/linux/slab.h
index 2e63c2e726aa..104f962ae6f2 100644
--- a/tools/include/linux/slab.h
+++ b/tools/include/linux/slab.h
@@ -15,6 +15,7 @@ enum _slab_flag_bits {
_SLAB_PANIC,
_SLAB_TYPESAFE_BY_RCU,
_SLAB_ACCOUNT,
+ _SLAB_MAY_ACCOUNT,
_SLAB_FLAGS_LAST_BIT
};
@@ -26,8 +27,10 @@ enum _slab_flag_bits {
#define SLAB_TYPESAFE_BY_RCU __SLAB_FLAG_BIT(_SLAB_TYPESAFE_BY_RCU)
#ifdef CONFIG_MEMCG
# define SLAB_ACCOUNT __SLAB_FLAG_BIT(_SLAB_ACCOUNT)
+# define SLAB_MAY_ACCOUNT __SLAB_FLAG_BIT(_SLAB_MAY_ACCOUNT)
#else
# define SLAB_ACCOUNT __SLAB_FLAG_UNUSED
+# define SLAB_MAY_ACCOUNT __SLAB_FLAG_UNUSED
#endif
void *kmalloc(size_t size, gfp_t gfp);
--
2.54.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads