From mboxrd@z Thu Jan 1 00:00:00 1970 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 1BB5886323 for ; Sat, 28 Feb 2026 00:52:09 +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=1772239932; cv=none; b=TMk8iulae1ah6nYHlPXYpP4p2ajLbD9upDYIKxBQYsHKUJdVYrv4bY29cRjgiBHlYfNCu+FzDFyBherFKmbVx3QmwTAEU5gCwEgQpZYZriJK8XXC7s32WSaN7lMZgI8EPIPwiXKvcyW9qCMKO5gnjTQq4E+ruxKXXtGKNIOpaPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772239932; c=relaxed/simple; bh=SO4P9lTr7kXpn3uXHaW9DqgCN+bZeD2qLCDUrth50ZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ISR85DuwzXeplMswaNsWyl7d6FsUD8Ga89hsdv/zMdLHOPxtOY3Zw1lV+VNEn8aQ7SZaexF79fLNoXmoKr/hPxrJrcsNjdHL5nQ3Q+il5Z/iRm1MqohCSGgK6nkzg0E8RPFiKjI//QDIRAbX+7y0zJ9VQ1Gxq6BirgTu0gO5N2w= 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=mNLKxexx; 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="mNLKxexx" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 70ACC26F22; Sat, 28 Feb 2026 01:52:08 +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 NJgMBd4AjeyX; Sat, 28 Feb 2026 01:52:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1772239927; bh=SO4P9lTr7kXpn3uXHaW9DqgCN+bZeD2qLCDUrth50ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mNLKxexx3w2Sy7feiSp/4TjbEFtWDKDME6cOnKdKzogMbWBPZQZlPHrvkJQAWXKup kHhY0L7ZdIpZt3dtC1M8KIdD8j+ks7SBPskUsJocUowm6TEsS7sDKIAph1931DjXWE mC7AdsmbCyJLbHRCevZauoBdDLXYJUnaOQuveV9ph08K2cSO7bUcrLfzlTFHvuwsbx oVosavZhSKkdm2UrNvXnleHNGHYkldNu7qAC30E2FGkvJYJZoum8D1UsUjO7EjHfg9 XlfyDw0g1KHjxxmBZ9ofUP+l2oi4fR+zue6kcavEi4SGkG3QmegYUeGzHCPjunvDWw CS/OxdqUqYeRQ== 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 18:51:44 -0600 Message-ID: <20260228005144.47807-1-mcq@disroot.org> In-Reply-To: <20260227122857.dca67a5f281e39a3e78acc74@linux-foundation.org> References: <20260227122857.dca67a5f281e39a3e78acc74@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 = 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.53.0