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 5C280278154 for ; Tue, 4 Mar 2025 17:39:49 +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=1741109990; cv=none; b=SqmJPmc6jxP6LQvTLk48h2WEu0cfK17G9fuu5uK9AqBCCLWOBxmZNQwuCK+w7dHeb5dTTugVzzZ52odTzWkH+uWAar+kpO4NZHDu7ItnsbALHFnlsWq83wyGNSLUnagV13/qZ+VPY48jxDnASPt6UuLwlXi5f+6ENRMSgiIxx0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741109990; c=relaxed/simple; bh=i50rufOwf6vwyAuooSNBHw4J8VhV9XZ8F0ZF8cluBGI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WIlR16pjdFoYJk8dYgdR9G0kPbFR/Clg1DRwNpf4QXhHhz0qpml8ClSFcAnHM5bKnnXURiO2bQ/lWHfjy15ZZfbtfAFUa80Q9yfZjOGXH0O51YKPLZzK0pqwRXLQbYq8mAvXs9wWKH43IHKgfQ58aPH1HNVnGZwNAuTpnAl85Bw= 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=YxzjTcJd; 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="YxzjTcJd" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-22334230880so79945315ad.1 for ; Tue, 04 Mar 2025 09:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741109989; x=1741714789; 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=TI3FoVeE0Ra2glCU+l7ZrrB58ecOTFnnVt+cs3oYhCA=; b=YxzjTcJdvr8cZm5Z333BpkRAbVng5UVXGX8ZW8qGp3M/aJl+AQSg6qVuz0R385Sr2M 6Kk6NuXMuHVvypLko/03b4vXcNnCRePJ9p+fp9uYee/En6ASe50D0aC9QbPlAVkKU8j6 qYxecn2iyESRdyaWtxjujV62UYvzYO5V8kSt+0aFMr5UOzi1B7ZjXUBDIkI/urKJtzHM S28Ba7E1y5YsIB8TJDWwnWivIHMkH66JLWlNamZ40xMTQUYVfsyiKGs47XQ22d+boKsY 5US4pwmtPzDhIOzRzwqnH+WcPIoF8tl3alHJlZnulr2IyfPnvWVkm1vlraub4ptYrcg0 O/aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741109989; x=1741714789; 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=TI3FoVeE0Ra2glCU+l7ZrrB58ecOTFnnVt+cs3oYhCA=; b=cctMMlBzYlZEGvTi1ijG4iOADPtt/cDVn/gXyixWJe9wpia5bQjzMtu0Q/tzNDawgu IaAYRWaR/vxG7YgnUqDo1x26LQQdIsgfOQj1J6Xtadl5NN/4ueirYYzeJYKfHZYxp9fT bS0FsyYSKG7OowVFrlISMIXIGmYaRqXtPqa5yU7oHRG7rG1ebCM45Rvc9cAlPZEAIPhH OMmO1nf7scL4nEH7Rjr7yWpOLYEJfaspnOZUg/gPQqpCOP/vQm8EAlsP2Gp1DCQPDPhS qi4seRkszMH0ZDh9wfrX/t8TGSf9ukqgYif22lmJn6+QoiroLAtW6eioGo6vtdp6Ok35 LyrA== X-Forwarded-Encrypted: i=1; AJvYcCXr4aOSFzE0diyc3s9UK5zBRPIn3TUbbe98tpg+I+ES48BRgBzLaENGp8fc7luTo9LYvkpziw/X6ZnO@lists.linux.dev X-Gm-Message-State: AOJu0YzHWJ98v63rRwdJqhD1xNPd51wLcCJ6viMxGrioiJinM4uTZ7t9 j+/GefroVJs3wtc9bo4kdUl0Jvk4Ce07SLXlHHQvfukqVjsPUzyAIvLskB+vm+EVucSLUefJOLU 2zw== X-Google-Smtp-Source: AGHT+IGZddoSY2oyJ60dCyqtZiF8YnS+v36sYEMEslkao7NI/8RRXlf38IKWdXRybiMidO4JcJg+/iNohU8= X-Received: from pfbfw3.prod.google.com ([2002:a05:6a00:61c3:b0:730:76c4:7144]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:734b:b0:1ee:d418:f758 with SMTP id adf61e73a8af0-1f2f4cdb421mr28532451637.17.1741109988705; Tue, 04 Mar 2025 09:39:48 -0800 (PST) Date: Tue, 4 Mar 2025 09:39:47 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250227021855.3257188-1-seanjc@google.com> <20250227021855.3257188-9-seanjc@google.com> Message-ID: Subject: Re: [PATCH v2 08/38] clocksource: hyper-v: Register sched_clock save/restore iff it's necessary From: Sean Christopherson To: Michael Kelley Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "Kirill A. Shutemov" , Paolo Bonzini , Juergen Gross , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Ajay Kaher , Jan Kiszka , Andy Lutomirski , Peter Zijlstra , Daniel Lezcano , John Stultz , "linux-kernel@vger.kernel.org" , "linux-coco@lists.linux.dev" , "kvm@vger.kernel.org" , "virtualization@lists.linux.dev" , "linux-hyperv@vger.kernel.org" , "xen-devel@lists.xenproject.org" , Tom Lendacky , Nikunj A Dadhania Content-Type: text/plain; charset="us-ascii" On Tue, Mar 04, 2025, Michael Kelley wrote: > From: Sean Christopherson Sent: Wednesday, February 26, 2025 6:18 PM > > > > Register the Hyper-V timer callbacks or saving/restoring its PV sched_clock > > s/or/for/ > > > if and only if the timer is actually being used for sched_clock. > > Currently, Hyper-V overrides the save/restore hooks if the reference TSC > > available, whereas the Hyper-V timer code only overrides sched_clock if > > the reference TSC is available *and* it's not invariant. The flaw is > > effectively papered over by invoking the "old" save/restore callbacks as > > part of save/restore, but that's unnecessary and fragile. > > The Hyper-V specific terminology here isn't quite right. There is a > PV "Hyper-V timer", but it is loaded by the guest OS with a specific value > and generates an interrupt when that value is reached. In Linux, it is used > for clockevents, but it's not a clocksource and is not used for sched_clock. > The correct Hyper-V term is "Hyper-V reference counter" (or "refcounter" > for short). The refcounter behaves like the TSC -- it's a monotonically > increasing value that is read-only, and can serve as the sched_clock. > > And yes, both the Hyper-V timer and Hyper-V refcounter code is in a > source file with a name containing "timer" but not "refcounter". But > that seems to be the pattern for many of the drivers in > drivers/clocksource. :-) Heh, wading through misleading naming is basically a right of passage in the kernel. Thanks for the reviews and testing! I'll fixup all the changelogs.