From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 2DEC23C7DF1 for ; Fri, 15 May 2026 19:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778872837; cv=none; b=mVpLWLG65krdBAg/s2SDK9XOvVvBFRMsO5sDBWQ+30PRs4EH4viJkU9B/XeAxEAT7mh66W0NfFm0nYEA72z9mSO/pfcY7aV/7oRUuLZc+GzH9207D7Y+Qj7KfgTxkz67B3G0ot+JaJYnwPe3QHDjUYZsiJnWn9G31AacyQxN3Mw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778872837; c=relaxed/simple; bh=5ZroqPTAiGiCjkjdUwgIH01/p3JgUmk9yrzxGnD97ko=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ed+7beUsU8ageQs6Jy1/n2xrKVjw8/Bqlgv1QUAaBIElooLqODiY1MzR2arLdUQQrqOtax0ZpIHlK0NIu5TTBU3tVQU4AWkHY9FCrws2V2qyBPGylhXEG5/EL+Cet1X6LDGPYZf3vUX384DZhhhlGrlm4Pf5MEzGyggpYlI4I+Q= 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=od1d0dtK; arc=none smtp.client-ip=209.85.210.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="od1d0dtK" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-837d43e9ff3so95023b3a.2 for ; Fri, 15 May 2026 12:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778872834; x=1779477634; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=2d2hriGBYHFIT1h3oi40HlX5TSRUyuLIgvVXFrgjGyA=; b=od1d0dtKQea4g5h2wx1nLXnMZRIIhCn+9dNb2pRFkiEzqmNX8pA1TCKLwn+WcxDxTe u6+XoPq1VctC901ntJUaGEw8uLAxQHSDwqXDp56kVMdeuGrPVa/2aF2nnI1asnX4w/I9 zN3owAP9c0X9zDr1Rdw+exaXB47aJlF/qJ+X5kN2N8Cnbpya018G6zCEVKb0s18bWyuL m2ktBsj69fIdzywngTquGhNjdu8z1WuTwOEuqzGDDaGbtv/y1yoKZlx/7MOPGdyUIBrA taCUGXi7iG5VWIyY1JGGHu4/kRiIUorDrhyyH62aMIveUQkRbkBBVp9zKzOY2ECSwknH VEXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778872834; x=1779477634; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2d2hriGBYHFIT1h3oi40HlX5TSRUyuLIgvVXFrgjGyA=; b=oLGrigleJBV3DgrAWYxhJz1Sil6//szCnlHKQ3nJ6Dz0eZEOoEAFwljj7SO7EbWS8o oddLgpiUSvg2KzniKSyOO5AtzUXQn4LKKPHU+30do1nQiWkCQhaQMDdHOAfQBVtlq+Sp gAPvW6Sk968l7T3M0pQyNfe/VTgLgcWzJL7d3zFy9AO6zFCaevH+WuUvmPn0eIqbkJnZ VrMc3rq4OpOjxSn9y3wE9MaMl773VsMl8CFEDTVEjt0v7h6bplqfDcnQmuB6FtPCrwc9 6sb45JYjRB7v8JqPROi9m9xk4Li9k7uIQvNwBdsYr8pkG8WCaUN8Fiw1/TOXANL/V6g8 rhzg== X-Forwarded-Encrypted: i=1; AFNElJ/4jdbu231ZKaa5aZKKV/8/r5R01t+aCYAa7BD3g31Z/P4zx7vNMaSRjbV/NpG7mN0OGSIPu2fMrLKmwOU=@vger.kernel.org X-Gm-Message-State: AOJu0YyLm7W3kTX8AgCIoJ9n01kzVXxM1VncPzR2p5npsfSYa3vn1St3 S8PGGTcGOUeIEy0on6+sCC/tjV1rA35wGrsCQE+mZAxsZyyJbfVExCNFzXyDiz4ZBz6/LXM7J75 Xcmfhag== X-Received: from pfblg3.prod.google.com ([2002:a05:6a00:7083:b0:82f:bf29:61aa]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1ca4:b0:82c:6b1b:7ad4 with SMTP id d2e1a72fcca58-83f33bc808emr5114483b3a.3.1778872834057; Fri, 15 May 2026 12:20:34 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 15 May 2026 12:19:10 -0700 In-Reply-To: <20260515191942.1892718-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515191942.1892718-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260515191942.1892718-10-seanjc@google.com> Subject: [PATCH v3 09/41] clocksource: hyper-v: Don't save/restore TSC offset when using HV sched_clock From: Sean Christopherson To: Kiryl Shutsemau , Paolo Bonzini , Sean Christopherson , "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 Cc: Rick Edgecombe , Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Michael Kelley , Tom Lendacky , Nikunj A Dadhania , Thomas Gleixner , David Woodhouse Content-Type: text/plain; charset="UTF-8" Now that Hyper-V overrides the sched_clock save/restore hooks if and only sched_clock itself is set to the Hyper-V reference counter, drop the invocation of the "old" save/restore callbacks. When the registration of the PV sched_clock was done separately from overriding the save/restore hooks, it was possible for Hyper-V to clobber the TSC save/restore callbacks without actually switching to the Hyper-V refcounter. Enabling a PV sched_clock is a one-way street, i.e. the kernel will never revert to using TSC for sched_clock, and so there is no need to invoke the TSC save/restore hooks (and if there was, it belongs in common PV code). Reviewed-by: Michael Kelley Tested-by: Michael Kelley Signed-off-by: Sean Christopherson --- drivers/clocksource/hyperv_timer.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index 69c1c7264e5d..ac1d9f9c381c 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -527,9 +527,6 @@ static __always_inline void hv_setup_sched_clock(void *sched_clock) #include static u64 hv_ref_counter_at_suspend; -static void (*old_save_sched_clock_state)(void); -static void (*old_restore_sched_clock_state)(void); - /* * Hyper-V clock counter resets during hibernation. Save and restore clock * offset during suspend/resume, while also considering the time passed @@ -539,8 +536,6 @@ static void (*old_restore_sched_clock_state)(void); */ static void hv_save_sched_clock_state(void) { - old_save_sched_clock_state(); - hv_ref_counter_at_suspend = hv_read_reference_counter(); } @@ -553,8 +548,6 @@ static void hv_restore_sched_clock_state(void) * - reference counter (time) now. */ hv_sched_clock_offset -= (hv_ref_counter_at_suspend - hv_read_reference_counter()); - - old_restore_sched_clock_state(); } static __always_inline void hv_setup_sched_clock(void *sched_clock) @@ -562,10 +555,7 @@ static __always_inline void hv_setup_sched_clock(void *sched_clock) /* We're on x86/x64 *and* using PV ops */ paravirt_set_sched_clock(sched_clock); - old_save_sched_clock_state = x86_platform.save_sched_clock_state; x86_platform.save_sched_clock_state = hv_save_sched_clock_state; - - old_restore_sched_clock_state = x86_platform.restore_sched_clock_state; x86_platform.restore_sched_clock_state = hv_restore_sched_clock_state; } #else /* !CONFIG_GENERIC_SCHED_CLOCK && !CONFIG_PARAVIRT */ -- 2.54.0.563.g4f69b47b94-goog