From: Chris Lalancette <clalance@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 0/5]: Fix kdump under KVM
Date: Thu, 29 Oct 2009 09:34:46 +0100 [thread overview]
Message-ID: <4AE953A6.1000204@redhat.com> (raw)
In-Reply-To: <4AE81D87.1030709@redhat.com>
Avi Kivity wrote:
> On 10/28/2009 12:13 PM, Chris Lalancette wrote:
>>> The kick from i8254 code is pretty bad, as you mention. I forget why it
>>> is needed at all - shouldn't kvm_set_irq() end up kicking the correct
>>>
>> As I understand it, that's not quite how it works. From what I can see, what
>> happens is that the i8254 is programmed as an hrtimer. When the hrtimer
>> expires, we get a callback in kvm_timer_fn (or pit_timer_fn, in my new code).
>> That code is running in interrupt context, however, so you can't directly call
>> "set_irq" at that point. Instead, we update the "pending" variable and defer
>> work until later on. That "later on" is when we are doing a vcpu_run, at which
>> point we check the "pending" variable, and if set, inject the interrupt.
>>
>> The problem is that if the vcpu(s) are in idle when the hrtimer expires, and we
>> don't kick them, no vcpu will wake up, and hence none of them will ever run
>> "set_irq" to get it injected into the guest.
>>
>
> Oh yes, I remember now.
>
>> If you have other ideas on how we might accomplish this, I'd definitely be
>> interested in hearing them.
>>
>
> We could schedule work to run in thread context. Previous to the user
> return notifier work, this would cause a reloading of a bunch of msrs
> and would thus be quite expensive, but now switching to kernel threads
> and back is pretty cheap.
>
> So we could try schedule_work(). My only worry is that it uses
> wake_up() instead of wake_up_sync(), so it could introduce delay. I'd
> much prefer a variant the schedules immediately.
>
> An alternative is to make irq injection work from irq context. It's not
> difficult to do technically - convert mutexes to spin_lock_irqsave() -
> I'm just worried about long irqoff times with large guests (ioapic needs
> to iterate over all vcpus sometimes). This is useful for other cases -
> device assignment interrupt injection, irqfd for vhost/vbus. So maybe
> we should go this path, and worry about reducing irqoff times later when
> we bump KVM_MAX_VCPUS.
>
I'm starting to take a look at this. While this may be a generically useful
cleanup, it occurs to me that even if we call "set_irq" from the hrtimer
callback, we still have to do the "kick_vcpus" type thing. Otherwise, we still
have the problem where if all vcpus are idle, none of them will be doing
vcpu_run anytime soon to actually inject the interrupt into the guest.
Or did I mis-understand what you are proposing?
--
Chris Lalancette
next prev parent reply other threads:[~2009-10-29 8:34 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
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 [this message]
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=4AE953A6.1000204@redhat.com \
--to=clalance@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.