kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Lalancette <clalance@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] Fix kdump under KVM.
Date: Mon, 02 Nov 2009 14:22:33 +0100	[thread overview]
Message-ID: <4AEEDD19.9000105@redhat.com> (raw)
In-Reply-To: <4AEDA773.7030906@redhat.com>

Avi Kivity wrote:
> On 10/30/2009 02:23 PM, Chris Lalancette wrote:
>> In the meantime, I've gotten the "set_irq from IRQ context" that Avi 
>> suggested
>> working, and the fixing up of this IOAPIC check is the last bit to actually get
>> kdump working.
>>    
> 
> There are two problems with that:
> 
> - kvm_set_irq() calls some notifiers (irq_mask_notifiers, at least, but 
> possibly more); need to make sure those are safe from irq context
> - kvm_set_irq() will loop on all vcpus, usually incurring a cache miss 
> or two; with large vcpu counts this can make the irq-off time quite 
> large, hurting our worst-case latency
> 
> we can defer the second problem since it's only a performance issue, but 
> how did you deal with the first?
> 

Actually, there is a problem here, but I don't think it's as you describe.
kvm_set_irq() doesn't directly call the mask notifiers; all it really does is
call the i8259/ioapic callback, which causes an interrupt to be raised on the
LAPIC in question, which causes the interrupt to be injected into the VCPU on
the next run.  That doesn't call the irq_mask_notifiers, and seems to be
IRQ-safe (with the conversion from mutex's to spin_locks).

The irq mask notifiers are called later on during an EOI.  In particular,
ioapic_mmio_write() -> ioapic_write_indirect(), which is protected by the
ioapic_lock.  I don't see a problem here (although please point it out if I
missed it).

The problem I do see has to do with the irq_ack notifiers.  In particular, if
you are on ia64 and ioapic_mmio_write() gets called for the IOAPIC_REG_EOI
address, we call __kvm_ioapic_update_eoi().  In that case, we drop the spin_lock
and call kvm_notify_acked_irq(), which can re-enter the ioapic code.  This could
be IRQ unsafe, after we return from kvm_notify_acked_irq() we re-acquire the
spin-lock, but in an irq-unsafe fashion.  Therefore we could take the spin-lock,
get interrupted for the timer interrupt, and try to re-acquire the lock, causing
a deadlock.  I'll have to think a bit more on how to solve that one (there's a
similar situation going on in the i8259, which is not ia64 specific).

So, either I'm missing exactly what you are talking about, or there's no
deadlock with my patch (except with ia64).  Can you explain further?

-- 
Chris Lalancette

  reply	other threads:[~2009-11-02 13:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 16:41 [PATCH 0/5]: Fix kdump under KVM Chris Lalancette
2009-10-27 16:41 ` [PATCH 1/5] Fix up some comments around the source tree Chris Lalancette
2009-10-27 16:41 ` [PATCH 2/5] Remove KVM_REQ_PENDING_TIMER Chris Lalancette
2009-10-27 16:41 ` [PATCH 3/5] Remove references to VCPU in i8254 Chris Lalancette
2009-10-27 16:41 ` [PATCH 4/5] Remove timer.c Chris Lalancette
2009-10-27 16:41 ` [PATCH 5/5] Fix kdump under KVM Chris Lalancette
2009-10-27 17:42   ` Marcelo Tosatti
2009-10-28 10:21     ` Chris Lalancette
2009-10-28 12:41       ` Marcelo Tosatti
2009-10-30 12:23         ` Chris Lalancette
2009-10-30 13:07           ` Marcelo Tosatti
2009-10-30 15:28             ` Chris Lalancette
2009-10-30 18:03               ` David S. Ahern
2009-10-30 22:21                 ` Marcelo Tosatti
2009-10-30 22:19               ` Marcelo Tosatti
2009-11-01 15:21           ` Avi Kivity
2009-11-02 13:22             ` Chris Lalancette [this message]
2009-11-02 13:30               ` Avi Kivity
2009-10-28  9:59 ` [PATCH 0/5]: " Avi Kivity
2009-10-28 10:13   ` Chris Lalancette
2009-10-28 10:31     ` Avi Kivity
2009-10-29  8:34       ` Chris Lalancette
2009-10-29 10:15         ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AEEDD19.9000105@redhat.com \
    --to=clalance@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).