Re: Remove APIC lock

Gregory Haskins
2007-08-24T14:39:58Z

On Fri, 2007-08-24 at 22:24 +0800, Dong, Eddie wrote:
> kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org wrote:
> > Gregory Haskins wrote:
> >> On Fri, 2007-08-24 at 21:08 +0800, 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.
> >>>
> >>
> >> What about sources that can inject interrupts besides the timer?
> >> (E.g. in-kernel PV drivers)
> >
> > Injecting IRQ is OK, since it is just operation to IRR
> > register which we
> > can
> > use atomic operations. Xen also do in that way.
> >
> O, said too quick. Xen current has evolved to be protected by a
> bigger irqlock for both APIC & IOAPIC, and PIC uses per chip lock.
>
> For our case, PIC/IOAPIC now is using kvm->lock. So APIC is working
> with kvm->lock too. But this lock may be too big for pv driver. We may
> need to think of a solution to cover both APIC & IOAPIC in future.

Yeah, I would highly recommend you make this more fine grained. For
example, I had a vcpu->irq.lock, and a per-chip lock (e.g. one per apic,
per pic, (and one per ioapic but I never got there)). Event injection
is a hot-spot, so coarse locking is probably going to cause performance
deficiencies.