From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A43B5C43460 for ; Wed, 28 Apr 2021 09:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C9556141E for ; Wed, 28 Apr 2021 09:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238087AbhD1JKi (ORCPT ); Wed, 28 Apr 2021 05:10:38 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:46684 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbhD1JKg (ORCPT ); Wed, 28 Apr 2021 05:10:36 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1619600991; 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: in-reply-to:in-reply-to:references:references; bh=OL8ns1Jd0hYAa1/76ixHBO3gJQaqokoqzKMxkacoGTE=; b=DwNcWU6lhZFEca3EY3gAqfjY2lRbJSUHSb1OsiRUKECkfftfyEBNZ1AfJRMGniV5oo6lZX yRiuAUlN1dEWRSXLyBnIRk9r2ppIsfDhPFd1Zu1MnwtqNC+rDLrHJKAxelczyjDMVJexk0 +hq7TVo/kWozpIyMrK8EHEcNwLgsRknxxnSs9qlGURCLio/NfcDx5ZOJME17Et9MmyMv2/ zWdP25xz97wAHuAHfp28cirB3AkfQK5/1FKA8xwQ16zkNwK9ZeHf1rZLuWI6j/kFj//ZUE YaIspFwEh6ag1M5ei+3HuTmdeVckSueB3Gdt7wamxlQOLOiMXaT2WOBpkciPug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1619600991; 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: in-reply-to:in-reply-to:references:references; bh=OL8ns1Jd0hYAa1/76ixHBO3gJQaqokoqzKMxkacoGTE=; b=xHWiM2KmX/UuADNH1lowDKhszNxBh1Jhm1rk1imi8/f9QvbB5AcHEVw/c14GoKsoBXnLOW GDHoFE3m+CiuDxCw== 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: <87lf92n5r1.ffs@nanos.tec.linutronix.de> References: <1619576521-81399-1-git-send-email-zelin.deng@linux.alibaba.com> <87lf92n5r1.ffs@nanos.tec.linutronix.de> Date: Wed, 28 Apr 2021 11:09:50 +0200 Message-ID: <87im46n5b5.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28 2021 at 11:00, Thomas Gleixner wrote: > On Wed, Apr 28 2021 at 10:22, Zelin Deng wrote: > >> Hello, >> I have below VM configuration: >> ... >> 2 >> >> >> >> >> >> ... >> After VM has been up for a few minutes, I use "virsh setvcpus" to hot-add >> second vCPU into VM, below dmesg is observed: >> [ 53.273484] CPU1 has been hot-added >> [ 85.067135] SMP alternatives: switching to SMP code >> [ 85.078409] x86: Booting SMP configuration: >> [ 85.079027] smpboot: Booting Node 0 Processor 1 APIC 0x1 >> [ 85.080240] kvm-clock: cpu 1, msr 77601041, secondary cpu clock >> [ 85.080450] smpboot: CPU 1 Converting physical 0 to logical die 1 >> [ 85.101228] TSC ADJUST compensate: CPU1 observed 169175101528 warp. Adjust: 169175101528 >> [ 141.513496] TSC ADJUST compensate: CPU1 observed 166 warp. Adjust: 169175101694 > > Why is TSC_ADJUST on CPU1 different from CPU0 in the first place? > > That's broken. Aside of that the TSC synchronization check in guests cannot work reliably at all. Simply because there is no guarantee that vCPU0 and vCPU1 are running in parallel. Thanks, tglx