Yes you are right. It was potentially racy and it was harmful too!. I had observed that it was stalling the CPU before I introduced kicked flag.

But now,

vcpu->kicked = 1 ==> kvm_make_request(KVM_REQ_UNHALT, vcpu); ==>

__vcpu_run() ==> kvm_check_request(KVM_REQ_UNHALT, vcpu) ==>

vcpuN->mp_state = KVM_MP_STATE_RUNNABLE; so eventually we will end upin RUNNABLE.

Also Avi pointed that, logically kvm_arch_vcpu_ioctl_set_mpstate shouldbe called only in vcpu thread, so after further debugging, I noticedthat, setting vcpuN->mp_state = KVM_MP_STATE_RUNNABLE; is notnecessary.I 'll remove that in the next patch. Thanks for pointing.