From: Benjamin Lee McQueen <mcq@disroot.org>
To: akpm@linux-foundation.org, david@kernel.org
Cc: lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Benjamin Lee McQueen <mcq@disroot.org>
Subject: [PATCH] mm/vmpressure: scale window size based on machine memory and CPU count
Date: Fri, 27 Feb 2026 16:18:31 -0600 [thread overview]
Message-ID: <20260227221831.30346-1-mcq@disroot.org> (raw)
In-Reply-To: <20260227163333.6394-1-mcq@disroot.org>
on systems of different sizes, the fixed 512 page window may not
be suitable and cause excessive false positive memory pressure
notifications.
or should window size be capped to avoid excessive notification
delays on very large systems?
v2: better commit msg, also tried to fix the whitespace.
Signed-off-by: Benjamin Lee McQueen <mcq@disroot.org>
---
mm/vmpressure.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 3fbb86996c4d..925659f28dcb 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -32,10 +32,20 @@
* As the vmscan reclaimer logic works with chunks which are multiple of
* 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).
+ * Window size is now scaled based on RAM and CPU size, similarly to how
+ * vmstat checks them.
*/
-static const unsigned long vmpressure_win = SWAP_CLUSTER_MAX * 16;
+static unsigned long vmpressure_win;
+
+static int __init vmpressure_win_init(void)
+{
+ unsigned long mem = totalram_pages() >> (27 - PAGE_SHIFT);
+
+ vmpressure_win = SWAP_CLUSTER_MAX * max(16UL,
+ 2UL * fls(num_online_cpus()) * (1 + fls(mem)));
+ return 0;
+}
+core_initcall(vmpressure_win_init);
/*
* These thresholds are used when we account memory pressure through
--
2.51.0
next prev parent reply other threads:[~2026-02-27 22:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 16:33 Benjamin Lee McQueen
2026-02-27 20:28 ` Andrew Morton
2026-02-27 22:18 ` Benjamin Lee McQueen [this message]
2026-02-27 22:24 ` [PATCH v2] " Benjamin Lee McQueen
2026-02-27 22:15 [PATCH] " Benjamin Lee McQueen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260227221831.30346-1-mcq@disroot.org \
--to=mcq@disroot.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox