]> git.proxmox.com Git - mirror_qemu.git/commit - target-i386/kvm.c
target-i386: kvm: cache KVM_GET_SUPPORTED_CPUID data
authorChao Peng <chao.p.peng@linux.intel.com>
Mon, 13 Jun 2016 02:21:27 +0000 (10:21 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 16 Jun 2016 16:39:04 +0000 (18:39 +0200)
commit494e95e910c0073705dc5dbcdb17c9b8709d59ec
tree8b8be61f0b6b4f8d5fd9d1a6cea91be87df12631
parent56af2dda98c5d71feb7ff7fcac7269a1071aec62
target-i386: kvm: cache KVM_GET_SUPPORTED_CPUID data

KVM_GET_SUPPORTED_CPUID ioctl is called frequently when initializing
CPU. Depends on CPU features and CPU count, the number of calls can be
extremely high which slows down QEMU booting significantly. In our
testing, we saw 5922 calls with switches:

    -cpu SandyBridge -smp 6,sockets=6,cores=1,threads=1

This ioctl takes more than 100ms, which is almost half of the total
QEMU startup time.

While for most cases the data returned from two different invocations
are not changed, that means, we can cache the data to avoid trapping
into kernel for the second time. To make sure the cache safe one
assumption is desirable: the ioctl is stateless. This is not true for
CPUID leaves in general (such as CPUID leaf 0xD, whose value depends
on guest XCR0 and IA32_XSS) but it is true of KVM_GET_SUPPORTED_CPUID,
which runs before there is a value for XCR0 and IA32_XSS.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
Message-Id: <1465784487-23482-1-git-send-email-chao.p.peng@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386/kvm.c