From: Yang Zhang <yang.zhang.wz@gmail.com>
To: "rkrcmar@redhat.com" <rkrcmar@redhat.com>,
"Wu, Feng" <feng.wu@intel.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Jiang Liu (jiang.liu@linux.intel.com)"
<jiang.liu@linux.intel.com>
Subject: Re: [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-priority interrupts
Date: Wed, 23 Dec 2015 11:17:47 +0800 [thread overview]
Message-ID: <567A125B.6070100@gmail.com> (raw)
In-Reply-To: <20151222195259.GC12725@potion.redhat.com>
On 2015/12/23 3:52, rkrcmar@redhat.com wrote:
> 2015-12-22 07:19+0000, Wu, Feng:
>>> From: Yang Zhang [mailto:yang.zhang.wz@gmail.com]
>>> On 2015/12/22 14:59, Wu, Feng wrote:
>>>>> From: Yang Zhang [mailto:yang.zhang.wz@gmail.com]
>>>>>>>>> On 2015/12/16 9:37, Feng Wu wrote:
>>>>>>>>>> + for_each_set_bit(i, &bitmap, 16) {
>>>>>>>>>> + if (!dst[i]
>>>>>>>>> && !kvm_lapic_enabled(dst[i]->vcpu)) {
>>>>>>>>>
>>>>>>>>> It should be or(||) not and (&&).
>>>>>>>>
>>>>>>>> Oh, you are right! My negligence! Thanks for pointing this out, Yang!
>>>>>>>
>>>>>>> btw, i think the kvm_lapic_enabled check is wrong here? Why need it here?
>>>>>>
>>>>>> If the lapic is not enabled, I think we cannot recognize it as a candidate, can
>>>>> we?
>>>>>> Maybe Radim can confirm this, Radim, what is your option?
>
> SDM 10.6.2.2 Logical Destination Mode:
> For both configurations of logical destination mode, when combined
> with lowest priority delivery mode, software is responsible for
> ensuring that all of the local APICs included in or addressed by the
> IPI or I/O subsystem interrupt are present and enabled to receive the
> interrupt.
>
> The case is undefined if some targeted LAPICs weren't hardware enabled
> as no interrupts can be delivered to hardware disabled LAPIC, so we can
> check for hardware enabled.
>
> It's not obvious if "enabled to receive the interrupt" means hardware or
> software enabled, but lowest priority cannot deliver NMI/INIT/..., so
> checking for software enabled doesn't restrict any valid uses either.
Agree. My understanding is that it is software's responsibility to
ensuring this case not happen. But for hypervisor, we should not check
it for software. What we can do is just follow the SDM.
>
> so ... KVM only musn't blow up when encountering this situation :)
>
> The current code seems correct, but redundant. Just for reference, KVM
> now does:
> - check for software enabled LAPIC since patch aefd18f01ee8 ("KVM: x86:
> In DM_LOWEST, only deliver interrupts to vcpus with enabled LAPIC's")
> - check only for hardware enabled LAPIC in the fast path, since
> 1e08ec4a130e ("KVM: optimize apic interrupt delivery"))
>
> (v1 was arguable better, I pointed the need for enabled LAPIC in v1 only
> from looking at one KVM function, sorry.)
>
>>>>> Lapic can be disable by hw or sw. Here we only need to check the hw is
>>>>> enough which is already covered while injecting the interrupt into
>>>>> guest. I remember we(Glab, Macelo and me) have discussed it several ago,
>>>>> but i cannot find the mail thread.
>>>
>>>>
>>>> But if the lapic is disabled by software, we cannot still inject interrupts to
>>>> it, can we?
>>>
>>> Yes, We cannot inject the normal interrupt. But this already covered by
>>> current logic and add a check here seems meaningless. Conversely, it may
>>> do bad thing..
>>>
>>
>> Let's wait for Radim/Paolo's opinions about this.
>
> I'd pick whatever results in less code: this time it seems like checking
> for hardware enabled LAPIC in both paths (implicitly in the fast path).
> Maybe it can be done better, I haven't given it much thought.
>
> We should revert aefd18f01ee8 at the same time, so our PI/non-PI slow
> paths won't diverge -- I hope it wasn't fixing a bug :)
>
> I'll review the series tomorrow, thanks for your patience.
--
best regards
yang
next prev parent reply other threads:[~2015-12-23 3:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-16 1:37 [PATCH v2 0/2] Add vector-hashing support for lowest-priority interrupts delivery Feng Wu
2015-12-16 1:37 ` [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-priority interrupts Feng Wu
2015-12-21 1:46 ` Yang Zhang
2015-12-21 1:50 ` Wu, Feng
2015-12-21 2:06 ` Yang Zhang
2015-12-22 4:37 ` Wu, Feng
2015-12-22 6:49 ` Yang Zhang
2015-12-22 6:59 ` Wu, Feng
2015-12-22 7:13 ` Yang Zhang
2015-12-22 7:19 ` Wu, Feng
2015-12-22 19:52 ` rkrcmar
2015-12-23 2:12 ` Wu, Feng
2015-12-23 16:42 ` rkrcmar
2015-12-23 3:17 ` Yang Zhang [this message]
2015-12-23 17:19 ` Radim Krčmář
2016-01-18 5:19 ` Wu, Feng
2016-01-18 10:41 ` Paolo Bonzini
2016-01-19 4:44 ` Wu, Feng
2016-01-19 13:42 ` Paolo Bonzini
2016-01-19 13:49 ` Wu, Feng
2016-01-18 14:00 ` Radim Krcmár
2015-12-16 1:37 ` [PATCH v2 2/2] KVM: x86: Add lowest-priority support for vt-d posted-interrupts Feng Wu
2015-12-21 1:50 ` Yang Zhang
2015-12-21 1:55 ` Wu, Feng
2015-12-21 2:01 ` Yang Zhang
2015-12-22 4:36 ` Wu, Feng
2015-12-22 6:42 ` Yang Zhang
2015-12-23 16:50 ` rkrcmar
2015-12-23 17:21 ` Radim Krčmář
2016-01-04 1:57 ` Wu, Feng
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=567A125B.6070100@gmail.com \
--to=yang.zhang.wz@gmail.com \
--cc=feng.wu@intel.com \
--cc=jiang.liu@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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).