From nobody Sat Apr 18 11:08:47 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B3203559C0 for ; Fri, 27 Feb 2026 22:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772231074; cv=none; b=kdNdKpj5IhJrJDFxd7OfDmDjGnyid68QIixcDOVTgvAEvc/ZebIlM5VJala3HZyPNKqTKB7L1JHH+AcEruPcF5xfkSQTXeVSA7JPWMs7p2ynkc/skwtUx3Q+WLrrmdipWgtc9GwLqfYzQgxAOohjlAw+O2YpLIv3NNsuKyerNcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772231074; c=relaxed/simple; bh=SO4P9lTr7kXpn3uXHaW9DqgCN+bZeD2qLCDUrth50ZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+4WO+iNLF43+p4Y+KfgQ5O8WMyd2SlXo1Oy2hvGC11GlT+CLgtFZM/OeHGp76Fuwom9Ly7jGTSltEi8nPS0SziRAhSattoAVqynulJAM7mOYwP2fZMxnC05kiHg3q+f6oTsmS/DgmvzHaB/zg5ctgxPxiRitTXxD6VI9FbsEZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=kqcCumOx; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="kqcCumOx" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B96242675F; Fri, 27 Feb 2026 23:24:24 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OIZYeyILiTmy; Fri, 27 Feb 2026 23:24:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1772231064; bh=SO4P9lTr7kXpn3uXHaW9DqgCN+bZeD2qLCDUrth50ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kqcCumOxei8B6l7AtoUXXov41GNcAv8qElgwy0aOZou+Nkp405czy8EBF31mtieh4 GiWCaaG8KP90AvipNY3IuAqMoqxAuskX7JgcKlQN0nbpuTVvgBFZb1zPe2UzpfPp08 rclF8QjAI0rX/Vd4qxt5VfzUb86s3q7reXC1XVJzQdpDBU0ATYeII6qNe9H2O5FTEf PcD9ybWgsZMQ6QF1ZDDMsW+K7cYWj7nLO0LlroOZOjlcvP6yOzyqXmIIR2Wt8FtNVj iRRDNxKTFlnLLOPUuCDVfNqYwbHJOxAJcfcybh8TcaNtMDTfJZfQIeznouVAydFsmV Vo6fTYj9QozVg== From: Benjamin Lee McQueen 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 Subject: [PATCH v2] mm/vmpressure: scale window size based on machine memory and CPU count Date: Fri, 27 Feb 2026 16:24:07 -0600 Message-ID: <20260227222407.30999-1-mcq@disroot.org> In-Reply-To: <20260227163333.6394-1-mcq@disroot.org> References: <20260227163333.6394-1-mcq@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. also my bad for the multiple sends, i couldn't get the format right.. Signed-off-by: Benjamin Lee McQueen --- 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 =3D SWAP_CLUSTER_MAX * 16; +static unsigned long vmpressure_win; + +static int __init vmpressure_win_init(void) +{ + unsigned long mem =3D totalram_pages() >> (27 - PAGE_SHIFT); + + vmpressure_win =3D SWAP_CLUSTER_MAX * max(16UL, + 2UL * fls(num_online_cpus()) * (1 + fls(mem))); + return 0; +} +core_initcall(vmpressure_win_init); =20 /* * These thresholds are used when we account memory pressure through --=20 2.53.0