Re: [PATCH v5 2/4] mm: huge_memory: refactor anon_enabled_store() with change_anon_orders()

Barry Song
2026-03-10T20:23:06Z

On Wed, Mar 11, 2026 at 4:17 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 11 Mar 2026 04:11:36 +0800 Barry Song <21cnbao@gmail.com> wrote:
>
> > > +static bool set_anon_enabled_mode(int order, enum anon_enabled_mode mode)
> > > +{
> > > + static unsigned long *enabled_orders[] = {
> > > + &huge_anon_orders_always,
> > > + &huge_anon_orders_madvise,
> > > + &huge_anon_orders_inherit,
> > > + };
> >
> > Is there a reason enabled_orders needs to be static?
> > Could it instead be allocated on the stack?
>
> Could, but then the array would be rebuilt each time the function is called.
> The idea here is to save a bit of runtime cost.

I see. My understanding is that this function is very cold,
so we don't really care about its performance. But I'm fine
with keeping it static if you prefer.

Thanks
Barry