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
Showing the changes to include/uapi/linux (1 of 7 files). Show all
Unified · Split
| @@ -218,7 +218,8 @@ struct kvm_hyperv_exit { · 217 unmodified lines | |||
| 218 | struct kvm_run { | 218 | struct kvm_run { |
| 219 | /* in */ | 219 | /* in */ |
| 220 | __u8 request_interrupt_window; | 220 | __u8 request_interrupt_window; |
| 221 | __u8 padding1[7]; | 221 | __u8 immediate_exit; |
| 222 | __u8 padding1[6]; | ||
| 222 | 223 | ||
| 223 | /* out */ | 224 | /* out */ |
| 224 | __u32 exit_reason; | 225 | __u32 exit_reason; |
| @@ -881,6 +882,7 @@ struct kvm_ppc_resize_hpt { · 656 unmodified lines | |||
| 881 | #define KVM_CAP_SPAPR_RESIZE_HPT 133 | 882 | #define KVM_CAP_SPAPR_RESIZE_HPT 133 |
| 882 | #define KVM_CAP_PPC_MMU_RADIX 134 | 883 | #define KVM_CAP_PPC_MMU_RADIX 134 |
| 883 | #define KVM_CAP_PPC_MMU_HASH_V3 135 | 884 | #define KVM_CAP_PPC_MMU_HASH_V3 135 |
| 885 | #define KVM_CAP_IMMEDIATE_EXIT 136 | ||
| 884 | 886 | ||
| 885 | #ifdef KVM_CAP_IRQ_ROUTING | 887 | #ifdef KVM_CAP_IRQ_ROUTING |
| 886 | 888 | ||