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

From: Breno Leitao

Date: Mon Mar 09 2026 - 05:21:29 EST


On Sun, Mar 08, 2026 at 02:05:30PM -0700, Andrew Morton wrote:
> On Sat, 07 Mar 2026 08:08:06 -0800 Breno Leitao <leitao@xxxxxxxxxx> wrote:
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -316,6 +316,20 @@ static ssize_t enabled_show(struct kobject *kobj,
> > return sysfs_emit(buf, "%s\n", output);
> > }
> >
> > +enum anon_enabled_mode {
> > + ANON_ENABLED_ALWAYS,
> > + ANON_ENABLED_MADVISE,
> > + ANON_ENABLED_INHERIT,
> > + ANON_ENABLED_NEVER,
> > +};
>
> If we're feeling fancy we could use
>
> ANON_ENABLED_ALWAYS = 0,
> ...
>
> here, just to make it clear that we iterate over the enum values with
> an integer and we *require* those values.
>
> > +static bool change_anon_orders(int order, enum anon_enabled_mode mode)
> > +{
> > + static unsigned long *orders[] = {
> > + &huge_anon_orders_always,
> > + &huge_anon_orders_madvise,
> > + &huge_anon_orders_inherit,
> > + };
> > + bool changed = false;
> > + int i;
>
> enum anon_enabled_mode m;
>
> might be clearer here?

Thanks Andrew, let me respin it.

--breno