Re: [PATCH v2 1/6] lib/stackdepot: allow requesting early initialization dynamically

From: Marco Elver
Date: Wed Mar 02 2022 - 13:16:19 EST


On Wed, 2 Mar 2022 at 19:02, Vlastimil Babka <vbabka@xxxxxxx> wrote:
[...]
> > Similarly, for stack_depot_want_early_init, where instead you could
> > simply provide stack_depot_want_early_init() as a function, which simply
> > sets a boolean __stack_depot_want_early_init. If !STACKDEPOT, it'll also
> > just be a no-op function.
>
> Yeah, makes sense. I guess I have patch 3/6 wrong now anyway as with
> !STACKDEPOT it should fail linking due to missing stack_depot_want_early_init...

Right. It probably still worked because the compiler likely optimizes
out the dead call, but you never know...

> >> +bool stack_depot_want_early_init = false;
> >> +
> >
> > This can be __initdata, right?
>
> I initially thought so too, but in include/linux/init.h found
> * Don't forget to initialize data not at file scope, i.e. within a function,
> * as gcc otherwise puts the data into the bss section and not into the init
> * section.
> But maybe that's just outdated as everyone seems to init them at file scope.

I think that comment is just about static variables inside functions?
Here it's at file scope, so that caveat shouldn't apply. As an aside,
you could omit '= false' because it'd zero-init by default.

Thanks,
-- Marco