Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
From: Lorenzo Stoakes (ARM)
Date: Thu Oct 15 2026 - 05:27:03 EST
On Wed, Oct 14, 2026 at 05:08:59PM +0300, Nimrod Oren wrote:
> min_free_kbytes is recalculated on memory hotplug and on THP sysfs
> writes. The new value comes from calculate_min_free_kbytes() or, while
> THP is enabled, from set_recommended_min_free_kbytes(). A value written
> to the vm.min_free_kbytes sysctl is replaced whenever the new value is
> higher, so a lower value does not stick. This matters most when THP is
> enabled on configurations with large pageblocks, where the new value
> can be excessive [1].
>
> Stop recalculating min_free_kbytes once a value has been written to the
> sysctl. Systems where the sysctl is never written keep the current
> behavior.
>
> Link: https://lore.kernel.org/r/20260716173504.760369-1-noren@xxxxxxxxxx/ [1]
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@xxxxxxxxxx/
> Signed-off-by: Nimrod Oren <noren@xxxxxxxxxx>
With an added, focused, paragraph about user-visible effects as requested
by Andrew (you can probably just reply to Andrew with something and he can
fold it in for you), LGTM and:
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Thanks for sticking with this! :)
> diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
> index 5b318d17aa4b..189fc57dac5f 100644
> --- a/Documentation/admin-guide/sysctl/vm.rst
> +++ b/Documentation/admin-guide/sysctl/vm.rst
> +By default, the kernel sets this value based on the amount of lowmem
> +and recalculates it on memory hotplug. When Transparent Hugepage (THP)
> +support is enabled through global or per-size controls, the kernel may
> +also raise it to help keep pageblocks free and reduce fragmentation for
> +THP allocations. Once a value is written to this file, the kernel no
> +longer adjusts it automatically.
> +
Ah nice to update this also!
--
Cheers, Lorenzo