From nobody Mon Feb 9 17:56:32 2026 Received: from h7.fbrelay.privateemail.com (h7.fbrelay.privateemail.com [162.0.218.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F124413248; Tue, 20 Jan 2026 23:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.0.218.230 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768953277; cv=none; b=qf7DYYnvDrFnCajoAD/5H6ylMaz8SBDpFm+9PgkfVNLTGltRaQW34ZVZ2b5F/OALYUQCdx7LDr3KwqYDnGJ+DwjjJrg4rWoEb6jKmnfgCLSUGpiNAx/0tfsnvbEOcwrbSXY6Sd4hCsEF6bNXKRcVXQEqrw5NQYuaNKYGWLaxGSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768953277; c=relaxed/simple; bh=m0bqG1Uh+7GuYrIkTf7Q82+/GEWFCzT1VWr5lMZX2oM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CVSMeZWQpGLrIKaTB48I+plBIuzuBWLO7MtjMJHaygcK9UHXQaoM5DYCYeqGjdSczM9MvyMhEGbv6mOEhcKkvMMDaXO+dCOM1ReG3J7XGHs5umBVLdicO7Iva9EzMQPNph8iX9ixog53RPzXQZgsAljU7ecyA6GnVyWDn6+d2fQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=effective-light.com; spf=pass smtp.mailfrom=effective-light.com; arc=none smtp.client-ip=162.0.218.230 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=effective-light.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=effective-light.com Received: from MTA-14-3.privateemail.com (mta-14-1.privateemail.com [198.54.122.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by h7.fbrelay.privateemail.com (Postfix) with ESMTPSA id 4dwkQ85wSGz2xDR; Tue, 20 Jan 2026 18:42:24 -0500 (EST) Received: from mta-14.privateemail.com (localhost [127.0.0.1]) by mta-14.privateemail.com (Postfix) with ESMTP id 4dwkQ04TZBz3hhTQ; Tue, 20 Jan 2026 18:42:16 -0500 (EST) Received: from localhost.localdomain (bras-base-toroon4332w-grc-44-142-112-152-160.dsl.bell.ca [142.112.152.160]) by mta-14.privateemail.com (Postfix) with ESMTPA; Tue, 20 Jan 2026 18:42:03 -0500 (EST) From: Hamza Mahfooz To: kvm@vger.kernel.org Cc: Hamza Mahfooz , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86/mmu: move reused pages to the top of active_mmu_pages Date: Tue, 20 Jan 2026 18:41:15 -0500 Message-ID: <20260120234115.546590-1-someguy@effective-light.com> X-Mailer: git-send-email 2.52.0 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 X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" Move reused shadow pages to the head of active_mmu_pages in __kvm_mmu_get_shadow_page(). This will allow us to move towards more of a LRU approximation eviction strategy instead of just straight FIFO. Signed-off-by: Hamza Mahfooz --- arch/x86/kvm/mmu/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 02c450686b4a..2fe04e01863d 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2395,7 +2395,8 @@ static struct kvm_mmu_page *__kvm_mmu_get_shadow_page= (struct kvm *kvm, if (!sp) { created =3D true; sp =3D kvm_mmu_alloc_shadow_page(kvm, caches, gfn, sp_list, role); - } + } else if (!list_is_head(&sp->link, &kvm->arch.active_mmu_pages)) + list_move(&sp->link, &kvm->arch.active_mmu_pages); =20 trace_kvm_mmu_get_page(sp, created); return sp; --=20 2.52.0