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

From: Suren Baghdasaryan

Date: Tue Feb 24 2026 - 17:18:56 EST


On Tue, Feb 24, 2026 at 8:56 AM Suren Baghdasaryan <surenb@xxxxxxxxxx> wrote:
>
> On Tue, Feb 24, 2026 at 8:15 AM Suren Baghdasaryan <surenb@xxxxxxxxxx> wrote:
> >
> > On Tue, Feb 24, 2026 at 6:26 AM Harry Yoo <harry.yoo@xxxxxxxxxx> wrote:
> > >
> > > 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.
> >
> > Ah, thanks for the analyses! So, the fact that __alloc_empty_sheaf()
> > sets __GFP_NO_OBJ_EXT when allocating the sheaf leads to this issue
> > later on. Makes sense. I only wonder why I could not reproduce this...
> > Will try to find out later.
>
> The reason I could not reproduce this is because with my config
> free_empty_sheaf() just happen to never been called with SLAB_KMALLOC
> caches. Once I remove SLAB_KMALLOC condition in both
> __alloc_empty_sheaf() and free_empty_sheaf() I can reproduce the
> problem.
>
> >
> > > >
> > > > 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?
> >
> > I think that's the best fix and it makes logical sense.
> > alloc_slab_obj_exts() allocates obj_exts with __GFP_NO_OBJ_EXT and
> > then free_slab_obj_exts() does mark_objexts_empty() before freeing
> > them. Similarly, __alloc_empty_sheaf() allocates sheaves with
> > __GFP_NO_OBJ_EXT (for SLAB_KMALLOC objects), therefore
> > free_empty_sheaf() should also call mark_objexts_empty(sheaf) before
> > freeing them. mark_objexts_empty() currently accepts only slabobj_ext
> > but I think we can change that. I'll take a stab at it.
>
> I posted a fix at
> https://lore.kernel.org/all/20260224165250.1322946-1-surenb@xxxxxxxxxx/.

David,
Please use a fixed version at
https://lore.kernel.org/all/20260224221132.1702713-1-surenb@xxxxxxxxxx/
for testing.
Thanks,
Suren.

> David, please give it a try.
> Thanks,
> Suren.
>
>
>
> >
> > >
> > > /me goes to bed anyway
> > >
> > > --
> > > Cheers,
> > > Harry / Hyeonggon