From: Zelin Deng <zelin.deng@linux.alibaba.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Wanpeng Li <wanpengli@tencent.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH] Guest system time jumps when new vCPUs is hot-added
Date: Fri, 30 Apr 2021 06:40:05 +0800 [thread overview]
Message-ID: <1cdd15f4-1242-a21e-e2e5-cecfc93a1219@linux.alibaba.com> (raw)
In-Reply-To: <87o8dxf597.ffs@nanos.tec.linutronix.de>
Got it. Many thanks, Thomas.
On 2021/4/30 上午12:02, Thomas Gleixner wrote:
> On Thu, Apr 29 2021 at 17:38, Zelin Deng wrote:
>> On 2021/4/29 下午4:46, Thomas Gleixner wrote:
>>> And that validation expects that the CPUs involved run in a tight loop
>>> concurrently so the TSC readouts which happen on both can be reliably
>>> compared.
>>>
>>> But this cannot be guaranteed on vCPUs at all, because the host can
>>> schedule out one or both at any point during that synchronization
>>> check.
>> Is there any plan to fix this?
> The above cannot be fixed.
>
> As I said before the solution is:
>
>>> A two socket guest setup needs to have information from the host that
>>> TSC is usable and that the socket sync check can be skipped. Anything
>>> else is just doomed to fail in hard to diagnose ways.
>> Yes, I had tried to add "tsc=unstable" to skip tsc sync. However if a
> tsc=unstable? Oh well.
>
>> user process which is not pined to vCPU is using rdtsc, it can get tsc
>> warp, because it can be scheduled among vCPUs. Does it mean user
> Only if the hypervisor is not doing the right thing and makes sure that
> all vCPUs have the same tsc offset vs. the host TSC.
>
>> applications have to guarantee itself to use rdtsc only when TSC is
>> reliable?
> If the TSCs of CPUs are not in sync then the kernel does the right thing
> and uses some other clocksource for the various time interfaces, e.g.
> the kernel provides clock_getttime() which guarantees to be correct
> whether TSC is usable or not.
>
> Any application using RDTSC directly is own their own and it's not a
> kernel problem.
>
> The host kernel cannot make guarantees that the hardware is sane neither
> can a guest kernel make guarantees that the hypervisor is sane.
>
> Thanks,
>
> tglx
>
>
>
next prev parent reply other threads:[~2021-04-29 22:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 2:22 [PATCH] Guest system time jumps when new vCPUs is hot-added Zelin Deng
2021-04-28 2:22 ` [PATCH] KVM: x86: Update vCPU's hv_clock before back to guest when tsc_offset is adjusted Zelin Deng
2021-04-28 9:00 ` [PATCH] Guest system time jumps when new vCPUs is hot-added Thomas Gleixner
2021-04-28 9:09 ` Thomas Gleixner
2021-04-28 23:24 ` Zelin Deng
2021-04-29 8:46 ` Thomas Gleixner
2021-04-29 9:38 ` Zelin Deng
2021-04-29 16:02 ` Thomas Gleixner
2021-04-29 22:40 ` Zelin Deng [this message]
2021-09-06 11:22 ` 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=1cdd15f4-1242-a21e-e2e5-cecfc93a1219@linux.alibaba.com \
--to=zelin.deng@linux.alibaba.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/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).