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 9CA043242BD for ; Fri, 27 Feb 2026 16:33:51 +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=1772210034; cv=none; b=PTcsk0vrUaxhUVavFj2LoMjBxaJuOFl6unruvlxmS1bW6nIcLha80GPuwxWUHLswnxmYA3epdS/ASHu13iv4bakZ9v1Bnk48E3V7nrk4QstyjHi3X8C0G9hoX5ngVLB0ToCPdqZHxVwf31JN8BV1299gjwEzKxR6ORKh6/ACHXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772210034; c=relaxed/simple; bh=1BRDZ6KfArhSOUWxCOXleAvjBFxgRYA9XpavAbLIS/k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WeP27hZlSEsBqrVjy4/rr1KSwzucWgv8eBz3J3UfFDwNn2ACuzDZqpwv6FS2yQMHJGCZ+AAktB4bVtifYZPLLGw0kJfMhAga9GtrRBhgxSwAjwjL1pBvzVQmmhVFx63UX1kDfrLqRf1kmMFfo7hjFEcfALTi+uDir5BQy5028j4= 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=INYuLY70; 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="INYuLY70" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id D098C260B7; Fri, 27 Feb 2026 17:33:48 +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 eluT5zvIjBcL; Fri, 27 Feb 2026 17:33:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1772210028; bh=1BRDZ6KfArhSOUWxCOXleAvjBFxgRYA9XpavAbLIS/k=; h=From:To:Cc:Subject:Date; b=INYuLY70P6XaGhmxnysrHz6mAq1IExmenhyzL+pk8dpVNsCxp4IRPeEYbCEO/W3YH 88Eb/kxtS5OAQ3DuXzvn/JtHJnucRgt6oAjdiq+fj8UVlL7me5zEJJzcbQ/9gsYU8e YPZ7804Ze7DP0OEtYmbmdTuuD/UYYaDn+ylMPN65BJRLZX3cSByoVLNbhf+v65tPUb H6QU5QOozrbLkWZ8uBFWxkl8PUrHa0nkV49VTrOL/y4huv+iC3T+UcKNviqZp+x3E2 7O1U/VPSv/NQfYYvjJEDQr9ll4magRWWmWKVPouHkM+xYVuXBMA4heUHuqMY0qSGQd Lh2aRdt7pPSRQ== 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] mm/vmpressure: scale window size based on machine memory and CPU count Date: Fri, 27 Feb 2026 10:33:33 -0600 Message-ID: <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: 8bit the vmpressure window size was recently fixed at 512 pages regardless of machine size, this patch makes it scale based on the machine memory and CPU count. 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..b2989c70dd39 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