Re: [PATCH 1/1] sched.h: always_inline alloc_tag_{save|restore} to fix modpost warnings
From: Suren Baghdasaryan
Date: Thu Jul 04 2024 - 00:08:16 EST
On Wed, Jul 3, 2024 at 8:54 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, 3 Jul 2024 20:46:11 -0700 Suren Baghdasaryan <surenb@xxxxxxxxxx> wrote:
>
> > Ok, I confirmed that the warning is happening due to the access to
> > "current" from alloc_tag_save()/alloc_tag_restore() functions. I guess
> > when these functions access "thread_info" variable:
> > https://elixir.bootlin.com/linux/v6.10-rc6/source/arch/xtensa/include/asm/thread_info.h#L96,
> > compiler flags that because the variable is on the stack of an __init
> > function while alloc_tag_save()/alloc_tag_restore() when not inlined
> > are from .text section.
>
> Well, is the warning legitimate? I don't see why an automatic variable
> of an __init function should be considered to be .init storage - we can
> assume it won't become an invalid reference while the .init function is
> executing?
I don't think it's really a problem. __init function is executing, it
calls a function from .text (say alloc_tag_save() that was not
inlined) which in turn calls get_current(), which returns a pointer
somewhere inside __initdata. That should be fine since this can only
happen during init stage. If this call happens after init,
get_current() can't return a pointer from __initdata. If it does then
we have a much bigger problem.
>