Re: [PATCH v2] mm: compaction: optimize compact_memory to comply with the admin-guide

From: Andrew Morton
Date: Tue May 02 2023 - 16:50:15 EST


On Fri, 28 Apr 2023 11:58:48 +0100 Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> wrote:

> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -1736,6 +1736,7 @@ static int sysctl_compact_unevictable_allowed __read_mostly = CONFIG_COMPACT_UNE
> > */
> > static unsigned int __read_mostly sysctl_compaction_proactiveness = 20;
> > static int sysctl_extfrag_threshold = 500;
> > +static int sysctl_compact_memory;
> >
>
> __read_mostly but that aside, it's only used in
> sysctl_compaction_handler so could also be declared as static within
> that function. That way if CONFIG_SYSCTL is not set, it should be
> guaranteed that the compiler does not save storage for it.

but

static struct ctl_table vm_compaction[] = {
{
.procname = "compact_memory",
.data = &sysctl_compact_memory,
.maxlen = sizeof(int),
.mode = 0200,
.proc_handler = sysctl_compaction_handler,
},


I'll add the __read_mostly, thanks.