The intent of the extra check was to avoid the locked instruction that comes with
disabling preemption via rcu_read_lock(). But thinking more, the extra op should
be little more than a basic arithmetic operation in the grand scheme on modern x86
since the cache line is going to be locked and written no matter what, either
immediately before or immediately after.
+ /*
+ * Avoid the moderately expensive "should kick" operation if this pCPU
+ * is currently running the target vCPU, in which case it's a KVM bug
+ * if the vCPU is in the inner run loop.
+ */
+ if (vcpu == __this_cpu_read(kvm_running_vcpu) &&
+ !WARN_ON_ONCE(vcpu->mode == IN_GUEST_MODE))
+ goto out;
+