Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1821460pxy; Thu, 29 Apr 2021 15:41:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzpmrv7jH9cBWktn345VSYlzIahC9EDBqM8d5MOhb1bYkLKnZhJJhKs9rD3I7Ed1fyScPi X-Received: by 2002:a05:6402:8d3:: with SMTP id d19mr2267330edz.302.1619736085903; Thu, 29 Apr 2021 15:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619736085; cv=none; d=google.com; s=arc-20160816; b=EcSfkcsVXGdUUC7akWrSONPmz2VHZTkKBy/in+3Flumc2CkAVx1oaRvPUlIja/tfWo X63pmuZmjM8XmCY5qJTM2QHZO8S499PY0FisatGTEhyzcutU7VFNEdRINIWWzuoQEOb4 3xKcbT/2Txh8nXhVKH07SHyi9qHoMF1Mg/+xB6xBznVr0QCgNV3RDG2ZiTtAhAiClvTF 3YeO0bRbTNiMuu4AgjddUTokCGt9xod5a8CjSKsf3TgNdNx7dTYIv64ltHVdcMEgQZ3a bhu7E+gBwtTomCkaYohmkQd/lxM7RLKoPEJ8z3kntVDhuxgf7fdFU9s4K1M2IZwnjJ+I znfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=e0AGVtdB28Rz48d1//0EX+0kiGErf+Te9ohSj181ntg=; b=XQVSKRnOZPFSSNizdg4hNBn0ZQVxq2uIIeg38bFe+uLufMRe8BtCl5E5DpT19/EWQi WF4J25l0A6VWmHDIgltUGDAMCeoJPYSMR03XQFlAhGbOtCZuTeQJhtRs8YC95UTa+SGk OhDnsdIHTbXCqWeC9MjjHaCCE1/HATuUfFX7oh38g4FkmDinIznll7KDz7tQeSte85gb 4OThBBtB/gKwVYVmc6aWGlKggdF1FlQppTzAc3I1D2eV3ROfzV/1uaqkep8jk4D1hl/B cvaZf3PXj+Duicgnf6yRtKRpxn6BvopT3mhBkDz2WEiNN7PEeylSwUbmxp/Gu/cchZD+ xl1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a22si1304648ejt.219.2021.04.29.15.41.02; Thu, 29 Apr 2021 15:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbhD2Wk4 (ORCPT + 99 others); Thu, 29 Apr 2021 18:40:56 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:37264 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbhD2Wk4 (ORCPT ); Thu, 29 Apr 2021 18:40:56 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=zelin.deng@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UXCbXGB_1619736006; Received: from 192.168.1.8(mailfrom:zelin.deng@linux.alibaba.com fp:SMTPD_---0UXCbXGB_1619736006) by smtp.aliyun-inc.com(127.0.0.1); Fri, 30 Apr 2021 06:40:07 +0800 Subject: Re: [PATCH] Guest system time jumps when new vCPUs is hot-added To: Thomas Gleixner , Paolo Bonzini , Sean Christopherson , Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org References: <1619576521-81399-1-git-send-email-zelin.deng@linux.alibaba.com> <87lf92n5r1.ffs@nanos.tec.linutronix.de> <875z057a12.ffs@nanos.tec.linutronix.de> <2df3de0e-670a-ba28-fdd2-0002cebde545@linux.alibaba.com> <87o8dxf597.ffs@nanos.tec.linutronix.de> From: Zelin Deng Message-ID: <1cdd15f4-1242-a21e-e2e5-cecfc93a1219@linux.alibaba.com> Date: Fri, 30 Apr 2021 06:40:05 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <87o8dxf597.ffs@nanos.tec.linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > >