* [PATCH 0/2] fixes for slab->obj_exts allocation failure handling
@ 2025-09-15 20:09 Suren Baghdasaryan
2025-09-15 20:09 ` [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails Suren Baghdasaryan
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-09-15 20:09 UTC (permalink / raw)
To: vbabka
Cc: akpm, cl, rientjes, roman.gushchin, harry.yoo, shakeel.butt,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, surenb, linux-mm, linux-kernel
Fixes for several issues noticed by Shakeel pertaining to slab->obj_exts
allocation failure handling in [1].
Patchset is based on mm-new.
Please route it via vbabka/slab.git as it's relevant to Alexei's patches
in that branch.
[1] https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/
Suren Baghdasaryan (2):
slab: prevent warnings when slab obj_exts vector allocation fails
slab: mark slab->obj_exts allocation failures unconditionally
mm/slab.h | 8 ++++++--
mm/slub.c | 3 +--
2 files changed, 7 insertions(+), 4 deletions(-)
base-commit: 9a9318f95d63805868bd21e1381d68c3a75d03a7
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails
2025-09-15 20:09 [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Suren Baghdasaryan
@ 2025-09-15 20:09 ` Suren Baghdasaryan
2025-09-15 20:14 ` Shakeel Butt
2025-09-15 20:09 ` [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally Suren Baghdasaryan
2025-09-16 12:35 ` [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Vlastimil Babka
2 siblings, 1 reply; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-09-15 20:09 UTC (permalink / raw)
To: vbabka
Cc: akpm, cl, rientjes, roman.gushchin, harry.yoo, shakeel.butt,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, surenb, linux-mm, linux-kernel, stable
When object extension vector allocation fails, we set slab->obj_exts to
OBJEXTS_ALLOC_FAIL to indicate the failure. Later, once the vector is
successfully allocated, we will use this flag to mark codetag references
stored in that vector as empty to avoid codetag warnings.
slab_obj_exts() used to retrieve the slab->obj_exts vector pointer checks
slab->obj_exts for being either NULL or a pointer with MEMCG_DATA_OBJEXTS
bit set. However it does not handle the case when slab->obj_exts equals
OBJEXTS_ALLOC_FAIL. Add the missing condition to avoid extra warning.
Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")
Reported-by: Shakeel Butt <shakeel.butt@linux.dev>
Closes: https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: stable@vger.kernel.org # v6.10+
---
mm/slab.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/slab.h b/mm/slab.h
index c41a512dd07c..b930193fd94e 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -526,8 +526,12 @@ static inline struct slabobj_ext *slab_obj_exts(struct slab *slab)
unsigned long obj_exts = READ_ONCE(slab->obj_exts);
#ifdef CONFIG_MEMCG
- VM_BUG_ON_PAGE(obj_exts && !(obj_exts & MEMCG_DATA_OBJEXTS),
- slab_page(slab));
+ /*
+ * obj_exts should be either NULL, a valid pointer with
+ * MEMCG_DATA_OBJEXTS bit set or be equal to OBJEXTS_ALLOC_FAIL.
+ */
+ VM_BUG_ON_PAGE(obj_exts && !(obj_exts & MEMCG_DATA_OBJEXTS) &&
+ obj_exts != OBJEXTS_ALLOC_FAIL, slab_page(slab));
VM_BUG_ON_PAGE(obj_exts & MEMCG_DATA_KMEM, slab_page(slab));
#endif
return (struct slabobj_ext *)(obj_exts & ~OBJEXTS_FLAGS_MASK);
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally
2025-09-15 20:09 [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Suren Baghdasaryan
2025-09-15 20:09 ` [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails Suren Baghdasaryan
@ 2025-09-15 20:09 ` Suren Baghdasaryan
2025-09-15 20:15 ` Shakeel Butt
2025-09-16 12:35 ` [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Vlastimil Babka
2 siblings, 1 reply; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-09-15 20:09 UTC (permalink / raw)
To: vbabka
Cc: akpm, cl, rientjes, roman.gushchin, harry.yoo, shakeel.butt,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, surenb, linux-mm, linux-kernel, stable
alloc_slab_obj_exts() should mark failed obj_exts vector allocations
independent on whether the vector is being allocated for a new or an
existing slab. Current implementation skips doing this for existing
slabs. Fix this by marking failed allocations unconditionally.
Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")
Reported-by: Shakeel Butt <shakeel.butt@linux.dev>
Closes: https://lore.kernel.org/all/avhakjldsgczmq356gkwmvfilyvf7o6temvcmtt5lqd4fhp5rk@47gp2ropyixg/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: stable@vger.kernel.org # v6.10+
---
mm/slub.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index af343ca570b5..cab4e7822393 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2029,8 +2029,7 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,
slab_nid(slab));
if (!vec) {
/* Mark vectors which failed to allocate */
- if (new_slab)
- mark_failed_objexts_alloc(slab);
+ mark_failed_objexts_alloc(slab);
return -ENOMEM;
}
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails
2025-09-15 20:09 ` [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails Suren Baghdasaryan
@ 2025-09-15 20:14 ` Shakeel Butt
0 siblings, 0 replies; 6+ messages in thread
From: Shakeel Butt @ 2025-09-15 20:14 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: vbabka, akpm, cl, rientjes, roman.gushchin, harry.yoo,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, linux-mm, linux-kernel, stable
On Mon, Sep 15, 2025 at 01:09:17PM -0700, Suren Baghdasaryan wrote:
> When object extension vector allocation fails, we set slab->obj_exts to
> OBJEXTS_ALLOC_FAIL to indicate the failure. Later, once the vector is
> successfully allocated, we will use this flag to mark codetag references
> stored in that vector as empty to avoid codetag warnings.
>
> slab_obj_exts() used to retrieve the slab->obj_exts vector pointer checks
> slab->obj_exts for being either NULL or a pointer with MEMCG_DATA_OBJEXTS
> bit set. However it does not handle the case when slab->obj_exts equals
> OBJEXTS_ALLOC_FAIL. Add the missing condition to avoid extra warning.
>
> Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")
> Reported-by: Shakeel Butt <shakeel.butt@linux.dev>
> Closes: https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> Cc: stable@vger.kernel.org # v6.10+
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally
2025-09-15 20:09 ` [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally Suren Baghdasaryan
@ 2025-09-15 20:15 ` Shakeel Butt
0 siblings, 0 replies; 6+ messages in thread
From: Shakeel Butt @ 2025-09-15 20:15 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: vbabka, akpm, cl, rientjes, roman.gushchin, harry.yoo,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, linux-mm, linux-kernel, stable
On Mon, Sep 15, 2025 at 01:09:18PM -0700, Suren Baghdasaryan wrote:
> alloc_slab_obj_exts() should mark failed obj_exts vector allocations
> independent on whether the vector is being allocated for a new or an
> existing slab. Current implementation skips doing this for existing
> slabs. Fix this by marking failed allocations unconditionally.
>
> Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")
> Reported-by: Shakeel Butt <shakeel.butt@linux.dev>
> Closes: https://lore.kernel.org/all/avhakjldsgczmq356gkwmvfilyvf7o6temvcmtt5lqd4fhp5rk@47gp2ropyixg/
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> Cc: stable@vger.kernel.org # v6.10+
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] fixes for slab->obj_exts allocation failure handling
2025-09-15 20:09 [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Suren Baghdasaryan
2025-09-15 20:09 ` [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails Suren Baghdasaryan
2025-09-15 20:09 ` [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally Suren Baghdasaryan
@ 2025-09-16 12:35 ` Vlastimil Babka
2 siblings, 0 replies; 6+ messages in thread
From: Vlastimil Babka @ 2025-09-16 12:35 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, cl, rientjes, roman.gushchin, harry.yoo, shakeel.butt,
alexei.starovoitov, usamaarif642, 00107082, souravpanda,
kent.overstreet, linux-mm, linux-kernel
On 9/15/25 22:09, Suren Baghdasaryan wrote:
> Fixes for several issues noticed by Shakeel pertaining to slab->obj_exts
> allocation failure handling in [1].
>
> Patchset is based on mm-new.
>
> Please route it via vbabka/slab.git as it's relevant to Alexei's patches
> in that branch.
Thanks, added to slab/for-6.18/fixes
> [1] https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/
>
> Suren Baghdasaryan (2):
> slab: prevent warnings when slab obj_exts vector allocation fails
> slab: mark slab->obj_exts allocation failures unconditionally
>
> mm/slab.h | 8 ++++++--
> mm/slub.c | 3 +--
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
>
> base-commit: 9a9318f95d63805868bd21e1381d68c3a75d03a7
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-16 12:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-15 20:09 [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Suren Baghdasaryan
2025-09-15 20:09 ` [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails Suren Baghdasaryan
2025-09-15 20:14 ` Shakeel Butt
2025-09-15 20:09 ` [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally Suren Baghdasaryan
2025-09-15 20:15 ` Shakeel Butt
2025-09-16 12:35 ` [PATCH 0/2] fixes for slab->obj_exts allocation failure handling Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox