From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 9321C2E8E09 for ; Thu, 21 May 2026 21:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779397299; cv=none; b=P3JasKSot/zpsOq3Oo9kZthTbDLsZRf7t4GLfQqenOeKPitTNV4fUdt4Cp1S9owKIBQuaW7+ODWY5Acv3qF+TZHa6TpCztKR6ALm7+QHH32Is5uczZ+N2wHSpwXFpJsQ+YRmwFS9prXB2BWCz0yGc2ZWx+fZ9oHWtlkzhrMCM3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779397299; c=relaxed/simple; bh=UTNkbHY7Wjr/dyzbQ6GvUNv1NaEz32luLYEXfy53m6g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lCtrfSV2MfEI5inZbwmpDRcqlSQtBSKDUDAXyo5jijwgsf9qPJqsXQdj2tR2W/TEn7CGD3giWDQTzJaB2rjSL//7LBA1m9j3GBKXHSzONybU6fPahPCBOlxfjOF+Z866mUtDzgXEsP+JCf+hKClLzTxC98LxBbP/C+ehBrgmx00= 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=krXqT5rH; arc=none smtp.client-ip=209.85.214.201 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="krXqT5rH" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b4530a90fdso116845645ad.1 for ; Thu, 21 May 2026 14:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779397297; x=1780002097; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=iN4mR6FXbVUwqAWLl+PlqYFyvLBNkg9d4d7Akdf1bJQ=; b=krXqT5rHcUGfzMufFvLUrUfftfp9ZEx4fn012f/SMkUNiwCHTYfb443S057/OITIlV ymcUVIu+Fc9UsmzIJpZJpdaR982OKL8vsgluOCJVCR1YqsTbYErQ1SWFwo682C/9T/WK C0zOTzMoFmzUPry/u69WXNPmE6VRDPKIj2mK+OmjS5wxcItSl0mGa+KgQW33VMUNUnN6 lYtcqwTL0einmu/FEfy6kZQpjGI8Aiv4eII5qdP5x8WunBFe7eCQg55cPOv8rDYVU4ko w81o8JW0ODpg8bxHu7PXbs7TjRBU5qwxNmsd2f8H45/4GNjjj7fdFWIt1rMDKOlaE3nQ BjUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779397297; x=1780002097; h=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=iN4mR6FXbVUwqAWLl+PlqYFyvLBNkg9d4d7Akdf1bJQ=; b=NBxhAoCPKawK+o1Xnk4fCrHsxvQhRH/cAB3P9NAnmYzJp2Ob0xAdkePyFHIJlO9/Us Qal/qQ57K4CzDcQORKRpD1qKDmGAGMHKeTMaFQ7Jo6OV94X/imfhHaPPt51lsV0XowlM 8OyQaE0o38e03pC3LtFlppE0srT6cXMi3xvLbvDFyvYjoDSTlw8fHcZzpgLtlMe+rBfM ZBLUJB8QDmWSfmo/8G+GJewFlg2UpBPQPHzvoKupDHtxfbLzHkYPlIZzjsaf48GQX6zO goRsvsOsev8RXIZ8AXvBcnVLKaWf6u+Prp5wOfdmu/KAGYLTQbp/R9iSguCTBmqEqWX+ qMRA== X-Forwarded-Encrypted: i=1; AFNElJ/8Xcn4Ad+ICKD50Fiz7tzcjdNFIPKwPEzmDotKe5pYYdM656ZIXmf6PV07wTsOhKN5DzPQjWFLakJF@lists.linux.dev X-Gm-Message-State: AOJu0YwKFCUhtbuIep8B6eplNPzQbMJYJS8spvkmirKi8+n3RDbUaSd1 0NFa/9Mvcfm8W3Vi4ePtB9ot43lYticBvOArdbM8FMCALyqNYe7xKyTOoMFFIjxyLN22S4BXLkY 5VbPhcQ== X-Received: from plge10.prod.google.com ([2002:a17:902:cf4a:b0:2bd:40d4:e407]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e84c:b0:2ba:4ad9:70f6 with SMTP id d9443c01a7336-2beb06aa272mr6036375ad.31.1779397296608; Thu, 21 May 2026 14:01:36 -0700 (PDT) Date: Thu, 21 May 2026 14:01:35 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515191942.1892718-1-seanjc@google.com> <20260515191942.1892718-38-seanjc@google.com> Message-ID: Subject: Re: [PATCH v3 37/41] x86/kvmclock: Use TSC for sched_clock if it's constant and non-stop From: Sean Christopherson To: Dongli Zhang Cc: kvm@vger.kernel.org, Rick Edgecombe , Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , x86@kernel.org, linux-coco@lists.linux.dev, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Kiryl Shutsemau , Paolo Bonzini , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Kaher , Alexey Makhalov , Jan Kiszka , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Juergen Gross , Daniel Lezcano , Thomas Gleixner , John Stultz , Michael Kelley , Tom Lendacky , Nikunj A Dadhania , Thomas Gleixner , David Woodhouse Content-Type: text/plain; charset="us-ascii" On Thu, May 21, 2026, Dongli Zhang wrote: > On 2026-05-15 12:19 PM, Sean Christopherson wrote: > > Prefer the TSC over kvmclock for sched_clock if the TSC is constant, > > nonstop, and not marked unstable via command line. I.e. use the same > > criteria as tweaking the clocksource rating so that TSC is preferred over > > kvmclock. Per the below comment from native_sched_clock(), sched_clock > > is more tolerant of slop than clocksource; using TSC for clocksource but > > not sched_clock makes little to no sense, especially now that KVM CoCo > > guests with a trusted TSC use TSC, not kvmclock. > > > > /* > > * Fall back to jiffies if there's no TSC available: > > * ( But note that we still use it if the TSC is marked > > * unstable. We do this because unlike Time Of Day, > > * the scheduler clock tolerates small errors and it's > > * very important for it to be as fast as the platform > > * can achieve it. ) > > */ > > > > The only advantage of using kvmclock is that doing so allows for early > > and common detection of PVCLOCK_GUEST_STOPPED, but that code has been > > broken for over two years with nary a complaint, i.e. it can't be > > _that_ valuable. And as above, certain types of KVM guests are losing > > the functionality regardless, i.e. acknowledging PVCLOCK_GUEST_STOPPED > > needs to be decoupled from sched_clock() no matter what. > > Has it been broken for two years because of pvclock_clocksource_read_nowd()? Yep. Because pvclock_clocksource_read_nowd() ignores PVCLOCK_GUEST_STOPPED, the flag only ever gets recognized when the kernel reads WALL_CLOCK, which AFAICT only happens at initial boot, and during suspend and resume.