Skip to contentSkip to conversation

slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set

PATCH In review Hao Li 3 participants 7 messages Feb 5 – Feb 6

Subsystems (2)
lore
Share & tools
lore

Hao Li

author reviewer
#0 lore raw

PATCH 1/1 slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---
 mm/slub.c | 3 +++
 1 file changed, 3 insertions(+)
mm/slub.c +3 -0
index 865047eaf02b..3b1402e1c39d 100644
@@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
  */
 static inline bool need_slab_obj_exts(struct kmem_cache *s)
 {
+	if (s->flags & SLAB_NO_OBJ_EXT)
+		return false;
+
 	if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
 		return true;
 
Signature · 1 line
2.50.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---

Looks reasonable to me,

Thanks!

Quoted 17 lines
 mm/slub.c | 3 +++
 1 file changed, 3 insertions(+)
mm/slub.c +3 -0
index 865047eaf02b..3b1402e1c39d 100644
@@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
  */
 static inline bool need_slab_obj_exts(struct kmem_cache *s)
 {
+	if (s->flags & SLAB_NO_OBJ_EXT)
+		return false;
+
 	if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
 		return true;
 
Signature · 2 lines
Cheers,
Harry / Hyeonggon
#2 lore raw
Quoted 10 lines · Harry Yoo
Quoted 6 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---

Looks reasonable to me,

Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment? But a correct thing to do.

Quoted 20 lines

Thanks!

Quoted 17 lines
 mm/slub.c | 3 +++
 1 file changed, 3 insertions(+)
mm/slub.c +3 -0
index 865047eaf02b..3b1402e1c39d 100644
@@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
  */
 static inline bool need_slab_obj_exts(struct kmem_cache *s)
 {
+	if (s->flags & SLAB_NO_OBJ_EXT)
+		return false;
+
 	if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
 		return true;
 
#3 lore raw
Quoted 6 lines · Vlastimil Babka
Quoted 5 lines · Harry Yoo
Quoted 4 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

---

Looks reasonable to me,

Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment?

...unless you enable memory allocation profiling :)

Quoted 1 line

But a correct thing to do.

Signature · 2 lines
Cheers,
Harry / Hyeonggon
#4 lore raw
Quoted 10 lines · Harry Yoo
Quoted 9 lines · Vlastimil Babka
Quoted 8 lines · Harry Yoo
Quoted 6 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Looks reasonable to me,

Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment?

...unless you enable memory allocation profiling :)

If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in leftover space?

Quoted 2 lines
Quoted 1 line

But a correct thing to do.

#5 lore raw
Quoted 14 lines · Vlastimil Babka
Quoted 13 lines · Harry Yoo
Quoted 12 lines · Vlastimil Babka
Quoted 10 lines · Harry Yoo
Quoted 6 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---

Looks reasonable to me,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment?

...unless you enable memory allocation profiling :)

If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in leftover space?

/me builds and tests a new kernel with mem profiling always enabled...

Yes, but only if merging is disabled.

If you disable slab merging with slab_nomerge, kmem_cache gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.

When I enable debug feature slab_debug=P (and thus change s->size), kmem_cache_node gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.

Signature · 2 lines
Cheers,
Harry / Hyeonggon
author reviewer
#6 lore raw
Quoted 25 lines · Harry Yoo
Quoted 14 lines · Vlastimil Babka
Quoted 13 lines · Harry Yoo
Quoted 12 lines · Vlastimil Babka
Quoted 10 lines · Harry Yoo
Quoted 6 lines · Hao Li

SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't check this flag. We should return false unconditionally when SLAB_NO_OBJ_EXT is set.

---

Looks reasonable to me,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment?

...unless you enable memory allocation profiling :)

If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in leftover space?

/me builds and tests a new kernel with mem profiling always enabled...

Quoted 7 lines

Yes, but only if merging is disabled.

If you disable slab merging with slab_nomerge, kmem_cache gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.

When I enable debug feature slab_debug=P (and thus change s->size), kmem_cache_node gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.

Thanks for testing, this matches what I've seen too.

Besides, even if the two boot caches, kmem_cache and kmem_cache_node, go through the SLAB_OBJ_EXT_IN_OBJ path, it seems it wouldn't cause real trouble. We'd just end up doing some unnecessary memset. So, as Vlastimil said, this patch is mostly about doing the right thing.

Signature · 2 lines
Thanks,
Hao
Quoted 4 lines
Signature · 3 lines
-- 
Cheers,
Harry / Hyeonggon