linux/Documentation
Paolo Bonzini 460df4c1fc KVM: race-free exit from KVM_RUN without POSIX signals
The purpose of the KVM_SET_SIGNAL_MASK API is to let userspace "kick"
a VCPU out of KVM_RUN through a POSIX signal.  A signal is attached
to a dummy signal handler; by blocking the signal outside KVM_RUN and
unblocking it inside, this possible race is closed:

          VCPU thread                     service thread
   --------------------------------------------------------------
        check flag
                                          set flag
                                          raise signal
        (signal handler does nothing)
        KVM_RUN

However, one issue with KVM_SET_SIGNAL_MASK is that it has to take
tsk->sighand->siglock on every KVM_RUN.  This lock is often on a
remote NUMA node, because it is on the node of a thread's creator.
Taking this lock can be very expensive if there are many userspace
exits (as is the case for SMP Windows VMs without Hyper-V reference
time counter).

As an alternative, we can put the flag directly in kvm_run so that
KVM can see it:

          VCPU thread                     service thread
   --------------------------------------------------------------
                                          raise signal
        signal handler
          set run->immediate_exit
        KVM_RUN
          check run->immediate_exit

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-02-17 12:27:37 +01:00
..
2016-12-13 11:06:21 -08:00
2016-12-15 15:39:02 -08:00
2016-10-03 08:58:35 -07:00
2017-01-03 16:47:13 -07:00
2017-01-20 12:25:11 -08:00
2016-12-27 13:05:36 -07:00
2016-12-13 15:43:56 -08:00
2016-10-07 20:19:31 -07:00
2016-11-14 10:39:48 -08:00
2016-12-22 12:32:33 -08:00
2016-12-15 13:49:34 -08:00
2016-06-30 13:07:33 -06:00
2016-12-14 10:54:28 +01:00
2016-06-07 22:57:10 +02:00
2016-11-07 12:16:06 -06:00
2016-05-17 14:48:04 +02:00