Re: [7.0-rc1] codetag: kernel warning "alloc_tag was not set" during boot

From: Harry Yoo

Date: Tue Feb 24 2026 - 09:26:48 EST


On Tue, Feb 24, 2026 at 11:16:12PM +0900, Harry Yoo wrote:
> Just sharing updates on this before going to bed...
>
> I was able to reproduce it on my machine I have a working fix
> (nowhere close to upstream quality, though)
>
> The reason why we're seeing "alloc_tag not was set" is
> because SLUB allocates empty sheaves for kmalloc
> with __GFP_NO_OBJ_EXT and it doesn't teach memory profiling
> how to handle this when such sheaves are freed.
>
> When __GFP_NO_OBJ_EXT is used in alloc_slab_obj_exts(), it later
> avoids this "alloc_tag was not set" warning by marking alloc_tags
> empty in free_slab_obj_exts(), just before freeing obj_exts.
>
> And we don't handle this when allocating freeing sheaves
> that were allocated with __GFP_NO_OBJ_EXT.
>
> Passing __GFP_NO_OBJ_EXT skips 1) allocation of obj_exts,
> and 2) alloc_tag_add() even when obj_exts is already allocated,
> and this confuses memory profiling later.
>
> I'm adding the fix I have now. (I guess Suren might have some preference
> on how to solve it though)
>
> 1. mark obj_exts allocation failure when slab has no obj_exts and
> gfp flag has __GFP_NO_OBJ_EXT, so that a later obj_exts allocation
> will mark alloc_tags empty.
>
> 2. Set alloc_tag when obj_exts is allocated available,
> even when __GFP_NO_OBJ_EXT is set.
>
> Because it's already allocated, we don't have to worry about
> recursive allocation.

Wait, isn't it much simpler to just do mark_objexts_empty(sheaf);
just before freeing sheaves, if s->flags has SLAB_KMALLOC?

/me goes to bed anyway

--
Cheers,
Harry / Hyeonggon