Re: [PATCH v3 06/13] mm/slab: abstract slabobj_ext.ref access

From: Vlastimil Babka (SUSE)

Date: Wed Jul 29 2026 - 06:01:28 EST


On 7/29/26 08:18, Harry Yoo wrote:
>> diff --git a/mm/slab.h b/mm/slab.h
>> index 8f352d9f4d91..fbad99da093c 100644
>> --- a/mm/slab.h
>> +++ b/mm/slab.h
>> @@ -726,6 +726,8 @@ static inline void slab_obj_ext_set_objcg(struct slabobj_ext *obj_ext,
>> static inline union codetag_ref *
>> slab_obj_ext_codetag_ref(struct slab *slab, struct slabobj_ext *obj_ext)
>> {
>> + VM_WARN_ON_ONCE(!slab_obj_ext_has_codetag());
>> +
>> if (IS_ENABLED(CONFIG_MEMCG))
>> obj_ext += 1;
>>
>> ... and for objcg we would need to start passing slab pointer to
>> slab_obj_ext_objcg() and slab_obj_ext_set_objcg(). Hmm...
>
> But slab_obj_ext_codetag_ref() already takes the parameter to
> calculate offset. I think it's worth as it'll be optimized away on
> non-debug kerenels and there is no way to detect type confusion
> due to subtle errors in the objext layout.

OK, so updated to this. VM_WARN_ON_ONCE() added later.