* [merged mm-stable] mm-stop-recalculating-min_free_kbytes-once-set-by-userspace.patch removed from -mm tree
@ 2026-10-24 9:01 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-24 9:01 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, usama.arif, surenb, skhan, ryan.roberts,
rppt, rdunlap, nico.pache, mhocko, ljs, liam, lance.yang, kas,
hannes, dev.jain, david.laight.linux, david, corbet,
brendan.jackman, baolin.wang, baohua, noren, akpm
The quilt patch titled
Subject: mm: stop recalculating min_free_kbytes once set by userspace
has been removed from the -mm tree. Its filename was
mm-stop-recalculating-min_free_kbytes-once-set-by-userspace.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nimrod Oren <noren@nvidia.com>
Subject: mm: stop recalculating min_free_kbytes once set by userspace
Date: Wed, 14 Oct 2026 17:08:59 +0300
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].
For example, with default arm64 pageblock sizes, the THP recommendation
can reach 5.5 GiB per eligible zone with 64 KiB pages vs 22 MiB with 4 KiB
pages. This keeps a significant amount of memory free, reducing what
applications can use and triggering reclaim much earlier. Users can lower
vm.min_free_kbytes to avoid this, but the lower value only sticks until
the next recalculation.
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/20261014140859.1006967-1-noren@nvidia.com
Link: https://lore.kernel.org/r/20260716173504.760369-1-noren@nvidia.com/ [1]
Signed-off-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://lore.kernel.org/r/d202dcc3-d7d7-4e98-a9a5-3137cfbfd041@kernel.org/
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: David Laight <david.laight.linux@gmail.com>
---
Documentation/admin-guide/sysctl/vm.rst | 7 +++++++
mm/khugepaged.c | 7 +------
mm/page_alloc.c | 6 +-----
3 files changed, 9 insertions(+), 11 deletions(-)
--- a/Documentation/admin-guide/sysctl/vm.rst~mm-stop-recalculating-min_free_kbytes-once-set-by-userspace
+++ a/Documentation/admin-guide/sysctl/vm.rst
@@ -539,6 +539,13 @@ watermark[WMARK_MIN] value for each lowm
Each lowmem zone gets a number of reserved free pages based
proportionally on its size.
+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.
+
Some minimal amount of memory is needed to satisfy PF_MEMALLOC
allocations; if you set this to lower than 1024KB, your system will
become subtly broken, and prone to deadlock under high loads.
--- a/mm/khugepaged.c~mm-stop-recalculating-min_free_kbytes-once-set-by-userspace
+++ a/mm/khugepaged.c
@@ -3144,13 +3144,8 @@ void set_recommended_min_free_kbytes(voi
(unsigned long) nr_free_buffer_pages() / 20);
recommended_min <<= (PAGE_SHIFT-10);
- if (recommended_min > min_free_kbytes) {
- if (user_min_free_kbytes >= 0)
- pr_info_ratelimited("raising min_free_kbytes from %d to %lu to help transparent hugepage allocations\n",
- min_free_kbytes, recommended_min);
-
+ if (user_min_free_kbytes < 0 && recommended_min > min_free_kbytes)
min_free_kbytes = recommended_min;
- }
update_wmarks:
setup_per_zone_wmarks();
--- a/mm/page_alloc.c~mm-stop-recalculating-min_free_kbytes-once-set-by-userspace
+++ a/mm/page_alloc.c
@@ -6722,12 +6722,8 @@ void calculate_min_free_kbytes(void)
lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
- if (new_min_free_kbytes > user_min_free_kbytes)
+ if (user_min_free_kbytes < 0)
min_free_kbytes = clamp(new_min_free_kbytes, 128, 262144);
- else
- pr_warn_ratelimited("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
- new_min_free_kbytes, user_min_free_kbytes);
-
}
int __meminit init_per_zone_wmark_min(void)
_
Patches currently in -mm which might be from noren@nvidia.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-24 9:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-24 9:01 [merged mm-stable] mm-stop-recalculating-min_free_kbytes-once-set-by-userspace.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.