Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1539393pxy; Thu, 29 Apr 2021 09:04:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUtMUUZk2XnKXylmVhpwVR6U+LHZSFPPzWhRqbRKMa5t4nibytTBQzDm2TopWGHwmq/Jf/ X-Received: by 2002:a17:902:b68a:b029:e9:7643:6335 with SMTP id c10-20020a170902b68ab02900e976436335mr281052pls.2.1619712261843; Thu, 29 Apr 2021 09:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619712261; cv=none; d=google.com; s=arc-20160816; b=At8D7rDNZRzo0/Zi24XfH42Fetrng1Z0R0mWvE92Qkz5+HwfjjzVAucBR8l74hVP5N 3TiMxLSdIz6fKiv4mPDnN71cJ4lb1QhdIDX8oqFWzFqdWfF6TM0BwbRxG0CdtR763dea 9tUYBQjl6PYj4SCIPvVceNlURcpLXi6a+XAmGDorGrwv6Z5YZlhStN953/gD4ibKVn9P q/eyFX1J56tbDLtk5yQ1bW9dS3Llb8TAt5xdj7OmonpQPId669ZelIGCY3NWLwmBjfMJ navWR5f/adp2UI8rymHAiakPkTtjbE4Rd2Z+g05aqCO7LiDBoN4Tbn/PbDuvliSpWt7M 52mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=8plJW1VXqdM/pu1ulaDOFaCnsDTuvu4fwYJsVAeb39E=; b=rdVWuxolJwJnK/ZrREGAcITJPXTz7RuTUBT0Q/nYhJP/Nsl9VPX1aDefBnVBEKclGS l9xJJDdXiT5AVbC5i+QBA9NrrIZPFDkFxX/3Y1WgFreiHPvIEDInOVOmLDlICTYzDLz2 D7p2mApI50MtG1WYLh2VOo3O6Nvn6I9dnGGs6afNQglNuGR8ntPWXfSGyNSTCybywsr+ 9/llKEJS5sgSRxA6bQeDLdOPMjne36ks1C7KQOoQkc2mUfNgMwdwHycHLsBL6jtXFdpj Y/LqUNxhdKSDqUOj25mqPiWZbJnQ5x6PeKb3fnDOfJ3N/t9M3mQ1JuF2RGR7XukyZcKm 28ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tDCrPYi8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=PTZIOGrG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z28si5166377pfg.81.2021.04.29.09.04.05; Thu, 29 Apr 2021 09:04:21 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tDCrPYi8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=PTZIOGrG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233770AbhD2QDf (ORCPT + 99 others); Thu, 29 Apr 2021 12:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbhD2QDf (ORCPT ); Thu, 29 Apr 2021 12:03:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5651DC06138B; Thu, 29 Apr 2021 09:02:48 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1619712165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8plJW1VXqdM/pu1ulaDOFaCnsDTuvu4fwYJsVAeb39E=; b=tDCrPYi8epRqOfmXjzRVd+hbooSGl783ckl6sQX1A5heow2ufo0jVGFKEUwjXHcqxVH/u2 UEDVrPawKlRzU0u1CeXG3MZ5zw7lLsQBOasplVMnlEMkdIQ9luxXJqYbNP5lLTOPeObQPC T8beFcOEQkHWSLIGJkuXPLvurVYfijBce/i4AElu/rvpMDGyRAy/63pdV/bmltVUUhBqeW YsM5rPA1ksv03dHKMXgRe+SI4SfxX97eoIncb4TO/9UYcYzl28ZFpjVnUPIaYwk4Hlcrzi Np7Jy14haEfQb1uDWblpVZHg7dkZwLkRdDKQT7syPiQ+ul4VMSPT18dzLoVPqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1619712165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8plJW1VXqdM/pu1ulaDOFaCnsDTuvu4fwYJsVAeb39E=; b=PTZIOGrGSXFPL5ab1UCrpZmd2Ah5VfdyMmMYN0nmPDQUhJGuf7ilDznRsamgSV3WP2R7n0 UFI1Xp9muTi41NDw== To: Zelin Deng , Paolo Bonzini , Sean Christopherson , Wanpeng Li 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 In-Reply-To: <2df3de0e-670a-ba28-fdd2-0002cebde545@linux.alibaba.com> 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> Date: Thu, 29 Apr 2021 18:02:44 +0200 Message-ID: <87o8dxf597.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29 2021 at 17:38, Zelin Deng wrote: > On 2021/4/29 =E4=B8=8B=E5=8D=884: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=3Dunstable" to skip tsc sync.=C2=A0 However = if a=20 tsc=3Dunstable? Oh well. > user process which is not pined to vCPU is using rdtsc, it can get tsc=20 > warp, because it can be scheduled among vCPUs.=C2=A0 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=20 > 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