Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp841114pxb; Wed, 13 Jan 2021 18:01:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzB7C0KxsAkbrk5ArQMx7jHdFxu7aVnUJNzqXZ1CArm+GmjufMIZu4HENq+J5k6dTwdburt X-Received: by 2002:a17:906:b252:: with SMTP id ce18mr3595027ejb.5.1610589704902; Wed, 13 Jan 2021 18:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610589704; cv=none; d=google.com; s=arc-20160816; b=i7924yZNYyPbC/vbg0g+754pxIqPTiNyccZ17SoS8yHy/dZqqpN8ixYj9EKjaUgdXo wkQ+OlJ6o6XCRWLm/bcFxLEP5C0yrQi91oWxeeHCVwIfsozNauDqZtHJXE0oMSli1IYk RNL1hUSOrZFuwT7+mTyd26Wx9ljxIGBx5ePFv29aN2AvIycFcqAVAvGIeo8nubnd+gfP fWZymSmr28+mRyM/6wGjDexhT2h4NlITgdcEfnbe+hYXOpDEDkdWeIMLsubCBU3nvYma NP3kHNe2f0UEvQFgw0w87LxkhFi6e1QTjnydX21JxdRu0C0ByV0ihPbPDMk3Zby3eVKz kRqA== 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=UOt8ceuDAozsSYuvCTZAa9WX6HyBxiZLaTAjucMQXnc=; b=lCmZhCc/jaV+zl213xJB8SlZn0vQLmEf95d3B2J5snJCgnp92btK3TXDMkSvj/UfEC L2Cdv8mc8KYlqejojXWBJKW4SEDnesei08XNSx7hsfZZSCHGYwAG5IITHLaRWYi39bBA vHqfHTQ9ELYLH9qw0f7HeD+v5tl43XRa9NbEpK3xjO7OXbB0HPuXvCU4sAXe7PMyKH4M P3V9/ksQBpYB6tFL/iWG6N7p3OFtCgRPYUDLxb+ehAcy02oJaZsBN7aANklLHr2dm7+/ ygMrdOX5vInv3t59LYY/iB4cofeRV383OHpi/3bTZX1jv40KJ3mMFXaEGotbZCvgAa5p fJnQ== 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 r24si1678574eji.211.2021.01.13.18.00.57; Wed, 13 Jan 2021 18:01:44 -0800 (PST) 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 S1729395AbhANB7v (ORCPT + 99 others); Wed, 13 Jan 2021 20:59:51 -0500 Received: from mga05.intel.com ([192.55.52.43]:52821 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729378AbhANB7r (ORCPT ); Wed, 13 Jan 2021 20:59:47 -0500 IronPort-SDR: YsryFXQNNo40CS64TKDr93tsFvQdfRTUCg+X3rz/uq6zVQ55p7imKzJ2nbB8neU5XtUHX09ADf zJgD9yWwW1gg== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="263086146" X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="263086146" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 17:58:59 -0800 IronPort-SDR: KROhvZylfWMrAJyjWdB9MBI6G5CCmZmiATzs+GnldWjGPwXsvos6tq/eauIXuMzjSsNgMONA+b DSFG90SkgDVQ== X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="353704460" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.93]) ([10.238.4.93]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 17:58:54 -0800 Subject: Re: [PATCH v3 03/17] KVM: x86/pmu: Introduce the ctrl_mask value for fixed counter To: Peter Zijlstra , Like Xu 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-4-like.xu@linux.intel.com> From: "Xu, Like" Message-ID: Date: Thu, 14 Jan 2021 09:58:51 +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: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/14 2:06, Peter Zijlstra wrote: > On Mon, Jan 04, 2021 at 09:15:28PM +0800, Like Xu wrote: >> @@ -327,6 +328,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) >> pmu->counter_bitmask[KVM_PMC_FIXED] = 0; >> pmu->version = 0; >> pmu->reserved_bits = 0xffffffff00200000ull; >> + pmu->fixed_ctr_ctrl_mask = ~0ull; > All 1s > >> >> entry = kvm_find_cpuid_entry(vcpu, 0xa, 0); >> if (!entry) >> @@ -358,6 +360,9 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) >> ((u64)1 << edx.split.bit_width_fixed) - 1; >> } >> >> + for (i = 0; i < pmu->nr_arch_fixed_counters; i++) >> + pmu->fixed_ctr_ctrl_mask |= (0xbull << (i * 4)); > With some extra 1s on top You're right, I think it should be:     pmu->fixed_ctr_ctrl_mask &= ~(0xbull << (i * 4)); w/o invertion and I will fix it in the next version. > >> + pmu->fixed_ctr_ctrl_mask = ~pmu->fixed_ctr_ctrl_mask; > Inverted is all 0s, always. > >> pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) | >> (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); >> pmu->global_ctrl_mask = ~pmu->global_ctrl; >> -- >> 2.29.2 >>