From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 DAF8E3FCB0B for ; Fri, 29 May 2026 14:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780065924; cv=none; b=QvkVmhLuwHE/T3+bIXAc3lGG6DW20z32G1XjvohixByMwUiWGvQCPDapqs6FYxp361PSl95h8GhHoMg4HeFNLfoQfXXwtbHTi5pubrt3LKgDW1NR+2tYq/YV8oSyLYFoPZKJXFj67JOSS52mmzE4CLgxIMa3yNHd+y7PWqH6sfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780065924; c=relaxed/simple; bh=lDwpL4pN2Hd7khkwmK25Y7B4/KyUm/MaSweyAhy8p7c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hJyq+lUYHWUnRQ702ZYFUE6vvbXwXKrjileNbOAt8xbFdYN48jI5CQEpQ0xglxhltNllYHQwqUEZXWjZ41OPiCqDJXGzZCoglyFvvEQjqNYoOu+4oUmNMtXdRDOXac8CSeqpN33Pro95AU1/bKcaEvuJ+KG84VMEgzv2cKJmVDU= 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=tXRLBJuU; arc=none smtp.client-ip=209.85.214.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="tXRLBJuU" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf11699875so19126155ad.1 for ; Fri, 29 May 2026 07:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780065921; x=1780670721; 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=xo1ZeU9J2iCPf0q+fMxBulUq0vgLWRTwNewVlxT3hiI=; b=tXRLBJuUyzL+ruKOY2gYHtzMHh3KaAIfcLI2fiRhR6Yw1jnJEyMmKLwSHDGnlS6O82 6GIeSVn0bXOmTvpae6Wt47+96rrgwSulMi/oz4tuIEya58XYAIzbHQJl8apIZf+wjRm+ h/p6fcacDu1jsjjals+7drdYQjHlGjn82/JguWPVkOFb9E9UL9yF0Jk5YAsy1L1m3niM N6gqpcEL6Prj+dPppaBsfzRcb5AGYdTEjlOvxMJspO9SyMqxKR8p/sYEKXH8PvKUy889 paFb4KFfUe/uQCzBLCjCSkW1vEYukhWUH4/dPh9deUxxlW5YMZFkGeyJqoN57VfqLwQs CS1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780065921; x=1780670721; 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=xo1ZeU9J2iCPf0q+fMxBulUq0vgLWRTwNewVlxT3hiI=; b=JMeANLLzK0BPUcMCahcIRz+AoLIh7AStn12EfMEzWqwy1N8PQ7W/u2CGReTuvhX7Fh RpFk+CKQRC4Z42gIF+SXRRZHpLm2AT+iyJ6Boy5bnaBGFtHkLbbPEDn1sRWVr+mpHKay Fsy6XxYGoTIDYw7vgj7PyuOPsiZgrr3HAChl4KPI+oxSqBfNl0ycUygdaGG3+abdw+7e MEh1Ir2LcTX5Mvz8oGXIxcwmmtGuqHZQ9+kcPVyDxPJbq4IVcSBiERoJ5Fz/lvkYz7Lh YTcnsums43SWAOpH3BWq4E25Qij6iiIKkG1a5RKgyF9MuNZ+OqAjZMheialMXK25sV+a V+SQ== X-Forwarded-Encrypted: i=1; AFNElJ/5+JDh3KUqyazq1CYavrATijUsxXgmMPgMSMNe8ZyLH7jFMpwHwHYceZVDaUMCmcX/SjljiUozceEwXR0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw1SrHW/bgdlRwQGYxY6128B3IqE7N8eMzaDeo6QC74BEY+vSb R1FIp5gSy1Y3aje5eCJCwvdHwakH+qe8XZOt2QV52Zxh11C+M+3Zr/0EUC23nq3qaMVJ6YGSkKj EuE9+XQ== X-Received: from plblc15.prod.google.com ([2002:a17:902:fa8f:b0:2bf:238f:8196]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2448:b0:2b2:4fc1:f653 with SMTP id d9443c01a7336-2bf20d4466cmr29629345ad.3.1780065920784; Fri, 29 May 2026 07:45:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 29 May 2026 07:44:11 -0700 In-Reply-To: <20260529144435.704127-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: <20260529144435.704127-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260529144435.704127-25-seanjc@google.com> Subject: [PATCH v4 24/47] clocksource: hyper-v: Don't save/restore TSC offset when using HV sched_clock From: Sean Christopherson To: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Kiryl Shutsemau , Sean Christopherson , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Kaher , Alexey Makhalov , Jan Kiszka , Andy Lutomirski , Peter Zijlstra , Juergen Gross , Daniel Lezcano , John Stultz Cc: "H. Peter Anvin" , Rick Edgecombe , Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, xen-devel@lists.xenproject.org, David Woodhouse , Tom Lendacky , Nikunj A Dadhania , David Woodhouse , Michael Kelley , Thomas Gleixner 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 Reviewed-by: David Woodhouse Acked-by: Wei Liu 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.823.g6e5bcc1fc9-goog