Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2157109lqa; Tue, 30 Apr 2024 09:29:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcjkqSqEgWaRCseGJ8QJ8Od0XHD6yvMl0Kl4iSn+eVvkKmLSiRTH3kDjdF1AEoSR3lWDFdhqHQpsqS/Bu81WvgVbWfKul+VYy5wc9FVw== X-Google-Smtp-Source: AGHT+IG8OtFcK9kQmWqHzhfUclxF4Wa5QMDWU18cD706ycfIdsxI8Otz0TCXRjoQSWm5yOu19NAw X-Received: by 2002:a17:90a:9c05:b0:2ac:9baf:25b5 with SMTP id h5-20020a17090a9c0500b002ac9baf25b5mr3317928pjp.25.1714494569334; Tue, 30 Apr 2024 09:29:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714494569; cv=pass; d=google.com; s=arc-20160816; b=0o5JG1Zsxq6PK6Wr9CETwY+0gZoN6tJM8IwZF67hx7zHO+1JZrIK1+E16A4SfwwhQ7 Wrz/xRlUEDqeWKqN24x9qf6DhUqtaA1LLhKMFhFVDzKXyt/i4wkIzkdz/RQpRabADsEy 2jTWAb3rQhno+mRSGOvsojsLzK6sm3qtX3Ynpgt8wKAcdxuTYUy7trEYECK9eRD60udM nYMznGh0HrAyK9dAX+iHHj88qpvun9eQrFuDfnSMN0s4zjE37BjVYrVYVKBpU0k0wns9 r2M/FTBIJs8/wDZvSJoCEPQMPhLOBactDFPbZjzNJ/Qf2R/esYsQXsfzBHT/DXMkT3wB VsYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=Nnx8PEh4F0H2pwvd5VJa9QAeHpiBNkwiDpkDCA/9d28=; fh=bEinGHa90e6IryLqQyIL6LCRQLwO2ESr7vzi43iMdps=; b=03qr6KZ6V+E4V17+i1P7Pnddv8y30546dRxyENBlTFnmGDzRFocUdtZPJscmeyTfhG +qqpTa+JWeuqSJ9ooSwbyJxZ32MChNPkDAcV/Dqij5FmyYXupvPT6Z+p0AZTnvLl/SNG 3RnvHj4sX9ed/oihYU5eHQmGsGz3zCf/f2nar97NXs/VbcqMae1bKJmeOBUASPu2WLcG pVXKrDO/Z9m1LwR6uARaeiEGE8CBEfArk8Ga3fkqaMEB3yUJImzArQAtlWXKcM5NIFgN GiFJbUcZDwl5vfWdXly2e9b9z9HHZg5t6AHrN/TiE/JwvJpiaLd63HnO3kG3yoyLKeDu +RCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Tsd8c9aP; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o13-20020a17090ab88d00b002b104c92b0csi6037521pjr.119.2024.04.30.09.29.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Tsd8c9aP; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5FFACB27172 for ; Tue, 30 Apr 2024 16:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E0B9179203; Tue, 30 Apr 2024 16:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Tsd8c9aP" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E603175541 for ; Tue, 30 Apr 2024 16:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714492931; cv=none; b=CZRcwAn3hHdfVnb4q9vgBXQ/tNWDSZloI1OavuJwU5I+JdSzlvUlE0LGrJfx43jx4X3RCDQ1DQ4GoXSC8kakvD9XGnFsMVbzYNN4uZ5G/zUOvjAf/yRX2Pp0vkllnXAlFurFfZ42WrX8MKcpkXl6ZjNruovhli/D8vktmoAG4Ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714492931; c=relaxed/simple; bh=t9C7Ye6tArU7Baw32FWLZftC1ohgE3SE8Qu1VszqBkA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Zg+hKqt+OsjwqQfQcok9ncwsYOUwqehFJkWwXSofrNeZzIz9CX8FRElvoLUcXo0ix+CP4eM9Jhvil6y1zXkg5AwKGBul99rTpENZYTkXj7Dx5prRCM+6CIAF3PKGYwOAxba+iCu5NuUkHxLK/+f8y+hxK+H+H4P0hgKqcFKURmk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Tsd8c9aP; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-61c9e368833so9393437b3.3 for ; Tue, 30 Apr 2024 09:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714492929; x=1715097729; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Nnx8PEh4F0H2pwvd5VJa9QAeHpiBNkwiDpkDCA/9d28=; b=Tsd8c9aPA3axGEFylUe+D4SNOxlu5bv7IyNh+ZARaAIkNNdyPKAI/l44JCm0R9wKHe PUGVpGpwH4ojSF1Pn+HYodeD7HV4jTa7d47mDAL2ba+eCt752oQkxx8VeOndXpiqSOiU VYiESNIqy69nO47Vh+SIXtEI4R/Ju4kukYSaXxkKPeK+Ehfb8fa+lknCP5WJk9QxiETn Ph+bSGj2jGQ+btVKuZEgpWf3rcZb9oe1z7BWJEn7MCKdpGWGPwj9CCs4jpPlmRKcEqr3 zUwJv6GvP0JYmFV9Q5q3HUr08hAmNUv2tBWxkjSsgM8K4n7KOLiBqt1s1RV5QsgxYVnv 1IQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714492929; x=1715097729; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Nnx8PEh4F0H2pwvd5VJa9QAeHpiBNkwiDpkDCA/9d28=; b=vYzkRcNwJ9zYPvtZcKFchfolDrnW+Qkw2Qz2n+yfhLaZPjh7uZ1qZpbJpeLX8QYbZc BYQysGjmNR9UbmHX61k/hWKfvr9VTM5zMdXWNChbnGYiLgFIUexdNlNHxE9p3YHDxH2r NwscD6PRhnP7+I509vqz99biHsVaeBeibKy7ntVVPaQS5HfBgvi2n932d4SEH0GV/914 8JPE3sM2kvUcpCjlgUhdU7LpUiqaWRw2w/KL2XcTRY3yHllEY7QSdRO4iH5N+cHHjdso zHr4Y32zYzdSb49tl6p3mCEgPwJvrSk2zy6YRwxZOEWn3mBD5NqpRNGSJaFOfY1BQ95b ThiA== X-Forwarded-Encrypted: i=1; AJvYcCVvojcHZujdTfiMU03WHK8OJmRNZ1EpBs25ley0v2aQqHrIbOx0kPU30NBbbyTfcg3YYQ3a8Ig89f4VUiEMJCLrXWFG4TQf+Hf9UUsy X-Gm-Message-State: AOJu0YxVl7JdAd3IVkeVC/KXO9pQ7t2JN97XwVlcY8QGW6IXZMr8loT9 /DUhsFfCFACA9XN8LJyheAAAJcrU4nGjKgJuzAMbxZj++2BIS541LfVy/NAnurMzUKKTY589/Ua tpA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1002:b0:dd9:1db5:8348 with SMTP id w2-20020a056902100200b00dd91db58348mr4752342ybt.8.1714492928972; Tue, 30 Apr 2024 09:02:08 -0700 (PDT) Date: Tue, 30 Apr 2024 09:02:07 -0700 In-Reply-To: <38e124dcdbf5e0badedf3c0e52c72e5e9352c435.camel@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240206151950.31174-1-vkuznets@redhat.com> <171441840173.70995.3768949354008381229.b4-ty@google.com> <38e124dcdbf5e0badedf3c0e52c72e5e9352c435.camel@infradead.org> Message-ID: Subject: Re: [PATCH v2] KVM: selftests: Compare wall time from xen shinfo against KVM_GET_CLOCK From: Sean Christopherson To: David Woodhouse Cc: kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Jan Richter , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 29, 2024, David Woodhouse wrote: > On Mon, 2024-04-29 at 13:45 -0700, Sean Christopherson wrote: > > On Tue, 06 Feb 2024 16:19:50 +0100, Vitaly Kuznetsov wrote: > > > xen_shinfo_test is observed to be flaky failing sporadically with > > > "VM time too old". With min_ts/max_ts debug print added: > > >=20 > > > Wall clock (v 3269818) 1704906491.986255664 > > > Time info 1: v 1282712 tsc 33530585736 time 14014430025 mul 358755222= 3 shift 4294967295 flags 1 > > > Time info 2: v 1282712 tsc 33530585736 time 14014430025 mul 358755222= 3 shift 4294967295 flags 1 > > > min_ts: 1704906491.986312153 > > > max_ts: 1704906506.001006963 > > > =3D=3D=3D=3D Test Assertion Failure =3D=3D=3D=3D > > > =C2=A0=C2=A0 x86_64/xen_shinfo_test.c:1003: cmp_timespec(&min_ts, &vm= _ts) <=3D 0 > > > =C2=A0=C2=A0 pid=3D32724 tid=3D32724 errno=3D4 - Interrupted system c= all > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x00000000004030ad: main at xen_shinfo_test.c:1003 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x00007fca6b23feaf: ?? ??:0 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 3=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x00007fca6b23ff5f: ?? ??:0 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x0000000000405e04: _start at ??:? > > > =C2=A0=C2=A0 VM time too old > > >=20 > > > [...] > >=20 > > Applied to kvm-x86 selftests, thanks! > >=20 > > [1/1] KVM: selftests: Compare wall time from xen shinfo against KVM_GET= _CLOCK > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 https://github.com/kvm-x86/linux/commit/= 201142d16010 >=20 > Of course, this just highlights the fact that the very *definition* of > the wallclock time as exposed in the Xen shinfo and MSR_KVM_WALL_CLOCK > is entirely broken now.=20 >=20 > When the KVM clock was based on CLOCK_MONOTONIC, the delta between that > and wallclock time was constant (well, apart from leap seconds but KVM > has *always* been utterly hosed for that, so that's just par for the > course). So that made sense. >=20 > But when we switched the KVM clock to CLOCK_MONOTONIC_RAW, trying to > express wallclock time in terms of the KVM clock became silly. They run > at different rates, so the value returned by kvm_get_wall_clock_epoch() > will be constantly changing. >=20 > As I work through cleaning up the KVM clock mess, it occurred to me > that we should maybe *refresh* the wallclock time we report to the > guest. But I think it's just been hosed for so long that no guest could > ever trust it for anything but knowing roughly what year it is when > first booting, and it isn't worth fixing. >=20 > What we *should* do is expose something new which exposes the NTP- > calibrated relationship between the arch counter (or TSC) and the real > time, being explicit about TAI and about live migration (a guest needs > to know when it's been migrated and should throw away any NTP > refinement that it's done for *itself*). >=20 > I know we have the PTP paired reading thing, but that's *still* not > TAI, it makes guests do the work for themselves and doesn't give a > clean signal when live migration disrupts them. Is the above an objection to the selftest change, or just an aside? Honest question, I have no preference either way; I just don't have my head wrappe= d around all of the clock stuff enough to have an informed opinion on what th= e right/best way forward is.