From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3E17C10F0E for ; Fri, 12 Apr 2019 20:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96B6E20869 for ; Fri, 12 Apr 2019 20:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbfDLUSm (ORCPT ); Fri, 12 Apr 2019 16:18:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:64856 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbfDLUSl (ORCPT ); Fri, 12 Apr 2019 16:18:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2019 13:18:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,342,1549958400"; d="scan'208";a="140107053" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.181]) by fmsmga008.fm.intel.com with ESMTP; 12 Apr 2019 13:18:40 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org, Sean Christopherson , Liran Alon , Wanpeng Li Subject: [PATCH 6/7] KVM: lapic: Clean up the code for handling of a pre-expired hv_timer Date: Fri, 12 Apr 2019 13:18:33 -0700 Message-Id: <20190412201834.10831-7-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190412201834.10831-1-sean.j.christopherson@intel.com> References: <20190412201834.10831-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Calling apic_timer_expired() is a nop when a timer interrupt is already pending, i.e. there's no need to call apic_timer_expired() when there's a pending interrupt and the hv_timer wants to pend its own interrupt. Separate the two flows to make the code more readable and to avoid an unnecessary function call and read to ktimer->pending. Cc: Wanpeng Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 1d649a2af04c..f0be6f148a47 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1703,9 +1703,12 @@ static bool start_hv_timer(struct kvm_lapic *apic) * the window. For periodic timer, leave the hv timer running for * simplicity, and the deadline will be recomputed on the next vmexit. */ - if (!apic_lvtt_period(apic) && (r || atomic_read(&ktimer->pending))) { - if (r) - apic_timer_expired(apic); + if (!apic_lvtt_period(apic) && atomic_read(&ktimer->pending)) + return false; + + /* set_hv_timer() returns '1' when the timer has already expired. */ + if (r) { + apic_timer_expired(apic); return false; } -- 2.21.0