From: David Hildenbrand <david@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: x86: optimize local IRQ disable time before vmentry
Date: Thu, 9 Mar 2017 14:11:00 +0100 [thread overview]
Message-ID: <994702e9-1d62-0ac4-3845-8bc9e816c284@redhat.com> (raw)
In-Reply-To: <7939e90b-4fe0-d07a-82b4-73cb0f4407fc@redhat.com>
Am 09.03.2017 um 13:33 schrieb Paolo Bonzini:
>
>
> On 09/03/2017 13:16, Wanpeng Li wrote:
>> From: Wanpeng Li <wanpeng.li@hotmail.com>
>>
>> Commit b95234c84 (kvm: x86: do not use KVM_REQ_EVENT for APICv interrupt
>> injection) disables interrupts before setting vcpu->mode to fix an race:
>>
>> | The IPI for posted interrupts may be issued between setting vcpu->mode =
>> | IN_GUEST_MODE and disabling interrupts. If that happens,
>> | kvm_trigger_posted_interrupt returns true, but smp_kvm_posted_intr_ipi
>> | doesn't do anything about it. The guest is entered with PIR.ON, but the
>> | posted interrupt IPI has not been sent and the interrupt is only delivered
>> | to the guest on the next vmentry (if any).
>>
>> However the race has already been fixed by the side-effects of moving the
>> RVI update after IN_GUEST_MODE in the commit:
>>
>> - The IPI for posted interrupts is issued after setting vcpu->mode =
>> IN_GUEST_MODE and disabling interrupts, the posted interrupt IPI is
>> delayed until the guest enters non-root mode; it is then trapped by
>> the processor causing the interrupt to be injected.
>> - The IPI for posted interrupts is issued between setting vcpu->mode =
>> IN_GUEST_MODE and disabling interrupts, the movement of the RVI update
>> after IN_GUEST_MODE in the commit will catch the new PIR, and set RVI.
>>
>> This patch tries to reduce the local IRQ disable time by restoring the
>> place of disable local IRQ in order to improve host kernel responsibility
>> to some degree.
>
> This should not make any difference; we're talking of a few dozen clock
> cycles, and it's quite possible that the extra chance of getting a PI
> interrupt in the host negates it.
>
> Paolo
>
Also, I think after all the discussion regarding handling vcpu->mode +
preemption when it comes to a vcpu_kick(), keeping it that way is way
cleaner.
--
Thanks,
David
prev parent reply other threads:[~2017-03-09 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 12:16 Wanpeng Li
2017-03-09 12:33 ` Paolo Bonzini
2017-03-09 13:11 ` David Hildenbrand [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=994702e9-1d62-0ac4-3845-8bc9e816c284@redhat.com \
--to=david@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.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
all inboxes | Powered by JetHome®