Re: [PATCH] mm/compaction: remove unused variable sysctl_compact_memory

From: Vlastimil Babka
Date: Wed Mar 03 2021 - 13:55:42 EST


On 3/2/21 6:56 PM, Pintu Kumar wrote:
> The sysctl_compact_memory is mostly unsed in mm/compaction.c
> It just acts as a place holder for sysctl.
>
> Thus we can remove it from here and move the declaration directly
> in kernel/sysctl.c itself.
> This will also eliminate the extern declaration from header file.
> No functionality is broken or changed this way.
>
> Signed-off-by: Pintu Kumar <pintu@xxxxxxxxxxxxxx>
> Signed-off-by: Pintu Agarwal <pintu.ping@xxxxxxxxx>

You should be able to remove the variable completely and set .data to NULL in
the corresponding entry. The sysctl_compaction_handler doesn't access it at all.

Then you could do the same with drop_caches. Currently
drop_caches_sysctl_handler currently writes to it, but that can be avoided using
a local variable - see how sysrq_sysctl_handler avoids the global variable and
its corresponding .data field is NULL.

Vlastimil