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

Andrew Morton
2026-03-10T20:17:28Z

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.