From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5859C433DB for ; Fri, 15 Jan 2021 15:30:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B95A723136 for ; Fri, 15 Jan 2021 15:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732692AbhAOPaK (ORCPT ); Fri, 15 Jan 2021 10:30:10 -0500 Received: from mga11.intel.com ([192.55.52.93]:4719 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731683AbhAOPaJ (ORCPT ); Fri, 15 Jan 2021 10:30:09 -0500 IronPort-SDR: xthGdTZlG4BvzfTAX0ZJhQY69vCRu9XcuPlfVP/Gm4rRaimJkQBa9S/bW20YDFM0WPvV1o8PTQ hVjj4ODyOuMg== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="175058065" X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="175058065" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 07:29:29 -0800 IronPort-SDR: Ixg0JjW8VZZZzXk+jB1PStwoRSX9tGBJLAATnjowIqeKWkevJpQ6ocy0moGpwOtqUM7r0REw7l uF8thNaTqmDg== X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="382699941" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.249.174.174]) ([10.249.174.174]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 07:29:24 -0800 Subject: Re: [PATCH v3 06/17] KVM: x86/pmu: Add IA32_PEBS_ENABLE MSR emulation for extended PEBS To: Peter Zijlstra Cc: Paolo Bonzini , eranian@google.com, kvm@vger.kernel.org, Ingo Molnar , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andi Kleen , Kan Liang , wei.w.wang@intel.com, luwei.kang@intel.com, linux-kernel@vger.kernel.org References: <20210104131542.495413-1-like.xu@linux.intel.com> <20210104131542.495413-7-like.xu@linux.intel.com> From: "Xu, Like" Message-ID: Date: Fri, 15 Jan 2021 23:29:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 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: kvm@vger.kernel.org On 2021/1/15 22:46, Peter Zijlstra wrote: > On Mon, Jan 04, 2021 at 09:15:31PM +0800, Like Xu wrote: > >> + if (cpuc->pebs_enabled & ~cpuc->intel_ctrl_host_mask) { >> + arr[1].msr = MSR_IA32_PEBS_ENABLE; >> + arr[1].host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask; >> + arr[1].guest = cpuc->pebs_enabled & ~cpuc->intel_ctrl_host_mask; >> + /* >> + * The guest PEBS will be disabled once the host PEBS is enabled >> + * since the both enabled case may brings a unknown PMI to >> + * confuse host and the guest PEBS overflow PMI would be missed. >> + */ >> + if (arr[1].host) >> + arr[1].guest = 0; >> + arr[0].guest |= arr[1].guest; >> + *nr = 2; > Elsewhere you write: > >> When we have a PEBS PMI due to guest workload and vm-exits, >> the code path from vm-exit to the host PEBS PMI handler may also >> bring PEBS PMI and mark the status bit. The current PMI handler >> can't distinguish them and would treat the later one as a suspicious >> PMI and output a warning. > So the reason isn't that spurious PMIs are tedious, but that the > hardware is actually doing something weird. > > Or am I not reading things straight? I think the PEBS facility works as expected because in the both enabled case, the first PEBS PMI is generated from host counter 1 based on guest interrupt_threshold and the later PEBS PMI could be generated from host counter 2 based on host interrupt_threshold. Therefore, if we adjust the overflow value to a small value, so that the number of instructions from vm-exit to global ctrl disabling could be enough big to trigger PEBS PMI. Do you think this is weird, or do you see other possibilities ?