From: Alan Jenkins <alan.christopher.jenkins@gmail.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: KVM: x86: reset lapic_timer.expired_tscdeadline at SET_LAPIC time
Date: Mon, 20 Jun 2016 16:22:33 +0100 [thread overview]
Message-ID: <9407acfa-2923-6059-b11a-e0944263a248@gmail.com> (raw)
In-Reply-To: <20160620131157.GA7470@amt.cnet>
On 20/06/16 14:11, Marcelo Tosatti wrote:
> On Sat, Jun 18, 2016 at 02:43:51PM +0100, Alan Jenkins wrote:
>> On 18/06/2016, Marcelo Tosatti <mtosatti@redhat.com> wrote:
>>> I'm happy to check my own test if this is considered a solution.
>>> (And apologies for how my own efforts go... flailing around and not
>>> always communicating effectively...)
> Your report had many details.
Good, let's hope I will not report too many irrelevant details ("bury
the lede") :).
>
>> 1) I think the commit message could be improved. Specifically it
>> says the problem is due to TSC write, then that we need to fix LAPIC
>> reset. It doesn't say what the connection is between the two.
> Right.
>
>
>> (I.e. you would have to read the bug report, & then realize that it
>> _happens_ to involve a LAPIC state restore as well, because it's
>> triggered by reloading the entire VM state from a snapshot)
>>
>> Doing so might make the intention of this commit clearer. I've been
>> trying to work out a high quality fix, which prevents the lockups
>> revealed by this case. I think this commit would fix my bug nicely,
>> but it doesn't help e.g. if the LAPIC restore was omitted from the
>> sequence.
>>
>> (Both TSC and the value of TSC deadline are set by MSRs, not by
>> writing to the LAPIC. So I don't think the LAPIC state restore is
>> necessary to trigger the issue).
>>
>>
>> 2) If this approach is considered expedient, I have two comments -
>>
>> i) isn't it better to set lapic_timer.expired_tscdeadline in
>> lapic.c, i.e. in apic_post_state_restore() ?
>>
>> ii) then, wouldn't it be more correct to set it between
>> hrtimer_cancel() and start_apic_timer()? It doesn't sound right to
>> clear expired_tscdeadline, in case it was set immediately by
>> start_apic_timer()
>>
>> Alan
> Advancing the timer expiration should only be necessary on
> guest initiated writes. Lets improve the commit message.
The timer expiration is still advanced, this patch just avoids the
busywait. I think you mean it's ok if the guest would be interrupted
early after a host-initiated write.
I think it'd be fine in practice; even interrupting before observed TSC
reaches the TSC deadline isn't a problem in itself. When restoring CPU
state, qemu will already have burnt the ~10ns advance in terms of *real*
time. And if there actually were external observers, they would already
be confused by the guest being rewound. I just can't code something
like that without leaving a comment.
> Can you confirm the patch fixes your problem?
That did it, yes.
prev parent reply other threads:[~2016-06-20 15:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 23:41 KVM: x86: reset lapic_timer.expired_tscdeadline at SET_LAPIC time Marcelo Tosatti
2016-06-18 13:43 ` Alan Jenkins
2016-06-20 13:05 ` [PATCH v2] " Marcelo Tosatti
2016-06-20 15:22 ` Alan Jenkins
[not found] ` <87bb5b7c-ab8c-7bb4-b01d-f535eb716522@gmail.com>
2016-06-21 1:31 ` Marcelo Tosatti
2016-06-21 7:50 ` Paolo Bonzini
2016-06-21 11:35 ` Marcelo Tosatti
2016-06-21 11:37 ` Paolo Bonzini
2016-06-20 13:11 ` Marcelo Tosatti
2016-06-20 15:22 ` Alan Jenkins [this message]
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=9407acfa-2923-6059-b11a-e0944263a248@gmail.com \
--to=alan.christopher.jenkins@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@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