Re: [PATCH] mm: compaction: limit illegal input parameters of compact_memory interface

From: Luis Chamberlain
Date: Fri Mar 03 2023 - 17:21:10 EST


On Fri, Mar 03, 2023 at 08:44:41AM +0800, ye.xingchen@xxxxxxxxxx wrote:
> From: Minghao Chi <chi.minghao@xxxxxxxxxx>
>
> Available only when CONFIG_COMPACTION is set. When 1 is written to
> the file, all zones are compacted such that free memory is available
> in contiguous blocks where possible.
> But echo others-parameter > compact_memory, this function will be
> triggered by writing parameters to the interface.
>
> Applied this patch,
> sh/$ echo 1.1 > /proc/sys/vm/compact_memory
> sh/$ sh: write error: Invalid argument
> The start and end time of printing triggering compact_memory.
>
> Signed-off-by: Minghao Chi <chi.minghao@xxxxxxxxxx>
> Signed-off-by: Ye Xingchen <ye.xingchen@xxxxxxxxxx>

Do a huge favor and while you're at it split this into two patches,
one which takes this out of kernel/sysctl.c and move it to
mm/compaction.c and a second one that does your change here.

Since kernel/sysctl.c is being trimmed you can base your changes on
sysctl-next [0] and I'm happy to take in there if Andrew agrees to it.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next

Luis