Re: Remove APIC lock

Avi Kivity
2007-08-25T08:05:26Z

Dong, Eddie wrote:
> Avi:
>
> apic->lock is used in many place to avoid race condition with apic
> timer call back
> function which may run on different pCPU. This patch migrate the
> apic timer to
> same CPU with the one VP runs on, thus the lock is no longer
> necessary.
>
> thx,eddie
>
>

What about preemption:

- vcpu executes lapic code in qemu process context
- process is preempted
- timer fires, touches lapic code

Furthermore, I question the necessity of this. Taking a spinlock is a
couple dozen cycles on modern processors. Entering the guest is a
couple thousand. So what are we saving?

(migrating the timer is a good thing though).

A different approach might be to wake up the vcpu like we do for irr,
with kvm_vcpu_kick(), and let the timer code be handled in process
context, so no locks need be taken.

--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.