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

From: Andrew Morton

Date: Tue Mar 10 2026 - 16:18:46 EST


On Wed, 11 Mar 2026 04:11:36 +0800 Barry Song <21cnbao@xxxxxxxxx> 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.