Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4013319pxv; Tue, 13 Jul 2021 08:50:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY5kOGB1qznJ+ePdJaJNx30R57XFL61Pf9vfLWxE3c88cXpOw+utexv52t1aCYTxat/rkw X-Received: by 2002:a02:8241:: with SMTP id q1mr4625533jag.134.1626191414384; Tue, 13 Jul 2021 08:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626191414; cv=none; d=google.com; s=arc-20160816; b=y7N2sTWEiQ317Ev5pDTDtob3qa2iY4iDn1coSTI05R/K0zMLfkiQOkWxnPmkM21CW2 r59iErDOha791fqHQtohnSQy3fDT2BtuO7jk+Pi66bSFuR6ZD98WvDo/HsKlSySEu5jX dEIsVedBise742aDwA2IsHUieZapDNEJmMHFAjkuWOJFRXC8loqQmPeTika288cj8AFq OA592KuqmcaFziKNdN4ynW4R6OX0ekeELlitF8Dl0rakvC+IiTsM1fxvUirELwyJ+WYv XtkbRXlLK5reSVAUmwbfW9hodofEJ+ADRLw9plBOH1/j54T/NHoQh76Lo7jn774QFkKA KsqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jG0GlQf65FSs7wAywgVrWxVXba4Vuqs6QN9P6/U3ebY=; b=dgN6BgQ7qzwZSRr08bCwV3xxosUKHo3O1472ymm6S/GKL7PeEbTbJ09cwxCp3DONug 7SO0vTtm/teaV1XaNQuqtvbEWKWQ1iXE9caY640qMr2gDCcJ/zjJ0JzRjl2KMjzSuff6 OG5xnIm0/CtOQFwelnO3KEmSzI2fNtT0jkOwvmCcmHMTXKHBkFW+4SzD9MtDRvBrG53k fYiKUtuZggGyjc9VrbmQQ60bwVnXSIBQimsi6Piz70yFqw0RtNfD1T/dlHsflQVqEjGc 6Xjc0yFhtOiPJGgycaIhS3Uught+34XHhuAeQu9ZXw9ThLm9FEpd3GpUdnBFbw0IIkcH yDxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si20081298iob.0.2021.07.13.08.50.01; Tue, 13 Jul 2021 08:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237148AbhGMPuR (ORCPT + 99 others); Tue, 13 Jul 2021 11:50:17 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:35399 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237061AbhGMPuQ (ORCPT ); Tue, 13 Jul 2021 11:50:16 -0400 Received: by mail-wr1-f53.google.com with SMTP id m2so20060808wrq.2; Tue, 13 Jul 2021 08:47:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jG0GlQf65FSs7wAywgVrWxVXba4Vuqs6QN9P6/U3ebY=; b=TKpVO3WlHW+sBQ0RzmrgQXNHtpukbnSt8NLaeWtv1jBLp08jI4YxujYSPKqyc1iQBI 4g5/25Ptc8GLkVKpartSUdYPLop8mGpoX7te8Tnvw2jPPLrcsmlWbpXZ5cqTIzj0Prpe t9c1aQP1AHJ+Y9Z2rQW0ovaQYrPD1s71SQSBhp5JQiAPRtaQAQeGxr0k6PZC8fMsU1b3 Pj1NgKLK5PbRGYODCoqpeXwlEb10RNxyLTAuGCpJv62vG1RpSrmkxT4JDjAw78oN475C NN8b2DfCbxcTi7dBKf4sqdt1kqmHfn5xUtZyx+X++V+yKMgsxF+/gIsEOFEsaH3/ZkUn a1RQ== X-Gm-Message-State: AOAM530xOmIKX2S33BX0EMJJ5LEAOwHGwNmSCfK9EqBkxJivEOS/GzeF jgYJ3DYk5CbV1cgm70/PTvU= X-Received: by 2002:adf:b318:: with SMTP id j24mr6755990wrd.361.1626191244601; Tue, 13 Jul 2021 08:47:24 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id a9sm17581521wrv.37.2021.07.13.08.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 08:47:24 -0700 (PDT) Date: Tue, 13 Jul 2021 15:47:22 +0000 From: Wei Liu To: Ani Sinha , Michael Kelley Cc: Peter Zijlstra , Wei Liu , linux-kernel@vger.kernel.org, anirban.sinha@nokia.com, mikelley@microsoft.com, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-hyperv@vger.kernel.org Subject: Re: [PATCH] Hyper-V: fix for unwanted manipulation of sched_clock when TSC marked unstable Message-ID: <20210713154722.pqsofao7xp4ihg44@liuwe-devbox-debian-v2> References: <20210713030522.1714803-1-ani@anisinha.ca> <20210713130446.gt7k3cwlmhsxtltw@liuwe-devbox-debian-v2> <20210713131756.GD4170@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 13, 2021 at 09:01:06PM +0530, Ani Sinha wrote: > > > On Tue, 13 Jul 2021, Peter Zijlstra wrote: > > > On Tue, Jul 13, 2021 at 01:04:46PM +0000, Wei Liu wrote: > > > On Tue, Jul 13, 2021 at 08:35:21AM +0530, Ani Sinha wrote: > > > > Marking TSC as unstable has a side effect of marking sched_clock as > > > > unstable when TSC is still being used as the sched_clock. This is not > > > > desirable. Hyper-V ultimately uses a paravirtualized clock source that > > > > provides a stable scheduler clock even on systems without TscInvariant > > > > CPU capability. Hence, mark_tsc_unstable() call should be called _after_ > > > > scheduler clock has been changed to the paravirtualized clocksource. This > > > > will prevent any unwanted manipulation of the sched_clock. Only TSC will > > > > be correctly marked as unstable. > > > > > > Correct me if I'm wrong, what you're trying to address is that > > > sched_clock remains marked as unstable even after Linux has switched to > > > a stable clock source. > > > > > > I think a better approach will be to mark the sched_clock as stable when > > > we switch to the paravirtualized clock source. > > > > No.. unstable->stable transitions are unsound. You get to switch to your > > paravirt clock earlier. > > > > I believe manipulating sched_clock was never the intention of the original > author who added the code to mark tsc as unstable on hyper-V: > > commit 88c9281a9fba67636ab26c1fd6afbc78a632374f > Author: Vitaly Kuznetsov > Date: Wed Aug 19 09:54:24 2015 -0700 > > x86/hyperv: Mark the Hyper-V TSC as unstable > > > The original author simply wanted to mark TSC as unstable on hyper-V > systems because of reasons the above commit log will describe. Sched clock > manipulation happened accidentally because from where the > mark_tsc_unstable() was being called. This patch simply fixes this. > > Michael Kelly from Microsoft has tested this patch already. OK. In light of Peter's comment and this one, I'm fine with this patch. Michael, can you give an ack or review here? Thanks, Wei. > > --Ani >