From: Jan Kiszka <jan.kiszka@web.de>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: Fix RTC interrupt coalescing tracking
Date: Wed, 26 Jun 2013 08:26:43 +0200 [thread overview]
Message-ID: <51CA89A3.7020709@web.de> (raw)
In-Reply-To: <20130626061540.GA1038@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4378 bytes --]
On 2013-06-26 08:15, Gleb Natapov wrote:
> On Wed, Jun 26, 2013 at 07:49:37AM +0200, Jan Kiszka wrote:
>> On 2013-06-24 14:19, Gleb Natapov wrote:
>>> This reverts most of the f1ed0450a5fac7067590317cbf027f566b6ccbca. After
>>> the commit kvm_apic_set_irq() no longer returns accurate information
>>> about interrupt injection status if injection is done into disabled
>>> APIC. RTC interrupt coalescing tracking relies on the information to be
>>> accurate and cannot recover if it is not.
>>>
>>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
>>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
>>> index 9d75193..9f4bea8 100644
>>> --- a/arch/x86/kvm/lapic.c
>>> +++ b/arch/x86/kvm/lapic.c
>>> @@ -405,17 +405,17 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
>>> return highest_irr;
>>> }
>>>
>>> -static void __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
>>> - int vector, int level, int trig_mode,
>>> - unsigned long *dest_map);
>>> +static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
>>> + int vector, int level, int trig_mode,
>>> + unsigned long *dest_map);
>>
>> I still think __apic_accept_irq should unconditionally inject, and the
>> test for acpi_enabled belongs into kvm_apic_set_irq. Why should
>> __apic_accept_irq accept non-APIC_DM_FIXED messages if the APIC is off?
>> See below for another reason to refactor this part of the interface.
>>
> 10.4.7.2 Local APIC State After It Has Been Software Disabled
>
> The local APIC will respond normally to INIT, NMI, SMI, and SIPI
> messages.
OK, I see.
>
>>>
>>> -void kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
>>> - unsigned long *dest_map)
>>> +int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
>>> + unsigned long *dest_map)
>>> {
>>> struct kvm_lapic *apic = vcpu->arch.apic;
>>>
>>> - __apic_accept_irq(apic, irq->delivery_mode, irq->vector,
>>> - irq->level, irq->trig_mode, dest_map);
>>> + return __apic_accept_irq(apic, irq->delivery_mode, irq->vector,
>>> + irq->level, irq->trig_mode, dest_map);
>>> }
>>>
>>> static int pv_eoi_put_user(struct kvm_vcpu *vcpu, u8 val)
>>> @@ -608,8 +608,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
>>> *r = -1;
>>>
>>> if (irq->shorthand == APIC_DEST_SELF) {
>>> - kvm_apic_set_irq(src->vcpu, irq, dest_map);
>>> - *r = 1;
>>> + *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
>>> return true;
>>> }
>>>
>>> @@ -654,8 +653,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
>>> continue;
>>> if (*r < 0)
>>> *r = 0;
>>> - kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map);
>>> - *r += 1;
>>> + *r += kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map);
>>> }
>>>
>>> ret = true;
>>> @@ -664,11 +662,15 @@ out:
>>> return ret;
>>> }
>>>
>>> -/* Set an IRQ pending in the lapic. */
>>> -static void __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
>>> - int vector, int level, int trig_mode,
>>> - unsigned long *dest_map)
>>> +/*
>>> + * Add a pending IRQ into lapic.
>>> + * Return 1 if successfully added and 0 if discarded.
>>> + */
>>> +static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
>>> + int vector, int level, int trig_mode,
>>> + unsigned long *dest_map)
>>> {
>>> + int result = 0;
>>> struct kvm_vcpu *vcpu = apic->vcpu;
>>>
>>> switch (delivery_mode) {
>>> @@ -682,10 +684,13 @@ static void __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
>>> if (dest_map)
>>> __set_bit(vcpu->vcpu_id, dest_map);
>>>
>>> - if (kvm_x86_ops->deliver_posted_interrupt)
>>> + if (kvm_x86_ops->deliver_posted_interrupt) {
>>> + result = 1;
>>> kvm_x86_ops->deliver_posted_interrupt(vcpu, vector);
>>> - else {
>>> - if (apic_test_and_set_irr(vector, apic)) {
>>> + } else {
>>> + result = !apic_test_and_set_irr(vector, apic);
>>
>> This part of the revert makes no sense. If deliver_posted_interrupt is
>> on, we don't have this feedback anymore, thus we decided to remove it, no?
>>
> Agree, but I wanted to do clear revert and fix on top.
Fine with me, let's write a separate fix.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
prev parent reply other threads:[~2013-06-26 6:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 12:19 [PATCH] KVM: Fix RTC interrupt coalescing tracking Gleb Natapov
2013-06-26 5:49 ` Jan Kiszka
2013-06-26 6:15 ` Gleb Natapov
2013-06-26 6:26 ` Jan Kiszka [this message]
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=51CA89A3.7020709@web.de \
--to=jan.kiszka@web.de \
--cc=gleb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox