mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] mm: vmpressure: scale sampling window with machine size
@ 2026-07-15 14:36 deepakraog
  2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: deepakraog @ 2026-07-15 14:36 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kernel

The vmpressure window size was fixed at 512 pages (SWAP_CLUSTER_MAX * 16).
Scale it at boot from total memory and CPU count using the same fls-based
formula as vmstat per-zone thresholds, clamped between 128 and 2048 pages.

Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
---
 mm/vmpressure.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index f053554e5..8925d4ad3 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -33,9 +33,29 @@
  * SWAP_CLUSTER_MAX, it makes sense to use it for the window size as well.
  *
  * TODO: Make the window size depend on machine size, as we do for vmstat
- * thresholds. Currently we set it to 512 pages (2MB for 4KB pages).
+ * thresholds. Scales with CPU count and total memory at boot.
  */
-static const unsigned long vmpressure_win = SWAP_CLUSTER_MAX * 16;
+static unsigned long vmpressure_win;
+
+static unsigned long __init vmpressure_window_size(void)
+{
+	unsigned long win;
+	int mem;
+
+	mem = totalram_pages() >> (27 - PAGE_SHIFT);
+	win = SWAP_CLUSTER_MAX * (unsigned long)fls(num_online_cpus()) *
+	      (1 + fls(mem));
+	win = max(win, SWAP_CLUSTER_MAX * 4UL);
+	win = min(win, SWAP_CLUSTER_MAX * 64UL);
+	return win;
+}
+
+static int __init vmpressure_win_init(void)
+{
+	vmpressure_win = vmpressure_window_size();
+	return 0;
+}
+core_initcall(vmpressure_win_init);
 
 /*
  * These thresholds are used when we account memory pressure through
-- 
Deepak Rao Gaikwad


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-15 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 14:36 [PATCH 1/4] mm: vmpressure: scale sampling window with machine size deepakraog
2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
2026-07-15 14:36 ` [PATCH 3/4] mm: vrealloc: grow vm_area mappings in place deepakraog
2026-07-15 14:36 ` [PATCH 4/4] ceph: release unused cap reservation on readdir error deepakraog
2026-07-15 17:51   ` Viacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox