Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2401111rwl; Sat, 8 Apr 2023 14:15:48 -0700 (PDT) X-Google-Smtp-Source: AKy350b+JUhYPL7zG3uIYI683HLwUEGQqMvw3yrVJNB+M7EmKIBY6/82MQ6CZ33fLt2cYp/ZmhTz X-Received: by 2002:a17:90b:1c8d:b0:23f:8752:98be with SMTP id oo13-20020a17090b1c8d00b0023f875298bemr7576490pjb.4.1680988548391; Sat, 08 Apr 2023 14:15:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680988548; cv=pass; d=google.com; s=arc-20160816; b=Whims5jbv33D1BkGj8zZ1sYEr/33fO4AeWRbTzc4B1qNaH1WAUY+ljFxLXzCPs84iX PkXcdLddNU7ZmkU705/NHGT71xzgbB8V+eEsr5TkZsq3/QlGTjkJcW9UiPX8i319bcfw 5kOv0HfynrL6XoNaZ7Vz9rIRkad7+7R2CUS2c0OuMk5DTf3te3MDrG2lkymwnOeFun1w W/GDdrHgaU9nmt+wQcDExMeKptjb8sMA8fuv4w45E8L8Hno9zLH14ZcyLuwSGcOj1T7g RMXPcfyQpH/e/uXY7CaiHNaXMmDCkVb8plWmw57aRBaLEepmqNiPIGa/kLFmeO+GZemO IWKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=xqFrzmZJD1YsHtTBjw3KnMW6cANlrpncaAp338SlGx4=; b=qYs8JcCjuTS7oIhjFtlO4MGoJem1rF6PC5BvmOQ4t/GN5GAzmCh51E2bt9k/45eh8d YhYZ4t3bSYTMiv+DII7lHDU71ka7UZFJ3WLYs+Z/X4jcdA4V1U1a1PaLsxeJdqBt8x9D EoNQ5iXPuGgDQI8k7M6eSdvtI69ryxZIkZrcbirExB3BPS3UG0QGE5FYfqMOcZBjjl9p 9mxKzQ1R2RVKwOogtlGYqnVHI02eA02wEbm5d5PI3FTeuaE79hehgYdPpXQrvfLRZeJ0 N2LPnil4Usm3Cl4IGSzIQiIRor4CfQfmiDKX/Ib+9dq9hgrM0YsZsC/dEdRhXOdxHulA XNEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=JlghanVH; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gi2-20020a17090b110200b00240e633e032si9253935pjb.8.2023.04.08.14.15.26; Sat, 08 Apr 2023 14:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=JlghanVH; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbjDHVET (ORCPT + 99 others); Sat, 8 Apr 2023 17:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjDHVER (ORCPT ); Sat, 8 Apr 2023 17:04:17 -0400 Received: from BN6PR00CU002.outbound.protection.outlook.com (mail-eastus2azon11021024.outbound.protection.outlook.com [52.101.57.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320C49758; Sat, 8 Apr 2023 14:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+yLu9cEbSL/v4/VKhtTA7D67wzO7kvvjivT5d2T3Pk7stFSaB1s3FggVcjZlrXaCiHZvURG2VGNcXQUTCZXxRCN+A5vVR9u9kMCZl4Nm5oVCL3ntPq6XDcNce0B471F/SvADsB5np2G8FRxF+G8oytE0/ClJXlHQIwOB9xXAkEuOwb5PUljNUfxYEyMCkw3JBLTh3ZcNXEKgj4fZ5I8D4VrklFZ9b2xCes2uipRbHGFA72BQUtrhMfJ86yoaret97CJSmvnbowqA/qskndGNsv0ECxkwVc0p5zj/ov5JN0z4zQLlxvOyMqC0nZz2pMewtzXMrKNwSOoFEZoIQUAdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xqFrzmZJD1YsHtTBjw3KnMW6cANlrpncaAp338SlGx4=; b=ISZRaybDJ/yx/5vWtlXqmoe5xTENcUxSJVqsgL9vveZB7vCQ883au9uD4y3gZ+yUnPnPdIBCnAhqrPvIpUh2l1ZutjfwojMwITsU7vmyF8+9YiC7G5xlH261QDwoPgT1l2zrG+ygh0SbhplYMfuuDqsKGWcO2QXAaxLdgj4UE3OMmshQgA7Q3SykUUggadfjC2JUokYerdljZUMIBXmvYtmryr1+nK/uZyzen3ewlsqBkve4UPs8jMx5dIa0MKwjnVBBqtntNNh4k5n+XBpX58UsNs2tGxLI+EBfIybdXHebOlJ/pI1zMvzpeLMeBIhOsLq9cV37Uw/pXVWQLdC7pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xqFrzmZJD1YsHtTBjw3KnMW6cANlrpncaAp338SlGx4=; b=JlghanVHVmhjt6gXhCM9Y1oePQMqrhb4ZC0Z1sOHlf8e4AuApzUrPnbZAPpBeSQKvgNjqGD5/rbkSXSfupYGlpMSv6CFqgs8fvN7FY4XPyC4H6a0xfa/OPKb2CLHnyFByTFVPdYvYmV27u7K3r9msJmlqQuZUU3Xv0TFqidIYYM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BL0PR2101MB1092.namprd21.prod.outlook.com (2603:10b6:207:30::23) by CH3PR21MB4016.namprd21.prod.outlook.com (2603:10b6:610:178::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.1; Sat, 8 Apr 2023 21:04:13 +0000 Received: from BL0PR2101MB1092.namprd21.prod.outlook.com ([fe80::97b2:25ca:c44:9b7]) by BL0PR2101MB1092.namprd21.prod.outlook.com ([fe80::97b2:25ca:c44:9b7%6]) with mapi id 15.20.6298.017; Sat, 8 Apr 2023 21:04:13 +0000 From: Dexuan Cui To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] clocksource: hyper-v: make sure Invariant-TSC is used if it is available Date: Sat, 8 Apr 2023 14:03:39 -0700 Message-Id: <20230408210339.15085-1-decui@microsoft.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MW3PR05CA0029.namprd05.prod.outlook.com (2603:10b6:303:2b::34) To BL0PR2101MB1092.namprd21.prod.outlook.com (2603:10b6:207:30::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL0PR2101MB1092:EE_|CH3PR21MB4016:EE_ X-MS-Office365-Filtering-Correlation-Id: bf045407-3bdc-4378-53ab-08db3874cded X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9gA/CFN05bgatktS5OF2LQ9KZn2mpBvLclcuPVLWdpmyC0PEGrcc9H70dDdi/luvBrWD0SndbGtT7e1jHurUrinsl4CwKmbD+SnJ9QG1rsV93+3+d1L81IIn//N9Du+KluZNHGDcvQI/7j6dfGZmzXtQyWqQMO7k2MUkv7e17AEMYlMJNUB5NURTrZyMJAthgDDwAtKJnOA42SJuYF9rJXvbt4OKqGzl6ksIUj5uXt5k1IIZZoXMeClDNmIx5x3NjZPl7flDEpxCjmJe6+hyB5spkF/ynOGE17NhJCyHyaQL9UbYENVdkok244kTrn8hpaLTXt6jhqbfkLdRhCEjCqe1Wgn/NK1dAIFSzIXrf60Iz+/DHECJok+i0TXMb/PswIo/BRxDLqx9zhcliNuEfoTEgCrhtvKcqlhasktXxZtzW6lf+pw00BAEwOLkU3xsGgLqsgGxOKKMAP+fe7lL026o2qVPWe1i4Dt899ya3+YYJCiu+QwWV8+K2PFoTuhenbcfq2TtV7ZCQUXmPaQMtNofS6qdpBTdcvU876zVXCjyBd+aXfR5YZO5KyMEwuIDOQNIj9/NP7QjZ2k4Xs06KqbVVqiZK0qvmj/u/kahkxI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR2101MB1092.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199021)(786003)(4326008)(66946007)(66556008)(66476007)(478600001)(316002)(6636002)(5660300002)(38100700002)(41300700001)(82950400001)(82960400001)(8936002)(8676002)(186003)(83380400001)(2616005)(6486002)(6666004)(52116002)(10290500003)(6512007)(6506007)(1076003)(86362001)(36756003)(2906002)(66899021);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?WOBg/fxFenTRpl18WGGF27qSddNdxSuFcMmDsmsKt3OWEhn8a82Rd+RPuxqa?= =?us-ascii?Q?AuQIFKRqA4eZNX8p50UGHmQdiUTdh/g+m3bcait6iczPnItDwilovCOhpUB6?= =?us-ascii?Q?OeQgc+qiBB5hlDXQfgZ/Ar0A9NSXswW4y8lvv8+8Y8bqRy8M4hKoEQHW1tPx?= =?us-ascii?Q?SRE7ahWSmczKOG3aRID6ekArASL2XcjPZxeIp4HTC+tVy+PB1B0sVZ8i1kDR?= =?us-ascii?Q?SaNeLpTYfA5b8GpPKaccC5ba0/TSszIvcMysKm57NR/3adt6bgmMKMZct2Re?= =?us-ascii?Q?6vwO3STz9GjKptqhFH/ORQfjfaNVOhMmdKZTbPimUAvorlXzMHAMqYR4QqXL?= =?us-ascii?Q?G+VIggL6EfQet82N8wJLKINaM2bU13MOItuAvQpskRgWYZ41SQzDiau2CE4f?= =?us-ascii?Q?W8LqjvjlRgq+nx97J0PROG5i5oWL964FOJwcAQzQTBgPENNZosOrnv9k6XFQ?= =?us-ascii?Q?sjF7HrPU9bsUnYjIJYsxr0bUdV7dHQtc89ZsCOWpac+nE+iBKBXMAnEBIJLK?= =?us-ascii?Q?czmkQDwKv9WHdbS+IH3k1vgbEXGPIjXLjUPmc86hoq/nz0tQ3W6pZee82pq0?= =?us-ascii?Q?0cGEFsmIpGFfr/C8i6zZ0KjcjXOjB5xedlF9dN3+88+cX6wszgOXpgqx00z3?= =?us-ascii?Q?JwXBRQSIjGsb7NmqI3Ftzj7OWG4qZ+QgISKczy2LLZ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LRTuDa4fcI2am9kYjPysplWyWWPLtr7/arJCojmv3ltvytqmJkRDj?= =?us-ascii?Q?BsAIpmzCRv3o3NmtXF2JaHoeoeFgKBg8tskLdbcSLBar?= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf045407-3bdc-4378-53ab-08db3874cded X-MS-Exchange-CrossTenant-AuthSource: BL0PR2101MB1092.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2023 21:04:12.7623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VdFD9NEOuIV0PvlbuhejoZ8R0xwSvzuSp7m9zaA9XHcy6VVC9hLN4Ao4FzeexHGWfb8iXOCIWQscgMJkmf4EOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR21MB4016 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If Hyper-V TSC page is unavailable and Invariant-TSC is available, currently hyperv_cs_msr (rather than Invariant-TSC) is used by default. Use Invariant-TSC by default by downgrading hyperv_cs_msr.rating in hv_init_tsc_clocksource(), if Invariant-TSC is available. Signed-off-by: Dexuan Cui --- drivers/clocksource/hyperv_timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index c0cef92b12b82..7901a88ad9188 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -506,9 +506,6 @@ static bool __init hv_init_tsc_clocksource(void) { union hv_reference_tsc_msr tsc_msr; - if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) - return false; - /* * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly * handles frequency and offset changes due to live migration, @@ -525,6 +522,9 @@ static bool __init hv_init_tsc_clocksource(void) hyperv_cs_msr.rating = 250; } + if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) + return false; + hv_read_reference_counter = read_hv_clock_tsc; /* -- 2.25.1