aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWanpeng Li <[email protected]>2022-02-22 01:02:03 -0800
committerPaolo Bonzini <[email protected]>2022-02-25 10:09:34 -0500
commit3c51d0a6c761c2025c6db1ed4d3a7273167bf899 (patch)
tree8810288e3d48c3a5997391d3840d05f05ee1a94e
parent40cd58dbf121e1d0c18f1bd4dd10335ae45a28fc (diff)
x86/kvm: Don't waste memory if kvmclock is disabled
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. Signed-off-by: Wanpeng Li <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
-rw-r--r--arch/x86/kernel/kvmclock.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index a35cbf9107af..44ed677d401f 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -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