Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2783394rdg; Mon, 16 Oct 2023 15:05:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEo5eZINdjsifS4UXgTO7jx1g64xwKFMc+Oslv0WN6IDJZB6SToHKG9dfe+/9Yy4e8EagC1 X-Received: by 2002:a17:90b:390d:b0:27d:5562:7e0b with SMTP id ob13-20020a17090b390d00b0027d55627e0bmr453097pjb.7.1697493953942; Mon, 16 Oct 2023 15:05:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697493953; cv=pass; d=google.com; s=arc-20160816; b=AZImfaYaq0Kstc8fuu0f2uB+I8nRsFOvJryYYblNCAiA3/XdkbvceSBPSArdK7vVRY IIimY9fuV52TL+Y73PMi8JvoqvAjEcRCoWfHsg6ajZKR2tg9SpvZK3kQbFTLAAYyZCah pOA2WLLLPSBJ+HN+sTAKnTzc+e+FAmrRkjZxDtbUJ+vALWoZ9B0VpkyyYHkivweNxfPV i66Iqi+TeT2icqRPySW6F1Id4Ze/bkn1K7VveWV8L2ojRxtj3cS2nATK4rsCTV1BAIoD fC9h/NRIVtCa2dqBw8ICBo/6JWiY1ZSl28THx33iAwWQwDzDr66z5mYplXgAVDGGiYDz 8wgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:content-language:references:cc:to:subject :user-agent:date:message-id:dkim-signature:dkim-signature; bh=dHE696cPxODN/lu1/Af0OQq5dfUl4EaERIRN4My2udg=; fh=umV9SjMYSHmOYQYfkw/CG22/Fayh3OhP496HedHsptM=; b=gMAIFIEWqwS4YqL/e7LB4laQ4wnMz3U9XKWfvUDsdkFm9QGNyJOmLQ8QJi5G07nytq cwZJV8ZzNtqFDmTC+IYYoAskP3hSP9IS9PDZYP5wwTilFnfvN+wV8g/0QghJjBE6Hrwt UK8dEnnwszUY8+0HPeafeBfCTt1CjTkcljci9x7NbYugFHtAQD7wth2Pjr+LJcKph3nw bEPZEwKtDeorvGs7njG7RkpWDk4lnSfOZGZlL7M2FEkoWwivgy8UpU/y8flgl08dPqx2 QkWa6Ik49y999IidCxCTbn4IfMZUHApr2E29vVEKNat3D678rCw2h+zYsjAffC4J3hjk DdSA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=uUlaB30S; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GD8pJe6O; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id lr9-20020a17090b4b8900b00277630078f9si260632pjb.12.2023.10.16.15.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 15:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=uUlaB30S; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GD8pJe6O; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EEFA2803C5D7; Mon, 16 Oct 2023 15:05:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232845AbjJPWFe (ORCPT + 99 others); Mon, 16 Oct 2023 18:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjJPWFd (ORCPT ); Mon, 16 Oct 2023 18:05:33 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA43A1; Mon, 16 Oct 2023 15:05:30 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39GKO3D4017528; Mon, 16 Oct 2023 22:05:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=dHE696cPxODN/lu1/Af0OQq5dfUl4EaERIRN4My2udg=; b=uUlaB30Sco06ApNKVNAZKUJmxWZ52UXMYfJ+5F+BucMfg2UleLB2shmEVCygbHcdacHj jdQyWJMP9iUoH1pBvE7KHvNZe9CTXDBz4xQaPVUeOEOh960LFC5bGiymdxOgkNcihj+I FU6nlVew7hY7LYuCz7vL5z4gwBqfSA8ZgGSxYqGwIlaW6Qem6lgN7Sr4oGtAXVFTR4Zc cm3dU23gjda0/EDOetaQ4DRWa0kZ13y2N/85S9p4o8tqTy5e1biFSC4IWquOzOBEvpk3 w+wXFAzku842WalxM+PAwhBxbU5oRzfKCwQqdmJQA5NLe91BU/zs4LbokfSppMYHGIJS 9g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tqk1cutyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2023 22:05:02 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39GJvKto040665; Mon, 16 Oct 2023 22:05:01 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3trfykg7bw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2023 22:05:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cLxhKX4nXGLbtvtR2jz1l4cPBFWRZqABn3cM8mdSOLIfspJOlPKCvgMQf6G+rsjAYh9ZUBTUnciuh5zAHPRjw/W6LONC3r1OFeacCLs5tCEIi+gvK2Z+1rr5COU5BZVo+EuAPTaQLWJ9/4kpGshgcNz2E7KtXSb1QPSAPyl4xMHZ8Szt6hczl+Yvr2HE47ZbsnE5lHWDPt2XR/mWOZ5j2NLmIE4o/0Mh9nxxWGZGRQcAU9bZOG/jG6UTLMxWfkwskKDnrSO8fpUnFrSFP1no+3quoT6TM7Ri9Sc7jJOwhlppN/c9zmC6K/0lcbybc9/h0CSwFGytvxH43dLoJ6yQAA== 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=dHE696cPxODN/lu1/Af0OQq5dfUl4EaERIRN4My2udg=; b=drD9oC81UHZOFH63njymxsog3HxVCD/PPfjZ2Lg5zDfFc7Sj7dE97OBS4e+1LSD5m5MdE3gUQIC8YBM21wfOS9APVcDJq4BHvLFtBo14gYzHLq3MY1hecqXQqx9q5N9oCjjEzyB4lNYJ+uIbwcU9UqU3kPbdeeM8v98a78do4OHHGN9vloOrXnOE+ia7zrgkuKHGJILx9oG4NxfQShyHnCeM0zJ+zr8Sn5q8r64ulpFtvKBTOPHIKKYrp44bfWcQbXv+LiVrzuXOgEGisA5WIlepw5lHb8vx6a0LQfE38pOXavnyo8hRxJCdPkrX7LogiiR1eG00DNDQD2NFFBbZgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dHE696cPxODN/lu1/Af0OQq5dfUl4EaERIRN4My2udg=; b=GD8pJe6OwkMQhmoIvJ2SJbePOo7o7a3ROEi0bdH77GqF3OLTvFcpgDIjbUNDRm+H4P6u0t09OPMPIplsq1H/phYQxKxSBl8/CT0QLTqOZX6xwQy2ajmwHBb9ufH/F8xeteKS7Q98Y/Th3IcXbDT7lH/kI8KYnYdH8JuI/AXEBSM= Received: from BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) by MW5PR10MB5807.namprd10.prod.outlook.com (2603:10b6:303:19a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.47; Mon, 16 Oct 2023 22:04:59 +0000 Received: from BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::8e27:f49:9cc3:b5af]) by BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::8e27:f49:9cc3:b5af%7]) with mapi id 15.20.6886.034; Mon, 16 Oct 2023 22:04:59 +0000 Message-ID: Date: Mon, 16 Oct 2023 15:04:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH RFC 1/1] KVM: x86: add param to update master clock periodically To: Sean Christopherson , David Woodhouse Cc: Joe Jin , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com References: <34057852-f6c0-d6d5-261f-bbb5fa056425@oracle.com> <8f3493ca4c0e726d5c3876bb7dd2cfc432d9deaa.camel@infradead.org> <993cc7f9-a134-8086-3410-b915fe5db7a5@oracle.com> <03afed7eb3c1e5f4b2b8ecfd8616ae5c6f1819e9.camel@infradead.org> Content-Language: en-US From: Dongli Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DM6PR04CA0023.namprd04.prod.outlook.com (2603:10b6:5:334::28) To BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB2663:EE_|MW5PR10MB5807:EE_ X-MS-Office365-Filtering-Correlation-Id: ee4e01d2-602d-41e4-74b5-08dbce93f069 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hRWyWzJZTsHbk9gWfCZjhqRFCox0t62FHYsHHh2gc4iiZlEds84jdQeyi4lXHFZm68f4/WUarKznbCy2vXWHKDvJFfTSIkp0YDC7FJGmof1PV1XjfyOMv3cbArdhs7mEwzU7gtikBxxlZlO767t8gUSiHDTf0koYdIHo9wOWaoW5Zg/v8gR8HRVzDnLeX2a9RHripO23SLyZp/rof0qSxqxD+KL2eMmH7I04Uj7iaDmvRIEG4FooTmmp9cYzor+3W18RJPss3/peFUVO+vQZ+zIUwQJ2LVM4JT8H32Y9EjHfODJEifmBxaVKrise9P+eZd59ITeOff7ZLON65lUTwTdo03aAEexovKa3xcZAK0zzRoaUSB6UzaNlsMbuhYwdJusUuoMdOLKrWg7Mp3HpNihSB5ndrnTMOf484KkvLOWKJdnr6d0KqX+oTn859trKIdUprHpAGF3oWvbHsEPMuNV1E2jia8Md3VUNEuDmb348rOkzrROOxwoCYKHlpi3RaCxbj1XrLV7NRLy3b7r3T0hxVEA3qD7cS7a6+f7czrygnRFTVaH3q4+hfCEf2RPfdSDY9YYwe192va0RSJJYbL0v849hRsO4OF8wbobdqdRieJ3u+pAa4Na3x7HJBipXIzfWbQpPSAKy2rZInNweLn6Ia63Z3QlIPvMy/6k1vBE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB2663.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(39860400002)(396003)(136003)(376002)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(31696002)(8676002)(6506007)(316002)(66476007)(66556008)(110136005)(44832011)(66946007)(5660300002)(478600001)(8936002)(36756003)(6486002)(4326008)(15650500001)(7416002)(4001150100001)(38100700002)(6512007)(2616005)(6666004)(26005)(2906002)(53546011)(83380400001)(86362001)(41300700001)(31686004)(21314003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Wi9seStNUFFKWDNzSXQvQy90TDd6NHJUQ3B4NGU5ZEVCYVF3RzY1dzBRRFRL?= =?utf-8?B?UFVmdlZVei9FN1g2MmxqZWhDZ0ZQMlFJcGNJVGxhNGRUcU55ai9vYW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tUYk1nR29xTU1DMENhYStmN2NFOHNicHdBam9FL3lXM2tm?= =?utf-8?B?NUlrVjBsZmxETmdDeXJlWENoSmw5M2YzMGpMS0c4VUNXYlo5ak9DOEtzMWFu?= =?utf-8?B?WDUyMlhET1NoOC83QzFESjJ6YzJwaStFaE04cGYzb09RZ2RSNVNUanFxcHN2?= =?utf-8?B?RDhaMExFeVhMVEpjNlJHdlJkNU54bVRvT09rMm5FYVhOSCtxaUdFRGdKV2Zz?= =?utf-8?B?MnEybVptZ1JHc2tseDRLRXIrSVVtbE14NmJGbXN6TUloL25CNElVMzBkY0Rv?= =?utf-8?B?ME5ZeitIVksvSk1zZVNTZ2VnOXpzSTRRZUgrZWxMbzhIL2ZmODl2ZkxKa2xj?= =?utf-8?B?VXErTTVRRllNK3QvUWVwblM4RlN2Z0UrMVNtdktLZ3pBdVFLMFN3Tk9MZ0ZJ?= =?utf-8?B?TFFpazZOaTNLeVdybk1kQVhoempyNk1CRFUycmdUZWNUelVYck9KcGNvajdn?= =?utf-8?B?NlN0cWY5cVJabytmbis2TEp0OGFtRUU2U3hBTUpVeDJrRTdBV0dIYVZQU3ZN?= =?utf-8?B?SlZHd2VSeEd5U3c1TUlmUVZkQVptTENSY21GWnhmT0pxbmdHQlI1L0pUQzFr?= =?utf-8?B?RWp3c2dzdElmY2pmV3djYjE4NmNxQXovNWhWaXQ5Y1FkN29HMHI5VG01cHRD?= =?utf-8?B?MHE3V0p4MGpWTFRldWFpZk5hTW5zeEpuSjdOUlhHSlZGWVRTRkNhR2RQTmZP?= =?utf-8?B?WnpoVzQ2bUViRjQzZTRXTzgxSE9VSllwQTJrejVwQnNxdGxtUXBDQ3Yxc3Jl?= =?utf-8?Q?lTsXw+V84Dis/jLOJPfTLgCD1gqU7VGzeo?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee4e01d2-602d-41e4-74b5-08dbce93f069 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2663.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 22:04:59.3819 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gCYVSbGBxii2XvN2Fcg0bf74u2JkwWXjQNKSGGZ7IlvEgQsp9Ps9ROSN6WXStPyMSQyMdVYaeba5M/RGLUVWhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5807 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-16_11,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310160192 X-Proofpoint-GUID: es_NBnJnkmuLaOgS_W7suYUDRwHGYP55 X-Proofpoint-ORIG-GUID: es_NBnJnkmuLaOgS_W7suYUDRwHGYP55 X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 15:05:51 -0700 (PDT) Hi Sean, On 10/16/23 11:49, Sean Christopherson wrote: > On Mon, Oct 16, 2023, David Woodhouse wrote: >> On Mon, 2023-10-16 at 08:47 -0700, Dongli Zhang wrote: >>> Suppose we are discussing a non-permanenet solution, I would suggest: >>> >>> 1. Document something to accept that kvm-clock (or pvclock on KVM, including Xen >>> on KVM) is not good enough in some cases, e.g., vCPU hotplug. >> >> I still don't understand the vCPU hotplug case. >> >> In the case where the TSC is actually sane, why would we need to reset >> the masterclock on vCPU hotplug? >> >> The new vCPU gets its TSC synchronised to the others, and its kvmclock >> parameters (mul/shift/offset based on the guest TSC) can be *precisely* >> the same as the other vCPUs too, can't they? Why reset anything? > > Aha! I think I finally figured out why KVM behaves the way it does. > > The unnecessary masterclock updates effectively came from: > > commit 7f187922ddf6b67f2999a76dcb71663097b75497 > Author: Marcelo Tosatti > Date: Tue Nov 4 21:30:44 2014 -0200 > > KVM: x86: update masterclock values on TSC writes > > When the guest writes to the TSC, the masterclock TSC copy must be > updated as well along with the TSC_OFFSET update, otherwise a negative > tsc_timestamp is calculated at kvm_guest_time_update. > > Once "if (!vcpus_matched && ka->use_master_clock)" is simplified to > "if (ka->use_master_clock)", the corresponding "if (!ka->use_master_clock)" > becomes redundant, so remove the do_request boolean and collapse > everything into a single condition. > > Before that, KVM only re-synced the masterclock if it was enabled or disabled, > i.e. KVM behaved as we want it to behave. Note, at the time of the above commit, > VMX synchronized TSC on *guest* writes to MSR_IA32_TSC: > > case MSR_IA32_TSC: > kvm_write_tsc(vcpu, msr_info); > break; > > That got changed by commit 0c899c25d754 ("KVM: x86: do not attempt TSC synchronization > on guest writes"), but I don't think the guest angle is actually relevant to the > fix. AFAICT, a write from the host would suffer the same problem. But knowing > that KVM synced on guest writes is crucial to understanding the changelog. > > In kvm_write_tsc(), except for KVM's wonderful "less than 1 second" hack, KVM > snapshotted the vCPU's current TSC *and* the current time in nanoseconds, where > kvm->arch.cur_tsc_nsec is the current host kernel time in nanoseconds. > > ns = get_kernel_ns(); > > ... > > if (usdiff < USEC_PER_SEC && > vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) { > ... > } else { > /* > * We split periods of matched TSC writes into generations. > * For each generation, we track the original measured > * nanosecond time, offset, and write, so if TSCs are in > * sync, we can match exact offset, and if not, we can match > * exact software computation in compute_guest_tsc() > * > * These values are tracked in kvm->arch.cur_xxx variables. > */ > kvm->arch.cur_tsc_generation++; > kvm->arch.cur_tsc_nsec = ns; > kvm->arch.cur_tsc_write = data; > kvm->arch.cur_tsc_offset = offset; > matched = false; > pr_debug("kvm: new tsc generation %llu, clock %llu\n", > kvm->arch.cur_tsc_generation, data); > } > > ... > > /* Keep track of which generation this VCPU has synchronized to */ > vcpu->arch.this_tsc_generation = kvm->arch.cur_tsc_generation; > vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec; > vcpu->arch.this_tsc_write = kvm->arch.cur_tsc_write; > > Note that the above sets matched to false! But because kvm_track_tsc_matching() > looks for matched+1, i.e. doesn't require the first vCPU to match itself, KVM > would immediately compute vcpus_matched as true for VMs with a single vCPU. As > a result, KVM would skip the masterlock update, even though a new TSC generation > was created. > > vcpus_matched = (ka->nr_vcpus_matched_tsc + 1 == > atomic_read(&vcpu->kvm->online_vcpus)); > > if (vcpus_matched && gtod->clock.vclock_mode == VCLOCK_TSC) > if (!ka->use_master_clock) > do_request = 1; > > if (!vcpus_matched && ka->use_master_clock) > do_request = 1; > > if (do_request) > kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); > > On hardware without TSC scaling support, vcpu->tsc_catchup is set to true if the > guest TSC frequency is faster than the host TSC frequency, even if the TSC is > otherwise stable. And for that mode, kvm_guest_time_update(), by way of > compute_guest_tsc(), uses vcpu->arch.this_tsc_nsec, a.k.a. the kernel time at the > last TSC write, to compute the guest TSC relative to kernel time: > > static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns) > { > u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.this_tsc_nsec, > vcpu->arch.virtual_tsc_mult, > vcpu->arch.virtual_tsc_shift); > tsc += vcpu->arch.this_tsc_write; > return tsc; > } > > Except the @kernel_ns passed to compute_guest_tsc() isn't the current kernel time, > it's the masterclock snapshot! > > spin_lock(&ka->pvclock_gtod_sync_lock); > use_master_clock = ka->use_master_clock; > if (use_master_clock) { > host_tsc = ka->master_cycle_now; > kernel_ns = ka->master_kernel_ns; > } > spin_unlock(&ka->pvclock_gtod_sync_lock); > > if (vcpu->tsc_catchup) { > u64 tsc = compute_guest_tsc(v, kernel_ns); > if (tsc > tsc_timestamp) { > adjust_tsc_offset_guest(v, tsc - tsc_timestamp); > tsc_timestamp = tsc; > } > } > > And so the "kernel_ns-vcpu->arch.this_tsc_nsec" is *guaranteed* to generate a > negative value, because this_tsc_nsec was captured after ka->master_kernel_ns. > > Forcing a masterclock update essentially fudged around that problem, but in a > heavy handed way that introduced undesirable side effects, i.e. unnecessarily > forces a masterclock update when a new vCPU joins the party via hotplug. > > Compile tested only, but the below should fix the vCPU hotplug case. Then > someone (not me) just needs to figure out why kvm_xen_shared_info_init() forces > a masterclock update. > > I still think we should clean up the periodic sync code, but I don't think we > need to periodically sync the masterclock. This looks good to me. The core idea is to not update master clock for the synchronized cases. How about the negative value case? I see in the linux code it is still there? (It is out of the scope of my expectation as I do not need to run vCPUs in different tsc freq as host) Thank you very much! Dongli Zhang > > --- > arch/x86/kvm/x86.c | 29 ++++++++++++++++------------- > 1 file changed, 16 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index c54e1133e0d3..f0a607b6fc31 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -2510,26 +2510,29 @@ static inline int gtod_is_based_on_tsc(int mode) > } > #endif > > -static void kvm_track_tsc_matching(struct kvm_vcpu *vcpu) > +static void kvm_track_tsc_matching(struct kvm_vcpu *vcpu, bool new_generation) > { > #ifdef CONFIG_X86_64 > - bool vcpus_matched; > struct kvm_arch *ka = &vcpu->kvm->arch; > struct pvclock_gtod_data *gtod = &pvclock_gtod_data; > > - vcpus_matched = (ka->nr_vcpus_matched_tsc + 1 == > - atomic_read(&vcpu->kvm->online_vcpus)); > + /* > + * To use the masterclock, the host clocksource must be based on TSC > + * and all vCPUs must have matching TSCs. Note, the count for matching > + * vCPUs doesn't include the reference vCPU, hence "+1". > + */ > + bool use_master_clock = (ka->nr_vcpus_matched_tsc + 1 == > + atomic_read(&vcpu->kvm->online_vcpus)) && > + gtod_is_based_on_tsc(gtod->clock.vclock_mode); > > /* > - * Once the masterclock is enabled, always perform request in > - * order to update it. > - * > - * In order to enable masterclock, the host clocksource must be TSC > - * and the vcpus need to have matched TSCs. When that happens, > - * perform request to enable masterclock. > + * Request a masterclock update if the masterclock needs to be toggled > + * on/off, or when starting a new generation and the masterclock is > + * enabled (compute_guest_tsc() requires the masterclock snaphot to be > + * taken _after_ the new generation is created). > */ > - if (ka->use_master_clock || > - (gtod_is_based_on_tsc(gtod->clock.vclock_mode) && vcpus_matched)) > + if ((ka->use_master_clock && new_generation) || > + (ka->use_master_clock != use_master_clock)) > kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); > > trace_kvm_track_tsc(vcpu->vcpu_id, ka->nr_vcpus_matched_tsc, > @@ -2706,7 +2709,7 @@ static void __kvm_synchronize_tsc(struct kvm_vcpu *vcpu, u64 offset, u64 tsc, > vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec; > vcpu->arch.this_tsc_write = kvm->arch.cur_tsc_write; > > - kvm_track_tsc_matching(vcpu); > + kvm_track_tsc_matching(vcpu, !matched); > } > > static void kvm_synchronize_tsc(struct kvm_vcpu *vcpu, u64 *user_value) > > base-commit: dfdc8b7884b50e3bfa635292973b530a97689f12