From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v2 2/5] KVM: nVMX: Re-evaluate L1 pending events when running L2 and L1 got posted-interrupt Date: Mon, 11 Dec 2017 23:53:51 +0100 Message-ID: <5b6ccb99-9086-d6f2-8fc7-121da9f1c036@redhat.com> References: <1512461786-6465-1-git-send-email-liran.alon@oracle.com> <1512461786-6465-3-git-send-email-liran.alon@oracle.com> <20171206185231.GB3644@flask> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, jmattson@google.com, wanpeng.li@hotmail.com, idan.brown@oracle.com, Krish Sadhukhan , Konrad Rzeszutek Wilk To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Liran Alon Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35850 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbdLKWxy (ORCPT ); Mon, 11 Dec 2017 17:53:54 -0500 In-Reply-To: <20171206185231.GB3644@flask> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 06/12/2017 19:52, Radim Krčmář wrote: >> smp_mb__after_atomic(); >> max_irr = kvm_apic_update_irr(vcpu, vmx->pi_desc.pir); > I think the optimization (partly livelock protection) is not worth the > overhead of two IRR scans for non-nested guests. Please make > kvm_apic_update_irr() return both prev_max_irr and max_irr in one pass. You could also return max_irr in an int*, and give the function a "bool" return type for max_irr > prev_max_irr. That is more efficient because you can do the check in the "if (pir_val)" conditional of __kvm_apic_update_irr. Paolo >> + >> + /* >> + * If we are running L2 and L1 has a new pending interrupt >> + * which can be injected, we should re-evaluate >> + * what should be done with this new L1 interrupt. >> + */ >> + if (is_guest_mode(vcpu) && (max_irr > prev_max_irr)) >> + kvm_make_request(KVM_REQ_EVENT, vcpu); > We don't need anything from KVM_REQ_EVENT and only use it to abort the > VM entry, kvm_vcpu_exiting_guest_mode() is better for that. > >> } else { >> - max_irr = kvm_lapic_find_highest_irr(vcpu); >> + max_irr = prev_max_irr; >> } >> + >> vmx_hwapic_irr_update(vcpu, max_irr); > We also should just inject the interrupt if L2 is run without > nested_exit_on_intr(), maybe reusing the check in vmx_hwapic_irr_update?