fixes for slab->obj_exts allocation failure handling
Subsystems (3)
cover fixes for slab->obj_exts allocation failure handling
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
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH 1/2 slab: prevent warnings when slab obj_exts vector allocation fails
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.
--- mm/slab.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
mm/slab.h +6 -2
@@ -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 );
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH 1/2] slab: prevent warnings when slab obj_exts vector allocation fails
Quoted 10 lines · Suren Baghdasaryan
When object extension vector allocation fails, we set
slab->obj_extstoOBJEXTS_ALLOC_FAILto 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 theslab->obj_extsvector pointer checksslab->obj_extsfor being either NULL or a pointer withMEMCG_DATA_OBJEXTSbit set. However it does not handle the case whenslab->obj_extsequalsOBJEXTS_ALLOC_FAIL. Add the missing condition to avoid extra warning.
Quoted 5 lines
Fixes 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")Reported-by Shakeel Butt <[email protected]>Closes https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/ open hereSigned-off-by Suren Baghdasaryan <[email protected]>Cc [email protected] # v6.10+
PATCH 2/2 slab: mark slab->obj_exts allocation failures unconditionally
In reply to Suren Baghdasaryanalloc_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.
--- mm/slub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/slub.c +1 -2
@@ -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 ; }
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH 2/2] slab: mark slab->obj_exts allocation failures unconditionally
Quoted 10 lines · Suren Baghdasaryan
alloc_slab_obj_exts()should mark failedobj_extsvector 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 <[email protected]>Closes https://lore.kernel.org/all/avhakjldsgczmq356gkwmvfilyvf7o6temvcmtt5lqd4fhp5rk@47gp2ropyixg/ open hereSigned-off-by Suren Baghdasaryan <[email protected]>Cc [email protected] # v6.10+
Quoted 7 lines · Suren Baghdasaryan
Fixes for several issues noticed by Shakeel pertaining to
slab->obj_extsallocation 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
Quoted 12 lines
[1] https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/
Suren Baghdasaryan (2):
slab: prevent warnings when slabobj_extsvector allocation fails
slab: markslab->obj_extsallocation failures unconditionallymm/slab.h | 8 ++++++-- mm/slub.c | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-)base-commit:
9a9318f95d63805868bd21e1381d68c3a75d03a7