Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1675354pxj; Wed, 19 May 2021 11:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpYypmOAkoH5nCmDAKwxIc09nIvp7bO+32AcgCL7y3IM6evHETdZ0H3bmMdObXbEDhe26M X-Received: by 2002:a05:6402:416:: with SMTP id q22mr364291edv.204.1621447909615; Wed, 19 May 2021 11:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621447909; cv=none; d=google.com; s=arc-20160816; b=F17sfBw8nIE6Nl87CqyirI6KT90iOVZOT3jY+tWLk0ljpoObcCNmuPnLI02fErAmWV oal6b4ZIQLA+hbfd4VTX1pri13FIYWtP7yKgrxJIpqCA6lrh5Nbs+MxSz6aPyJ/H3IXc OOQMZIXMb9PJBvysApLP8FtbYWjw4h333E6phMu7xRoiLBfNtdzrUNKQzkBQ5+WvBAwJ 7Ak0D182Z9NVBZPHWpY+f3i7etAmcTfnjYQ4yNyaDNVxV32HYbUaKQF5LjwU6AMTsOmH a2c5bEN3A6Mwj8QpxkYW+NFaczsD992haLZOdDkhccqTTv4JApipNpHBP0e1fgalsJuG kRDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=6g4ChxtJ4c+YZ5DGfkfxEVtcBl6Xu5KOk8lpND4XKKU=; b=zQjybKdmu84B06GEGc5ONi/DCGGfpsh8bDRGsI809IxR2msPJx+X3jneN7BNwhnIPR UyAUyu6eME3P7QoD/pEa53kdZ9pruFNTlkG5jrn9V87iBELz3H3Hs/LXeS/MyQOTeJod 1uySeyfW+Ee3BuQbFZzVWPCwT7FwKqtirKoWzfALXLqWBrE4R/61R4w+Xjfdfq6nObAE WgIHNRqNUKN2Ffh6xopruGJwJGChqhbdr+N0v6NzsZZPzxACnWnSK/cEBloI28iQXbIA SC3dji5PrQN7zC+9lLp1X514qmE2aZN4YiiUYU7sBodSaaOeW4JYIUA2z5OdVI59ieug GL+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx13si334827ejb.602.2021.05.19.11.11.26; Wed, 19 May 2021 11:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349493AbhERNR0 (ORCPT + 99 others); Tue, 18 May 2021 09:17:26 -0400 Received: from mga05.intel.com ([192.55.52.43]:24553 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbhERNR0 (ORCPT ); Tue, 18 May 2021 09:17:26 -0400 IronPort-SDR: iHkiztZ4G44tl65t7VpFBLSZ+CCd05fiN3ZuQp2p7V5kUL7rMLVmAGDc1uqCR8+/3QdkCcjV6V L+RUYDWMZuXg== X-IronPort-AV: E=McAfee;i="6200,9189,9987"; a="286240652" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="286240652" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 06:16:08 -0700 IronPort-SDR: LcDd7rPA9DICOZKuWjUH7c/hlK9q1r+zC7KbFKLQfJjojlwmZsKJYKz4cRoEBBgnTfvGs7oZa3 l0PvbNOZqL2Q== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="472950105" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.255.30.127]) ([10.255.30.127]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 06:16:03 -0700 Subject: Re: [PATCH v6 07/16] KVM: x86/pmu: Reprogram PEBS event to emulate guest PEBS counter To: Peter Zijlstra , Andi Kleen Cc: Like Xu , Paolo Bonzini , Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-8-like.xu@linux.intel.com> From: "Xu, Like" Message-ID: <852ab586-2438-c7fc-c41d-0862e2f1b7ca@intel.com> Date: Tue, 18 May 2021 21:15:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/18 16:47, Peter Zijlstra wrote: > On Mon, May 17, 2021 at 07:44:15AM -0700, Andi Kleen wrote: >> On 5/17/2021 1:39 AM, Peter Zijlstra wrote: >>> On Tue, May 11, 2021 at 10:42:05AM +0800, Like Xu wrote: >>>> + if (pebs) { >>>> + /* >>>> + * The non-zero precision level of guest event makes the ordinary >>>> + * guest event becomes a guest PEBS event and triggers the host >>>> + * PEBS PMI handler to determine whether the PEBS overflow PMI >>>> + * comes from the host counters or the guest. >>>> + * >>>> + * For most PEBS hardware events, the difference in the software >>>> + * precision levels of guest and host PEBS events will not affect >>>> + * the accuracy of the PEBS profiling result, because the "event IP" >>>> + * in the PEBS record is calibrated on the guest side. >>>> + */ >>>> + attr.precise_ip = 1; >>>> + } >>> You've just destroyed precdist, no? >> precdist can mean multiple things: >> >> - Convert cycles to the precise INST_RETIRED event. That is not meaningful >> for virtualization because "cycles" doesn't exist, just the raw events. >> >> - For GLC+ and TNT+ it will force the event to a specific counter that is >> more precise. This would be indeed "destroyed", but right now the patch kit >> only supports Icelake which doesn't support that anyways. >> >> So I think the code is correct for now, but will need to be changed for >> later CPUs. Should perhaps fix the comment though to discuss this. > OK, can we then do a better comment that explains *why* this is correct > now and what needs help later? > > Because IIUC the only reason it is correct now is because: > > - we only support ICL > > * and ICL has pebs_format>=2, so {1,2} are the same > * and ICL doesn't have precise_ip==3 support > > - Other hardware (GLC+, TNT+) that could possibly care here > is unsupported atm. but needs changes. > > None of which is actually mentioned in that comment it does have. Hi Andi & Peter, By "precdist", do you mean the"Precise Distribution of Instructions Retired (PDIR) Facility"? The SDM says Ice Lake Microarchitecture does support PEBS-PDIR on IA32_FIXED0 only. And this patch kit enables it in the patch 0011, please take a look. Or do I miss something about precdist on ICL ? Thanks, Like Xu