Re: [PATCH v3] kvm: x86: mmu: Make NX huge page recovery period configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/10/21 03:06, Junaid Shahid wrote:
+			If the value is 0 (the default), KVM will pick a period based
+			on the ratio such that the entire set of pages can be zapped
+			in approximately 1 hour on average.

"such that *a* page will be zapped after approximately 1 hour on average".
The time needed to zap all the pages is actually infinite (ignoring the
effect of rounding, of course), because the number of zapped pages decreases
as the list becomes smaller.

+	if (!period && ratio)
+		period = 60 * 60 * 1000 / ratio;
+

Let's also bound this to one second:

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index a43bcd478194..f9f228963088 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -6232,8 +6232,11 @@ static long get_nx_lpage_recovery_timeout(u64 start_time)
 	uint ratio = READ_ONCE(nx_huge_pages_recovery_ratio);
 	uint period = READ_ONCE(nx_huge_pages_recovery_period_ms);
- if (!period && ratio)
+	if (!period && ratio) {
+		/* Make sure the period is not less than one second.  */
+		ratio = min(ratio, 3600u);
 		period = 60 * 60 * 1000 / ratio;
+	}
return READ_ONCE(nx_huge_pages) && ratio
 		? start_time + msecs_to_jiffies(period) - get_jiffies_64()

Queued with this change, thanks.

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux