All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>,
	Jan Kiszka <jan.kiszka@web.de>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH KVM v2 1/4] KVM: fix i8254 IRQ0 to be normally high
Date: Mon, 7 Jan 2013 14:48:05 +0200	[thread overview]
Message-ID: <20130107124805.GD3440@redhat.com> (raw)
In-Reply-To: <20130107093917.GW3440@redhat.com>

On Mon, Jan 07, 2013 at 11:39:18AM +0200, Gleb Natapov wrote:
> On Wed, Dec 26, 2012 at 10:39:53PM -0700, Matthew Ogilvie wrote:
> > Reading the spec, it is clear that most modes normally leave the IRQ
> > output line high, and only pulse it low to generate a leading edge.
> > Especially the most commonly used mode 2.
> > 
> > The KVM i8254 model does not try to emulate the duration of the pulse at
> > all, so just swap the high/low settings it to leave it high most of
> > the time.
> > 
> > This fix is a prerequisite to improving the i8259 model to handle
> > the trailing edge of an interupt request as indicated in its spec:
> > If it gets a trailing edge of an IRQ line before it starts to service
> > the interrupt, the request should be canceled.
> > 
> > See http://bochs.sourceforge.net/techspec/intel-82c54-timer.pdf.gz
> > or search the net for 23124406.pdf.
> > 
> > Risks:
> > 
> > There is a risk that migrating a running guest between versions
> > with and without this patch will lose or gain a single timer
> > interrupt during the migration process.  The only case where
> Can you elaborate on how exactly this can happen? Do not see it.
> 
> > this is likely to be serious is probably losing a single-shot (mode 4)
> > interrupt, but if my understanding of how things work is good, then
> > that should only be possible if a whole slew of conditions are
> > all met:
> > 
> >  1. The guest is configured to run in a "tickless" mode (like
> >     modern Linux).
> >  2. The guest is for some reason still using the i8254 rather
> >     than something more modern like an HPET.  (The combination
> >     of 1 and 2 should be rare.)
> This is not so rare. For performance reason it is better to not have
> HPET at all.  In fact -no-hpet is how I would advice anyone to run qemu.
> 
It looks like Linux prefer to use APIC timer anyway.

> >  3. The migration is going from a fixed version back to the
> >     old version.  (Not sure how common this is, but it should
> >     be rarer than migrating from old to new.)
> >  4. There are not going to be any "timely" events/interrupts
> >     (keyboard, network, process sleeps, etc) that cause the guest
> >     to reset the PIT mode 4 one-shot counter "soon enough".
> > 
> > This combination should be rare enough that more complicated
> > solutions are not worth the effort.
> > 
> > Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
> > ---
> >  arch/x86/kvm/i8254.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
> > index c1d30b2..cd4ec60 100644
> > --- a/arch/x86/kvm/i8254.c
> > +++ b/arch/x86/kvm/i8254.c
> > @@ -290,8 +290,12 @@ static void pit_do_work(struct kthread_work *work)
> >  	}
> >  	spin_unlock(&ps->inject_lock);
> >  	if (inject) {
> > -		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
> > +		/* Clear previous interrupt, then create a rising
> > +		 * edge to request another interupt, and leave it at
> > +		 * level=1 until time to inject another one.
> > +		 */
> >  		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0);
> > +		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
> >  
> >  		/*
> >  		 * Provides NMI watchdog support via Virtual Wire mode.
> > -- 
> > 1.7.10.2.484.gcd07cc5
> 
> --
> 			Gleb.

--
			Gleb.

WARNING: multiple messages have this Message-ID (diff)
From: Gleb Natapov <gleb@redhat.com>
To: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
Cc: Jan Kiszka <jan.kiszka@web.de>,
	qemu-devel@nongnu.org, "Maciej W. Rozycki" <macro@linux-mips.org>,
	kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH KVM v2 1/4] KVM: fix i8254 IRQ0 to be normally high
Date: Mon, 7 Jan 2013 14:48:05 +0200	[thread overview]
Message-ID: <20130107124805.GD3440@redhat.com> (raw)
In-Reply-To: <20130107093917.GW3440@redhat.com>

On Mon, Jan 07, 2013 at 11:39:18AM +0200, Gleb Natapov wrote:
> On Wed, Dec 26, 2012 at 10:39:53PM -0700, Matthew Ogilvie wrote:
> > Reading the spec, it is clear that most modes normally leave the IRQ
> > output line high, and only pulse it low to generate a leading edge.
> > Especially the most commonly used mode 2.
> > 
> > The KVM i8254 model does not try to emulate the duration of the pulse at
> > all, so just swap the high/low settings it to leave it high most of
> > the time.
> > 
> > This fix is a prerequisite to improving the i8259 model to handle
> > the trailing edge of an interupt request as indicated in its spec:
> > If it gets a trailing edge of an IRQ line before it starts to service
> > the interrupt, the request should be canceled.
> > 
> > See http://bochs.sourceforge.net/techspec/intel-82c54-timer.pdf.gz
> > or search the net for 23124406.pdf.
> > 
> > Risks:
> > 
> > There is a risk that migrating a running guest between versions
> > with and without this patch will lose or gain a single timer
> > interrupt during the migration process.  The only case where
> Can you elaborate on how exactly this can happen? Do not see it.
> 
> > this is likely to be serious is probably losing a single-shot (mode 4)
> > interrupt, but if my understanding of how things work is good, then
> > that should only be possible if a whole slew of conditions are
> > all met:
> > 
> >  1. The guest is configured to run in a "tickless" mode (like
> >     modern Linux).
> >  2. The guest is for some reason still using the i8254 rather
> >     than something more modern like an HPET.  (The combination
> >     of 1 and 2 should be rare.)
> This is not so rare. For performance reason it is better to not have
> HPET at all.  In fact -no-hpet is how I would advice anyone to run qemu.
> 
It looks like Linux prefer to use APIC timer anyway.

> >  3. The migration is going from a fixed version back to the
> >     old version.  (Not sure how common this is, but it should
> >     be rarer than migrating from old to new.)
> >  4. There are not going to be any "timely" events/interrupts
> >     (keyboard, network, process sleeps, etc) that cause the guest
> >     to reset the PIT mode 4 one-shot counter "soon enough".
> > 
> > This combination should be rare enough that more complicated
> > solutions are not worth the effort.
> > 
> > Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
> > ---
> >  arch/x86/kvm/i8254.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
> > index c1d30b2..cd4ec60 100644
> > --- a/arch/x86/kvm/i8254.c
> > +++ b/arch/x86/kvm/i8254.c
> > @@ -290,8 +290,12 @@ static void pit_do_work(struct kthread_work *work)
> >  	}
> >  	spin_unlock(&ps->inject_lock);
> >  	if (inject) {
> > -		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
> > +		/* Clear previous interrupt, then create a rising
> > +		 * edge to request another interupt, and leave it at
> > +		 * level=1 until time to inject another one.
> > +		 */
> >  		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0);
> > +		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
> >  
> >  		/*
> >  		 * Provides NMI watchdog support via Virtual Wire mode.
> > -- 
> > 1.7.10.2.484.gcd07cc5
> 
> --
> 			Gleb.

--
			Gleb.

  reply	other threads:[~2013-01-07 12:48 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-27  5:39 [PATCH KVM v2 0/4] fix KVM i8259 IRQ trailing-edge logic Matthew Ogilvie
2012-12-27  5:39 ` [Qemu-devel] " Matthew Ogilvie
2012-12-27  5:39 ` [PATCH KVM v2 1/4] KVM: fix i8254 IRQ0 to be normally high Matthew Ogilvie
2012-12-27  5:39   ` [Qemu-devel] " Matthew Ogilvie
2013-01-07  9:39   ` Gleb Natapov
2013-01-07  9:39     ` [Qemu-devel] " Gleb Natapov
2013-01-07 12:48     ` Gleb Natapov [this message]
2013-01-07 12:48       ` Gleb Natapov
2013-01-08  0:17     ` mmogilvi
2013-01-08  0:17       ` [Qemu-devel] " mmogilvi
2013-01-08  7:31       ` Gleb Natapov
2013-01-08  7:31         ` [Qemu-devel] " Gleb Natapov
2013-01-11  6:40         ` Matthew Ogilvie
2013-01-11  6:40           ` [Qemu-devel] " Matthew Ogilvie
2013-01-11 15:45           ` Gleb Natapov
2013-01-11 15:45             ` [Qemu-devel] " Gleb Natapov
2013-01-15  9:49             ` Matthew Ogilvie
2013-01-15  9:49               ` [Qemu-devel] " Matthew Ogilvie
2012-12-27  5:39 ` [PATCH KVM v2 2/4] KVM: additional i8254 output fixes Matthew Ogilvie
2012-12-27  5:39   ` [Qemu-devel] " Matthew Ogilvie
2013-01-07 12:04   ` Gleb Natapov
2013-01-07 12:04     ` [Qemu-devel] " Gleb Natapov
2013-01-08  0:35     ` mmogilvi
2013-01-08  0:35       ` [Qemu-devel] " mmogilvi
2013-01-08  7:41       ` Gleb Natapov
2013-01-08  7:41         ` [Qemu-devel] " Gleb Natapov
2013-01-11  6:33         ` Matthew Ogilvie
2013-01-11  6:33           ` [Qemu-devel] " Matthew Ogilvie
2012-12-27  5:39 ` [PATCH KVM v2 3/4] KVM: fix i8259 interrupt high to low transition logic Matthew Ogilvie
2012-12-27  5:39   ` [Qemu-devel] " Matthew Ogilvie
2012-12-27  5:39 ` [PATCH KVM v2 4/4] KVM: i8259: refactor pic_set_irq level logic Matthew Ogilvie
2012-12-27  5:39   ` [Qemu-devel] " Matthew Ogilvie
2013-01-06 15:54 ` [PATCH KVM v2 0/4] fix KVM i8259 IRQ trailing-edge logic Gleb Natapov
2013-01-06 15:54   ` [Qemu-devel] " Gleb Natapov

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=20130107124805.GD3440@redhat.com \
    --to=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=mmogilvi_qemu@miniinfo.net \
    --cc=qemu-devel@nongnu.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.