Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3081578iob; Mon, 16 May 2022 12:39:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuUDTqLKqubOOHIwNhAjHwQfQNeF2CnrzuB7WTp4OXLOLJ87mKBtomsONcYkVVMUR1SC5x X-Received: by 2002:a17:906:aed8:b0:6f3:7e6b:14d with SMTP id me24-20020a170906aed800b006f37e6b014dmr17032386ejb.451.1652729997307; Mon, 16 May 2022 12:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652729997; cv=none; d=google.com; s=arc-20160816; b=llul7KUYqDpppab5/PEFM7X4zIyTE5UK6WkEQjjq/V43d5YQr0zPYdQ63VwYsjmTb+ P7QdhALuDd8OxIRL0ih7jM3CCAT4flXYQjvHGXAiA/Y+F8gwf9ItStIG4FKDUgyzLrAr JLC0sllpb5AlTR43DsWcsU7OCgVlel8VHqfOltt7KE60q2vKbJPYjGoVXfsEdzKVoOnp UwOX/MWq4JR3upm4H5pRdMu+CItJgC3fuBy0imScjGwy/f8WIIc4KeUgWtN+fK20Wn/B pZxuShhKix1JlCM0+jOD0Go5c7mTq4pKelbcBVTAg2p9SVbDLq8pG+swhcCEGRVcuev1 Smxg== 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=LLTNqznKiMJDTFV+0rHfE6alUt7vuXgncA8jt7OjD4E=; b=SC3/BFOq0mSvrlceuEG38KbybaUM8XyiElneqRFugIJGerAANeIiAo5XCiXDCKGTtE z8Dm+FaK7ICfL8/cELGtcPjpgJ6Z2xYmRvTffyMkkhcn9rX6yzJ244fk7jYlsW/VqDQs Nqyj1ihSgACGqYIYA11H9X+Nf/Ozg91JAR1Cxh8V+FH/6OtgsBlEPFzd9hozi6IQM94r ZxhTqifpzlSy/HuxnwwzI/z/GKNs7DSedv90ikSzMQW4DlioiWeOUZ/J1NKkhry6soD3 33plSy7kT45NeNfEo/OsvXG/oQm7ZWg2EozCiVn9nY+uaJRlEaniGbpFSr2ylh76suZk AtGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HHdhJkt4; 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 he14-20020a1709073d8e00b006f3bd052e9bsi251904ejc.949.2022.05.16.12.39.30; Mon, 16 May 2022 12:39:57 -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=HHdhJkt4; 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 S241034AbiEPHU4 (ORCPT + 99 others); Mon, 16 May 2022 03:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241015AbiEPHUy (ORCPT ); Mon, 16 May 2022 03:20:54 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A0DBE0F; Mon, 16 May 2022 00:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652685653; x=1684221653; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=5Bmrym4ZBrZuWxcL4DbvzKLGJFYIJDTX69S3vd8Egxg=; b=HHdhJkt4Uy0JAko18zXwuDaZT6xuJolbnr3XuUNobk5SBtZHx5oSomxI XPh+IL6jTkA9xnJgtJ/6QPqup/R/NiprPlXLbKz93josntWePfubuPAUS Mo4tSUAkiBGd02ZKRsiJXrI5U/fBU6ZlK2/c0RGo06kGo+HkN4e3OLUcH K0glFQ9b0q07Ww1FpsPbgJhIe9H5FUUzb0xy4ir3LBQ0g5Qcj3IuBqJD2 ARpttl5x9MFpWuZnCQTOKCJZaqXgDVy6li27nHuvEZPuNJXZETEk4fx02 a7Iz4jdQqjK4fyCriIFhL5dqTY2qIDubCCEEcwFMP908t5vr+BI5HWvqt Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="269579094" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="269579094" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2022 00:20:52 -0700 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="596388661" Received: from rhudecze-mobl.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.36.15]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2022 00:20:46 -0700 Message-ID: Date: Mon, 16 May 2022 10:20:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.8.1 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> <87fsm114ax.ffs@tglx> <87ee1iw2ao.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: <87ee1iw2ao.ffs@tglx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 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,T_SCC_BODY_TEXT_LINE 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 28/04/22 02:10, Thomas Gleixner wrote: > On Tue, Apr 26 2022 at 09:51, Adrian Hunter wrote: >> On 25/04/22 20:05, Thomas Gleixner wrote: >>> On Mon, Apr 25 2022 at 16:15, Adrian Hunter wrote: >>>> On 25/04/22 12:32, Thomas Gleixner wrote: >>>>> 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? >>> >>> Obviously so. That's the only thing which makes sense, no? >> >> [ Sending this again, because I notice I messed up the email "From" ] >> >> But wouldn't that mean changing all the VCPUs VMX TSC Offset at the same time, >> which means when none are currently executing? How could that be done? > > Why would you change TSC offset after the point where a VM is started > and why would it be different per vCPU? > > Time is global and time moves on when a vCPU is scheduled out. Anything > else is bonkers, really. If the hypervisor tries to screw with that then > how does the guest do timekeeping in a consistent way? > > CLOCK_REALTIME = CLOCK_MONOTONIC + offset > > That offset changes when something sets the clock, i.e. clock_settime(), > settimeofday() or adjtimex() in case that NTP cannot compensate or for > the beloved leap seconds adjustment. At any other time the offset is > constant. > > CLOCK_MONOTONIC is derived from the underlying clocksource which is > expected to increment with constant frequency and that has to be > consistent accross _all_ vCPUs of a particular VM. > > So how would a hypervisor 'hide' scheduled out time w/o screwing up > timekeeping completely? > > The guest TSC which is based on the host TSC is: > > guestTSC = offset + hostTSC * factor; > > If you make offset different between guest vCPUs then timekeeping in the > guest is screwed. > > The whole point of that paravirt clock was to handle migration between > hosts which did not have the VMCS TSC scaling/offset mechanism. The CPUs > which did not have that went EOL at least 10 years ago. > > So what are you concerned about? Thanks for the explanation. Changing TSC offset / scaling makes it much harder for Intel PT on the host to use, so there is no sense in my pushing for that at this time when there is anyway kernel option no-kvmclock.