Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3163583ioa; Mon, 25 Apr 2022 19:55:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVVS5In27J4vVkcadET3SS1E1gwGxwg5iZb9NhALk5kQMiqvCsWL2lA/UwUTM+NTkGTXkg X-Received: by 2002:a63:4c4b:0:b0:3aa:4af8:9ab8 with SMTP id m11-20020a634c4b000000b003aa4af89ab8mr18280458pgl.430.1650941704358; Mon, 25 Apr 2022 19:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650941704; cv=none; d=google.com; s=arc-20160816; b=UQskAgwNbqqCrP6Ng/jOskudGjZo3UhHWBn3vVoAA8zsQqYr9SmKVIAV8szZBbYDML w18e36Egq2V5K8QAkTpPWh09UlRHGjGyGpM19lXmS0vYYvmbCE9p8/O9zmTNKbTskg+F a5VZstC3dC9GGNStxwZVIOdm+xNC8v+65g4CsuGT7T/HzelHDnOrboEmxlZpfQ5iJUd+ aGCAPO4/u54G8oB88pM4IRN/ZRfZMBsu23kISxLu+kM5v700h0feEG1rl1YsEraQf1pq aejP2vN11biWk3f1jCO0E8td2ZjUpY8ZofHIHjN43SfiYum3jyhBGDCNsKJ8/rgXNCg/ 3+aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=GuS0+eUzG5BtLo3Moko/17XZLrJRu9fvWmqLPOFEyN8=; b=sU0LCzpbDyR+SO/YQRu4N8SVoCaz5ZQU40T7bhk13hem+da482dxBE9Ez0noMVyR+/ ZhbIcJJTHW1g6z3aaGxn8mY+63d9MgUTwSEwuhx+sotU2FLUxsGPO9hBVXAwp+tMTrXY jkCsJcp15zk13GmFqDJCTyEcxn0bfuPGy+Mgzoz+blPbdr99KE4Yq+gBnc3WhVsyfi+b jMDlPyL8R+susPUPaubZuVg3vuojp/igMQ3au0w3XWmDDNzLraPI26Y16kvjJvKBR2fP vRpNHQSR5H6J3A+WyOOvMdKdkoJjxyvrI/dHDbI71gxniA/Qw/tCmWKPplJgVPSRk+Cm D9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vHXQxaUe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=kUMwfiHv; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a63dc10000000b003aa5151286asi17880208pgg.627.2022.04.25.19.54.49; Mon, 25 Apr 2022 19:55:04 -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=@linutronix.de header.s=2020 header.b=vHXQxaUe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=kUMwfiHv; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239480AbiDYJjj (ORCPT + 99 others); Mon, 25 Apr 2022 05:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241541AbiDYJiL (ORCPT ); Mon, 25 Apr 2022 05:38:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B6B27CE6; Mon, 25 Apr 2022 02:32:18 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1650879136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GuS0+eUzG5BtLo3Moko/17XZLrJRu9fvWmqLPOFEyN8=; b=vHXQxaUeaHvw4Xiz9T9MB1+1qh9heHJPy5Tp0CxvFSUhFNU5qp75M1qmmCTZjp7fcr03Mc DjknOq742hHhWHCgVaUqMV5QYSrIp6361DJQhPOALiJckLkC991h1Mr+42ApMWH56Vfh0F 7mJgACdr44D8eYg66nI9zAzAHbIRuN0HHI7/UlQdX3VS2B+Oxyebso3Qtgag9Mt6iViyab tDG0GB7ENzwrMSP5r4Wy5a7tNw9Jkkj9NVzO1e9h5xHJNjukYDva81fOLEsZmohq7W4tqx xUNit134OoWKy6uGvAEiiM4f36FVlZMnbhZSJ7iGgnU26PD+j+n99dbSgNUjng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1650879136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GuS0+eUzG5BtLo3Moko/17XZLrJRu9fvWmqLPOFEyN8=; b=kUMwfiHvNx/7GQIpsSk2x/vGiCdnpXgig/ECozp+dMy2shcP4mvjucEJMnNWIM28e3948x PtvRHTt5Spu12GCw== To: Adrian Hunter , 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" Subject: Re: [PATCH V2 03/11] perf/x86: Add support for TSC in nanoseconds as a perf event clock In-Reply-To: <50fd2671-6070-0eba-ea68-9df9b79ccac3@intel.com> 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> Date: Mon, 25 Apr 2022 11:32:15 +0200 Message-ID: <87ilqx33vk.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 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. Thanks, tglx