From patchwork Wed Oct 12 12:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 13005059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60DD9C433FE for ; Wed, 12 Oct 2022 13:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbiJLNFY (ORCPT ); Wed, 12 Oct 2022 09:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiJLNFX (ORCPT ); Wed, 12 Oct 2022 09:05:23 -0400 X-Greylist: delayed 621 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 12 Oct 2022 06:05:20 PDT Received: from bddwd-sys-mailin04.bddwd.baidu.com (mx408.baidu.com [124.64.200.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4441A5209F for ; Wed, 12 Oct 2022 06:05:19 -0700 (PDT) Received: from bjhw-sys-rpm015653cc5.bjhw.baidu.com (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by bddwd-sys-mailin04.bddwd.baidu.com (Postfix) with ESMTP id D9FE413D8002E for ; Wed, 12 Oct 2022 20:54:28 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by bjhw-sys-rpm015653cc5.bjhw.baidu.com (Postfix) with ESMTP id CE838D9932 for ; Wed, 12 Oct 2022 20:54:28 +0800 (CST) From: Li RongQing To: kvm@vger.kernel.org Subject: [PATCH][RFC] KVM: x86: Don't reset deadline to period when timer is in one shot mode Date: Wed, 12 Oct 2022 20:54:28 +0800 Message-Id: <1665579268-7336-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In one-shot mode, the APIC timer stops counting when the timer reaches zero, so don't reset deadline to period for one shot mode Signed-off-by: Li RongQing --- arch/x86/kvm/lapic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 9dda989..bf39027 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1840,8 +1840,12 @@ static bool set_target_expiration(struct kvm_lapic *apic, u32 count_reg) if (unlikely(count_reg != APIC_TMICT)) { deadline = tmict_to_ns(apic, kvm_lapic_get_reg(apic, count_reg)); - if (unlikely(deadline <= 0)) - deadline = apic->lapic_timer.period; + if (unlikely(deadline <= 0)) { + if (apic_lvtt_period(apic)) + deadline = apic->lapic_timer.period; + else + deadline = 0; + } else if (unlikely(deadline > apic->lapic_timer.period)) { pr_info_ratelimited( "kvm: vcpu %i: requested lapic timer restore with "