Re: [PATCH 2/3] KVM: send IPI to vcpu only when it's in guest mode
From: Xiao Guangrong
Date: Wed Jan 05 2011 - 05:05:39 EST
On 01/05/2011 05:48 PM, Avi Kivity wrote:
>> srcu_read_unlock(&vcpu->kvm->srcu, idx);
>> + atomic_set(&vcpu->guest_mode, 1);
> I think it needs an smp_wmb() (technically x86 needs it too, but x86 is strongly ordered)
>> - if (cpus != NULL&& cpu != -1&& cpu != me)
>> + if (cpus != NULL&& cpu != -1&& cpu != me&&
>> + atomic_read(&vcpu->guest_mode))
>> cpumask_set_cpu(cpu, cpus);
> and smp_rmb() before the atomic_read().
Yeah, you're right, i'll fix these in the next version.
>> if (unlikely(cpus == NULL))
> Not sure if this is an optimization. On one hand it removes an expensive IPI for the fraction of time the cpu is out of guest mode. On the other hand it adds an unconditional cacheline bounce (and bounce back).
> Hm. I see that ->guest_mode and ->requests are in fact in the same cache line. So this is likely really an optimization. We should probably reorganize kvm_vcpu so that this is made explicit.
OK, will do it in the separate patch in the future, thanks!
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/