From nobody Mon Jun 8 05:26:40 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFBC937FF6A; Fri, 5 Jun 2026 12:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662621; cv=none; b=fs1DOp1EJQJ4yM2SB6R+PoXWzW9fc2X0Rja1pq+DUAmNNeWc0yrjsQP6r4KKzXPo9gE5pXmeXXBHciYCBUpQqbbQSNOiCt4fczJa8kS5P9F/VVXm7mbAovE0JZdofvcgeA8TWun/aKn00vC+NsYKxnIkihziFfsY9E3KWaz9VEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662621; c=relaxed/simple; bh=/R6y3unk4pKkVfrl6n0bsbfveoCKPvTurrWCHYnfhnY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=KG1N/bsQHHjgeCDOL6YsgYbN7sUmMC3yCzYEyOR0aOk9FjPbsLexFZ3rneIoYoLamg48zpplIY2lLJmmXfLca5B2Amu8yuQBLCTKBrCV93Zaf3+IZCDRhj6NdG/5sKj649Nd4CQ5CD2u8zmRGhnXUVUa7uETmg8XGMOvEPkN6HE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E2aoMOQi; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pPjoOQ02; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E2aoMOQi"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pPjoOQ02" Date: Fri, 05 Jun 2026 12:30:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780662616; h=from:from:sender:sender:reply-to: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=NmxZElg95MosyEeyONVqYPyTC/ziYxlxLx/lL2vABek=; b=E2aoMOQiEe2mQayNWlMWPd6WB93/puN2Fzs5P3dEb+nFJ2OL2ClDYVfw6Vq9ywSObPoClI NodytQN53Ic/yXTWLr3Q6EDuLTQnCMTizB8lnSu0A0adja6iWKbZ90wAOQ9gkiKqMkPVQx u1jJVqGnphmlR2BfvdG/PlCq2IuIOVhsevwYP077nBfb/hwXSYAEmTr19cMm5Q7iuqv9js 1tByDFQHn0lFI/S23kmFf7SsquV0U9IpagVcmeW6Krw2dNSeu5xDkilGRRzudgCjmC2dOc rrRjm3X+qe6UNoBfjyR3ickWJc9lHDzoPCVPUJdVuGBOlEpZ/xs4Yf4Fyy5p2w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780662616; h=from:from:sender:sender:reply-to: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=NmxZElg95MosyEeyONVqYPyTC/ziYxlxLx/lL2vABek=; b=pPjoOQ02hXpgIvBRhR7tvj1GIqaX6GbTAuDcwANTNc7kK4oYR62S8d70q2ZLjPu9x/xGS4 FxG24OPt1iTS7YDA== From: "tip-bot2 for David Woodhouse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/ptp] x86/kvmclock: Implement read_snapshot() for kvmclock clocksource Cc: David Woodhouse , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260604095755.64849-3-dwmw2@infradead.org> References: <20260604095755.64849-3-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178066261460.710.10674604514411904145.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/ptp branch of tip: Commit-ID: 19fa3e50644d2d47fca713b0df640f67dcd26634 Gitweb: https://git.kernel.org/tip/19fa3e50644d2d47fca713b0df640f67d= cd26634 Author: David Woodhouse AuthorDate: Thu, 04 Jun 2026 10:35:17 +01:00 Committer: Thomas Gleixner CommitterDate: Fri, 05 Jun 2026 14:25:03 +02:00 x86/kvmclock: Implement read_snapshot() for kvmclock clocksource Implement the read_snapshot() callback for the kvmclock clocksource. This returns the kvmclock nanosecond value (for timekeeping) while also providing the raw TSC value that was used to compute it. The TSC is read inside the pvclock seqlock-protected region, ensuring the raw TSC and derived kvmclock value are atomically paired. This enables ktime_get_snapshot_id() to provide the raw TSC to consumers like the vmclock PTP driver, which currently has to do a separate call to get_cycles() to obtain a value at *approximately* the same time, to feed through the vmclock calculation. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Assisted-by: Kiro:claude-opus-4.6-1m Link: https://patch.msgid.link/20260604095755.64849-3-dwmw2@infradead.org --- arch/x86/kernel/kvmclock.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index b5991d5..cb3d0ca 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -87,6 +87,27 @@ static u64 kvm_clock_get_cycles(struct clocksource *cs) return kvm_clock_read(); } =20 +static u64 kvm_clock_get_cycles_snapshot(struct clocksource *cs, + struct clocksource_hw_snapshot *chs) +{ + struct pvclock_vcpu_time_info *src; + unsigned version; + u64 ret, tsc; + + preempt_disable_notrace(); + src =3D this_cpu_pvti(); + do { + version =3D pvclock_read_begin(src); + tsc =3D rdtsc_ordered(); + ret =3D __pvclock_read_cycles(src, tsc); + } while (pvclock_read_retry(src, version)); + preempt_enable_notrace(); + + chs->hw_cycles =3D tsc; + chs->hw_csid =3D CSID_X86_TSC; + return ret; +} + static noinstr u64 kvm_sched_clock_read(void) { return pvclock_clocksource_read_nowd(this_cpu_pvti()) - kvm_sched_clock_o= ffset; @@ -156,13 +177,14 @@ static int kvm_cs_enable(struct clocksource *cs) } =20 static struct clocksource kvm_clock =3D { - .name =3D "kvm-clock", - .read =3D kvm_clock_get_cycles, - .rating =3D 400, - .mask =3D CLOCKSOURCE_MASK(64), - .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, - .id =3D CSID_X86_KVM_CLK, - .enable =3D kvm_cs_enable, + .name =3D "kvm-clock", + .read =3D kvm_clock_get_cycles, + .read_snapshot =3D kvm_clock_get_cycles_snapshot, + .rating =3D 400, + .mask =3D CLOCKSOURCE_MASK(64), + .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, + .id =3D CSID_X86_KVM_CLK, + .enable =3D kvm_cs_enable, }; =20 static void kvm_register_clock(char *txt)