From nobody Tue Apr 7 17:13:29 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 7922F396D2E for ; Thu, 26 Feb 2026 22:23:18 +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=1772144600; cv=none; b=MCYhbqnBhM36nv+2b2jFGkM7NyUQc/XL/pvf6wGln3E3o3SVnfg5pU5wd372GxfIuFoLvmQXkJbCBxHJRAx4y7V3BW8m05UKrluiZ/pgfmpXllagc7kkLcFb2pVGpYeYRrH/e+YWTluz3g6Slplh6jGtMc7dF2+5KCo1vTrntUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772144600; c=relaxed/simple; bh=VeWQNZuF3GodHUOAGR4MKmiuZROjs+XpxXoFLAB/Rw8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bWqkAr15YyBY6ztOvHSs6qqcXTuof3jRwpnrAOTGFep0QdILPSX9LbrCQJJCbvnhc3jLgz7SbU94aG2xX7jELLOd3qlmND+wPZe7Ms+qD8eKXwizpk19+bIzVdSmF2chEvpNmKQxXPPxNcQBPOFKhvNI5TbWkgjWbNNOi3joRF4= 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=VEjBiX7K; 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="VEjBiX7K" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 9B8952620C; Thu, 26 Feb 2026 23:23:10 +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 CbaE-xR9lXVp; Thu, 26 Feb 2026 23:23:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1772144590; bh=VeWQNZuF3GodHUOAGR4MKmiuZROjs+XpxXoFLAB/Rw8=; h=From:To:Cc:Subject:Date; b=VEjBiX7Kin174vBmtZiZyEVT6fT+zbstSrNpvi08NaCuanFsUdK3gp/jKvFQsPIbw pnKNrlFoQYhoauU6+EADw1Lf6C8rYqSXSJ9IQzUdLSbR6lMie6nyXProMfCxVQS/GA 6YL1LNiGghz3pqmL3vZoOlB7FDbl+tGOlXbJG6GxOhJGVt9A/1hw9phvHwLMoXd+jZ ra48h0wxygrv1T3qz5gO1m992NzwP+H16Nh3tQM1Nblz7Ee/IbSGvF8d/MWR/N+fpi KPuB3k2CFtKYSTCLW3IaOcsCB+J3TWLnwQtEzaHpE77WgE8opiXZti8jG5xabgBgZ4 cxnzTU2H5fDeA== From: Benjamin Lee McQueen To: akpm@linux-foundation.org Cc: david@kernel.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Benjamin Lee McQueen Subject: [PATCH] mm/vmpressure: scale window size based on machine memory Date: Thu, 26 Feb 2026 16:22:46 -0600 Message-ID: <20260226222246.4618-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" vmpressure's window size was fixed at 512 pages regardless of machine size. This fix, from a TODO scales the window size based on RAM size of the machi= ne. The method of scaling is similar to vmstat's scaling but based on RAM alone. Signed-off-by: Benjamin Lee McQueen --- mm/vmpressure.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 3fbb86996c4d..1d7b5d9e4351 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -32,11 +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). + * The window size scales with machine memory using logarithmic scaling + * Smaller machines get smaller window size, while larger ones, for + * example, get proportionally larger window size. */ -static const unsigned long vmpressure_win =3D SWAP_CLUSTER_MAX * 16; +static unsigned long vmpressure_win; =20 +static int __init vmpressure_win_init(void) +{ + unsigned long mem =3D totalram_pages() >> (27 - PAGE_SHIFT); + + vmpressure_win =3D SWAP_CLUSTER_MAX * max(16UL, (unsigned long)fls(mem) *= 8); + return 0; +} +core_initcall(vmpressure_win_init); /* * These thresholds are used when we account memory pressure through * scanned/reclaimed ratio. The current values were chosen empirically. In --=20 2.53.0