From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 731BD37F734 for ; Mon, 23 Mar 2026 21:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774301818; cv=none; b=GDaF1pVI8bqsbKyavLIvHZfls5KrRuvAduCH7Mhu8Zmpbh6CP6oocdqty46fOlbA8JlfsNzTrjE7xk1zd7L1QfP9MguJlXKDhZk6NQT2hE2hPfRUBeSVoKNmTUir++EsFQAXHhBYy0omw0+pTWnyj4LlvvcXCs6gvZUhN/zeJaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774301818; c=relaxed/simple; bh=oyDN7nuSM2OGyUAjqdE6Ab7mmYyTdjB+sca88ayvsXg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=FT+M+qkRcUFvIckBZrZ9o4zGJuvG1+DE4reIoOHgtrmt/ecrjhcANUUyJu1jsPApIvg3rR/0xmTjVY3k9gWXprQoOFRY2bPuQX1lxiTxvZGV1d8yNDCA/omuEXId0uAvv8KzuRF+lePWLp3Ggq0+/WezvfIXYw7olqLLjH7jrDI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oL9ZUuTm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oL9ZUuTm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC45C4CEF7; Mon, 23 Mar 2026 21:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774301818; bh=oyDN7nuSM2OGyUAjqdE6Ab7mmYyTdjB+sca88ayvsXg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=oL9ZUuTmJ4mcytfxA8sQSsupTHanjBggAKt5Gs73PhKGZI8paeYhETreHV39yFRRz IlNI8hkh2POYI07Ljf/LTEPkF9kc/Dqaaowzk9EkvMS5jsBhV5WooXHDcwiRV2kFfO 2n2lBBc1GglWDC2i1nJZ2Ju8LJ4xjfnaJyaaurm5/HALkrSsnwG/0YfSFX0nwqokql WRStodrBt/2PXXTAiQtnbxeYx4a1nWqmLrLAs1FRs4gYsel1w5pUqOYI3KRD1jraIQ ZSN9d7opwyNqU/E7u3l+fpoczI1MAFWugSPFXai5tHK2PzlJDWFERkFyTtCvDCGHqN JqMS8qwb6Gm9A== From: Thomas Gleixner To: Michael Kelley , LKML Cc: Anna-Maria Behnsen , John Stultz , Stephen Boyd , Daniel Lezcano , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "x86@kernel.org" , Peter Zijlstra , Frederic Weisbecker , Eric Dumazet Subject: RE: [patch 19/48] clockevents: Provide support for clocksource coupled comparators In-Reply-To: References: <20260224163022.795809588@kernel.org> <20260224163430.010425428@kernel.org> Date: Mon, 23 Mar 2026 22:36:54 +0100 Message-ID: <87v7emgrd5.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, Mar 23 2026 at 04:24, Michael Kelley wrote: > From: Michael Kelley Sent: Tuesday, March 3, 2026 10:45 AM >> From: Thomas Gleixner Sent: Tuesday, February 24, 2026 8:37 AM >> > >> > Some clockevent devices are coupled to the system clocksource by >> > implementing a less than or equal comparator which compares the programmed >> > absolute expiry time against the underlying time counter. >> >> I've been playing with this in linux-next, and particularly to set up the Hyper-V >> TSC page clocksource and Hyper-V timer as coupled. Most Hyper-V guests these days >> are running on hardware that allows using the TSC directly as the clocksource. But >> even if the Hyper-V TSC page clocksource isn't used, the timer is still the Hyper-V >> timer, so the coupling isn't active. However, SEV-SNP and TDX CoCo VMs on Hyper-V >> must use both the Hyper-V TSC page clocksource and the Hyper-V timer, so they >> would benefit from coupling. It's a nice idea! Did not think about that. I try to avoid the virt dungeon as much as it goes :) >> > +static inline bool clockevent_set_next_coupled(struct clock_event_device *dev, ktime_t expires) >> > +{ >> > + u64 cycles; >> > + >> > + if (unlikely(!(dev->features & CLOCK_EVT_FEAT_CLOCKSOURCE_COUPLED))) >> > + return false; >> > + >> > + if (unlikely(!ktime_expiry_to_cycles(dev->cs_id, expires, &cycles))) >> > + return false; >> > + >> > + if (IS_ENABLED(CONFIG_GENERIC_CLOCKEVENTS_COUPLED_INLINE)) >> >> Since COUPLED_INLINE is always selected for x64, there's no way to add the Hyper-V >> clockevent that is coupled but not inline. Adding the machinery to allow a second >> inline clockevent type may not be worth it, but adding a second coupled but not >> inline clockevent type on x64 should be supported. Thoughts? >> >> After fixing the u64 typo, and temporarily not always selecting COUPLED_INLINE in >> arch/x86/Kconfig, the coupled Hyper-V TSC page clocksource and timer seem to work >> correctly, though I'm still doing some testing. I'm also working on counting the number >> of time reads to confirm the expected benefit. > > Gentle ping. Any thoughts on this? (And on Peter Zijlstra's "deliciously insane" > follow-up?) Sure, we should be able to support that and I think Peter's suggestion is pretty clever. Did you get it working? Thanks, tglx