From: Andrey Smetanin <asmetanin@virtuozzo.com>
To: Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org
Cc: Gleb Natapov <gleb@kernel.org>, "Denis V. Lunev" <den@openvz.org>,
Roman Kagan <rkagan@virtuozzo.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v1] kvm/x86: Remove Hyper-V SynIC timer stopping
Date: Mon, 14 Dec 2015 20:01:23 +0300 [thread overview]
Message-ID: <566EF5E3.7060000@virtuozzo.com> (raw)
In-Reply-To: <566EE9B4.4040104@redhat.com>
On 12/14/2015 07:09 PM, Paolo Bonzini wrote:
>
>
> On 14/12/2015 16:33, Andrey Smetanin wrote:
>> It's possible that guest send us Hyper-V EOM at the middle
>> of Hyper-V SynIC timer running, so we start processing of Hyper-V
>> SynIC timers in vcpu context and stop the Hyper-V SynIC timer
>> uncoditionally and lose time expiration which Windows 2012R2 guest
>> expects.
>>
>> The patch fixes such situation by not stopping Hyper-V SynIC timer
>> at all, because it's safe to restart it without stop in vcpu context
>> and timer callback always returns HRTIMER_NORESTART.
>
> Can you summarize with a "picture" what is the bad race?
host guest
start periodic stimer
start periodic timer
timer expires after 15ms
send expiration message into guest
restart periodic timer
....doing something....
timer expires again after 15 ms
msg slot is still not cleared so
setup ->msg_pending
restart periodic timer
....doing something....
process timer msg and clear slot
so ->msg_pending was set:
send EOM into host
received EOM
queued call of kvm_hv_process_stimers()
by KVM_REQ_HV_STIMER
kvm_hv_process_stimers():
...
stimer_stop()
if (time_now >= stimer->exp_time)
stimer_expiration(stimer);
But time_now < stimer->exp_time, so stimer_expiration is not called
in this case and timer is not restarted. so guest lose timer.
> The patch seems safe, but I'd like to have a better understanding of
> what goes wrong.
>
> Paolo
>
next prev parent reply other threads:[~2015-12-14 17:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 15:33 [Qemu-devel] [PATCH v1] kvm/x86: Remove Hyper-V SynIC timer stopping Andrey Smetanin
2015-12-14 16:09 ` Paolo Bonzini
2015-12-14 16:48 ` Andrey Smetanin
2015-12-14 17:01 ` Andrey Smetanin [this message]
2015-12-16 17:54 ` Paolo Bonzini
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=566EF5E3.7060000@virtuozzo.com \
--to=asmetanin@virtuozzo.com \
--cc=den@openvz.org \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkagan@virtuozzo.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;
as well as URLs for NNTP newsgroup(s).