Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3336402ioa; Tue, 26 Apr 2022 01:23:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRl6WwxtEADRPQOK7v8bdfJjiXao2GxC72IMFYkV1nwzw4fu/DdaXKz4cl4u7hZgVhEpWD X-Received: by 2002:a17:907:d04:b0:6e8:8cbc:e86a with SMTP id gn4-20020a1709070d0400b006e88cbce86amr20537496ejc.194.1650961411968; Tue, 26 Apr 2022 01:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650961411; cv=none; d=google.com; s=arc-20160816; b=yqZIJ7UQc6WO1ds5oVEMzppo3gGbyM0cXQjdIhrkITwCjKNBfayy5BP5HhBdOzo9lD 7cdDduHD73Ejz41CTDDG+ppmoRDIB0qsaa09L0lIXANGUj2dm4bWodTzdiLLIYVXp8y9 fjRXzg1IFNH4LaNNH6xkgYyOUWiPM0xBWVLdiN4qWhQntt6Q7WJ5umI0KeYp7rOxwpHT rcN10UBz3KYU3sg3C0KRB3wNqZC9Cbnwq9kY7ElUfOkBtCRoqwarvybhG1vXN3b8+7xN Y7BGTNTunfVG1ArsuPMw59EhrjI2cF5UOrpBMUXRju4Vuz6d4zB7Jr7wjfN5wSZrQWGZ iciQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=wiVPeAarwOcHsmENULRylAoFCAc8Mu9UAaxtrjAb35s=; b=MG1b9C8jCf1sLJax7VRFpecCiqUqIPjcSrKb8zT2jW3Lfi2LWaHXMF91AvDOhV1HmX 6eWs5urmx+piX1wa1aKftUmmcaFf5NtBPzt7c8pgqF86ad6Bzt6uWQaFaGI055GW7GH4 mcQ1OOu2dvTyoY73BIhARv4nF0dBn/CIHRYCH7hPbMzzMl4qX+4iNfftbvAnnS1xAb1+ U/4mjkEc2folPOcfaAAg49Kgnc2RW4SGLWoUYojLCdqXa9GdP+pCqsB9JI9h8YCdEG4a J2Gk3C0V4JXoJj60QlshpoUhBmETYvDIlFSmFtZVxmIzsNykftu0DcNM7acmpIdoZk8r 0fnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aHww7+9t; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020aa7dc59000000b00425f619b1b8si2081675edu.63.2022.04.26.01.23.07; Tue, 26 Apr 2022 01:23:31 -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=@intel.com header.s=Intel header.b=aHww7+9t; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234886AbiDYNTI (ORCPT + 99 others); Mon, 25 Apr 2022 09:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbiDYNTD (ORCPT ); Mon, 25 Apr 2022 09:19:03 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A191F17E0A; Mon, 25 Apr 2022 06:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650892559; x=1682428559; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=zYnxt+dOMmGR9ixG9CjwBptYMb5IpG26lgSZqv0tNlM=; b=aHww7+9ty9Cdx+Mb3xk4CvVtIXsANaKQGowAFgmnKXidGIgtrDFrIUUH x5G29vfc9XdGygMZlw0gq7/irUqGiEeBMtd0Hqc+pz7jdQ1NETj+p9Gt/ A2oxGTzGs42KLi4mB09zB/aLspg1FStfSH7T8kXkIsfKffIP+LNcJzqzi YKGkGTT49MF1h5Ux40TLAHF1rJXvR5mfBk88Lldv5M6P91l4W9+qdncSE dEHUe7TeSioxEjrs23c5Y+k1Cx0mkR2zjIj+bvYKxdnnpLovrI+VhCMVG /yO6yF9beDc8O9Oh8pfoQtoZj5PezB5B8mWI9xav2ax1ywuKbMNe+rK7i w==; X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="265044384" X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="265044384" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 06:15:58 -0700 X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="579279569" Received: from pvagawan-mobl1.amr.corp.intel.com (HELO [10.0.2.15]) ([10.252.47.228]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 06:15:52 -0700 Message-ID: Date: Mon, 25 Apr 2022 16:15:47 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.7.0 Subject: Re: [PATCH V2 03/11] perf/x86: Add support for TSC in nanoseconds as a perf event clock Content-Language: en-US To: Thomas Gleixner , Peter Zijlstra Cc: Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , "linux-kernel@vger.kernel.org" , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "kvm@vger.kernel.org" , H Peter Anvin , Mathieu Poirier , Suzuki K Poulose , Leo Yan , "jgross@suse.com" , "sdeep@vmware.com" , "pv-drivers@vmware.com" , "pbonzini@redhat.com" , "seanjc@google.com" , "kys@microsoft.com" , "sthemmin@microsoft.com" , "virtualization@lists.linux-foundation.org" , "Andrew.Cooper3@citrix.com" , "Hall, Christopher S" References: <20220214110914.268126-1-adrian.hunter@intel.com> <20220214110914.268126-4-adrian.hunter@intel.com> <853ce127-25f0-d0fe-1d8f-0b0dd4f3ce71@intel.com> <30383f92-59cb-2875-1e1b-ff1a0eacd235@intel.com> <013b5425-2a60-e4d4-b846-444a576f2b28@intel.com> <6f07a7d4e1ad4440bf6c502c8cb6c2ed@intel.com> <50fd2671-6070-0eba-ea68-9df9b79ccac3@intel.com> <87ilqx33vk.ffs@tglx> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <87ilqx33vk.ffs@tglx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On 25/04/22 12:32, Thomas Gleixner wrote: > On Mon, Apr 25 2022 at 08:30, Adrian Hunter wrote: >> On 14/03/22 13:50, Adrian Hunter wrote: >>>> TSC offsetting may also be a problem. The VMCS TSC offset must be discoverable by the >>>> guest. This can be done via TSC_ADJUST MSR. The offset in the VMCS and the guest >>>> TSC_ADJUST MSR must always be equivalent, i.e. a write to TSC_ADJUST in the guest >>>> must be reflected in the VMCS and any changes to the offset in the VMCS must be >>>> reflected in the TSC_ADJUST MSR. Otherwise a para-virtualized method must >>>> be invented to communicate an arbitrary VMCS TSC offset to the guest. >>>> >>> >>> In my view it is reasonable for perf to support TSC as a perf clock in any case >>> because: >>> a) it allows users to work entirely with TSC if they wish >>> b) other kernel performance / debug facilities like ftrace already support TSC >>> c) the patches to add TSC support are relatively small and straight-forward >>> >>> May we have support for TSC as a perf event clock? >> >> Any update on this? > > If TSC is reliable on the host, then there is absolutely no reason not > to use it in the guest all over the place. And that is independent of > exposing ART to the guest. > > So why do we need extra solutions for PT and perf, ftrace and whatever? > > Can we just fix the underlying problem and make the hypervisor tell the > guest that TSC is stable, reliable and good to use? > > Then everything else just falls into place and using TSC is a > substantial performance gain in general. Just look at the VDSO > implementation of __arch_get_hw_counter() -> vread_pvclock(): > > Instead of just reading the TSC, this needs to take a nested seqcount, > read TSC and do yet another mult/shift, which makes clock_gettime() ~20% > slower than necessary. > > It's hillarious, that we still cling to this pvclock abomination, while > we happily expose TSC deadline timer to the guest. TSC virt scaling was > implemented in hardware for a reason. So you are talking about changing VMX TCS Offset on every VM-Entry to try to hide the time jumps when the VM is scheduled out? Or neglect that and just let the time jumps happen? If changing VMX TCS Offset, how can TSC be kept consistent between each VCPU i.e. wouldn't that mean each VCPU has to have the same VMX TSC Offset?