]> git.proxmox.com Git - qemu.git/commit
target-i386: yield to another VCPU on PAUSE
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 20 Nov 2013 11:54:02 +0000 (12:54 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 Nov 2013 16:39:20 +0000 (17:39 +0100)
commitb5fc314bcbb80f76b8deaf23a4c45767b87f750b
tree11abb9fb6a5fef0fdeddec46b4661d01beef076d
parentfbdcec5c487685b46e78f1e40a236ebf83f862fa
target-i386: yield to another VCPU on PAUSE

After commit b1bbfe7 (aio / timers: On timer modification, qemu_notify
or aio_notify, 2013-08-21) FreeBSD guests report a huge slowdown.

The problem shows up as soon as FreeBSD turns out its periodic (~1 ms)
tick, but the timers are only the trigger for a pre-existing problem.

Before the offending patch, setting a timer did a timer_settime system call.

After, setting the timer exits the event loop (which uses poll) and
reenters it with a new deadline.  This does not cause any slowdown; the
difference is between one system call (timer_settime and a signal
delivery (SIGALRM) before the patch, and two system calls afterwards
(write to a pipe or eventfd + calling poll again when re-entering the
event loop).

Unfortunately, the exit/enter causes the main loop to grab the iothread
lock, which in turns kicks the VCPU thread out of execution.  This
causes TCG to execute the next VCPU in its round-robin scheduling of
VCPUS.  When the second VCPU is mostly unused, FreeBSD runs a "pause"
instruction in its idle loop which only burns cycles without any
progress.  As soon as the timer tick expires, the first VCPU runs
the interrupt handler but very soon it sets it again---and QEMU
then goes back doing nothing in the second VCPU.

The fix is to make the pause instruction do "cpu_loop_exit".

Reported-by: Luigi Rizzo <rizzo@iet.unipi.it>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386/helper.h
target-i386/misc_helper.c
target-i386/translate.c