From: Sean Christopherson <seanjc@google.com>
To: "Li,Rongqing" <lirongqing@baidu.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Peter Shier <pshier@google.com>,
Jim Mattson <jmattson@google.com>,
Wanpeng Li <wanpengli@tencent.com>
Subject: Re: [PATCH][RFC] KVM: x86: Don't reset deadline to period when timer is in one shot mode
Date: Wed, 19 Oct 2022 15:53:36 +0000 [thread overview]
Message-ID: <Y1AdgCyCPINaTCgA@google.com> (raw)
In-Reply-To: <94584fc76a5f41629febc53615f82b6f@baidu.com>
On Mon, Oct 17, 2022, Li,Rongqing wrote:
> > +Jim, Peter, and Wanpeng
> >
> > On Wed, Oct 12, 2022, Li RongQing wrote:
> > > 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 <lirongqing@baidu.com>
> > > ---
> > > 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;
> > > + }
> >
> > This is not the standard "count has reached zero" path, it's the "vCPU is
> > migrated and the timer needs to be resumed on the destination" path.
> > Zeroing the deadline here will not squash the timer, IIUC it will cause the timer
> > to immediately fire.
> >
> > That said, I think the patch is actually correct
>
> Should we set deadline to 0 when it is expired whether the timer is one shot
> mode or period mode ?
I'm not sure I follow the question. Are you asking if this path should set the
deadline to '0' even if the timer is in periodic mode?
next prev parent reply other threads:[~2022-10-19 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 12:54 [PATCH][RFC] KVM: x86: Don't reset deadline to period when timer is in one shot mode Li RongQing
2022-10-12 16:05 ` Sean Christopherson
2022-10-17 9:54 ` Li,Rongqing
2022-10-19 15:53 ` Sean Christopherson [this message]
2022-10-20 1:17 ` Li,Rongqing
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=Y1AdgCyCPINaTCgA@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=pshier@google.com \
--cc=wanpengli@tencent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.