* Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
2026-10-14 14:08 [PATCH] mm: stop recalculating min_free_kbytes once set by userspace Nimrod Oren
@ 2026-10-14 20:32 ` Johannes Weiner
2026-10-14 20:34 ` Zi Yan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Johannes Weiner @ 2026-10-14 20:32 UTC (permalink / raw)
To: Nimrod Oren
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Jonathan Corbet, Shuah Khan,
Randy Dunlap, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts,
Dev Jain, Barry Song, Lance Yang, Usama Arif, Kiryl Shutsemau,
Brendan Jackman, David Laight, linux-mm, linux-doc, linux-kernel
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@nvidia.com/ [1]
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@kernel.org/
> Signed-off-by: Nimrod Oren <noren@nvidia.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
2026-10-14 14:08 [PATCH] mm: stop recalculating min_free_kbytes once set by userspace Nimrod Oren
2026-10-14 20:32 ` Johannes Weiner
@ 2026-10-14 20:34 ` Zi Yan
2026-10-14 21:48 ` Andrew Morton
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Zi Yan @ 2026-10-14 20:34 UTC (permalink / raw)
To: Nimrod Oren
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Jonathan Corbet, Shuah Khan,
Randy Dunlap, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Kiryl Shutsemau,
Brendan Jackman, Johannes Weiner, David Laight, linux-mm,
linux-doc, linux-kernel
On 14 Oct 2026, at 10:08, 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@nvidia.com/ [1]
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@kernel.org/
> Signed-off-by: Nimrod Oren <noren@nvidia.com>
> ---
> Documentation/admin-guide/sysctl/vm.rst | 7 +++++++
> mm/khugepaged.c | 7 +------
> mm/page_alloc.c | 6 +-----
> 3 files changed, 9 insertions(+), 11 deletions(-)
>
Acked-by: Zi Yan <ziy@nvidia.com>
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
2026-10-14 14:08 [PATCH] mm: stop recalculating min_free_kbytes once set by userspace Nimrod Oren
2026-10-14 20:32 ` Johannes Weiner
2026-10-14 20:34 ` Zi Yan
@ 2026-10-14 21:48 ` Andrew Morton
2026-10-15 7:10 ` Vlastimil Babka (SUSE)
2026-10-15 9:19 ` Lorenzo Stoakes (ARM)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2026-10-14 21:48 UTC (permalink / raw)
To: Nimrod Oren
Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jonathan Corbet, Shuah Khan, Randy Dunlap, Zi Yan, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
Usama Arif, Kiryl Shutsemau, Brendan Jackman, Johannes Weiner,
David Laight, linux-mm, linux-doc, linux-kernel
On Wed, 14 Oct 2026 17:08:59 +0300 Nimrod Oren <noren@nvidia.com> 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.
This problem lies somewhere in the range of "minor annoyance" to
"catastrophically horrible", but it isn't clear where in that range it
falls.
So can we please can we have a paragraph which explains the real-world
userspace-visible runtime effects of this problem?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
2026-10-14 14:08 [PATCH] mm: stop recalculating min_free_kbytes once set by userspace Nimrod Oren
` (2 preceding siblings ...)
2026-10-14 21:48 ` Andrew Morton
@ 2026-10-15 7:10 ` Vlastimil Babka (SUSE)
2026-10-15 9:19 ` Lorenzo Stoakes (ARM)
4 siblings, 0 replies; 6+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-10-15 7:10 UTC (permalink / raw)
To: Nimrod Oren, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jonathan Corbet
Cc: Shuah Khan, Randy Dunlap, Zi Yan, Baolin Wang, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Kiryl Shutsemau, Brendan Jackman, Johannes Weiner, David Laight,
linux-mm, linux-doc, linux-kernel
On 10/14/26 16:08, 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@nvidia.com/ [1]
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@kernel.org/
> Signed-off-by: Nimrod Oren <noren@nvidia.com>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm: stop recalculating min_free_kbytes once set by userspace
2026-10-14 14:08 [PATCH] mm: stop recalculating min_free_kbytes once set by userspace Nimrod Oren
` (3 preceding siblings ...)
2026-10-15 7:10 ` Vlastimil Babka (SUSE)
@ 2026-10-15 9:19 ` Lorenzo Stoakes (ARM)
4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-10-15 9:19 UTC (permalink / raw)
To: Nimrod Oren
Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jonathan Corbet, Shuah Khan, Randy Dunlap, Zi Yan, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
Usama Arif, Kiryl Shutsemau, Brendan Jackman, Johannes Weiner,
David Laight, linux-mm, linux-doc, linux-kernel
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@nvidia.com/ [1]
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@kernel.org/
> Signed-off-by: Nimrod Oren <noren@nvidia.com>
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@kernel.org>
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
^ permalink raw reply [flat|nested] 6+ messages in thread