Skip to contentSkip to conversation

x86/kvm: Don't waste memory if kvmclock is disabled

PATCH Applied Wanpeng Li 2 participants 2 messages Feb 22, 2022 – Feb 25, 2022

Subsystems (3)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 x86/kvm: Don't waste memory if kvmclock is disabled

From: Wanpeng Li <[email protected]>

Even if "no-kvmclock" is passed in cmdline parameter, the guest kernel still allocates hvclock_mem which is scaled by the number of vCPUs, let's check kvmclock enable in advance to avoid this memory waste.

---
 arch/x86/kernel/kvmclock.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/kvmclock.c +3 -0
index a35cbf9107af..44ed677d401f 100644
@@ -239,6 +239,9 @@ static void __init kvmclock_init_mem(void)
 
 static int __init kvm_setup_vsyscall_timeinfo(void)
 {
+	if (!kvmclock)
+		return 0;
+
 	kvmclock_init_mem();
 
 #ifdef CONFIG_X86_64
Signature · 1 line
2.25.1