public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jim Mattson <jmattson@google.com>,
	Mingwei Zhang <mizhang@google.com>,
	Zide Chen <zide.chen@intel.com>,
	Das Sandipan <Sandipan.Das@amd.com>,
	Shukla Manali <Manali.Shukla@amd.com>,
	Xiaoyao Li <xiaoyao.li@intel.com>,
	Dapeng Mi <dapeng1.mi@intel.com>,
	dongsheng <dongsheng.x.zhang@intel.com>,
	Yi Lai <yi1.lai@intel.com>
Subject: Re: [kvm-unit-tests patch v3 3/8] x86/pmu: Fix incorrect masking of fixed counters
Date: Fri, 21 Nov 2025 09:25:32 +0800	[thread overview]
Message-ID: <b6a694a0-5e6d-4cb6-947e-e3b00a4fd057@linux.intel.com> (raw)
In-Reply-To: <aR-WAGVNZwNh7Xo8@google.com>


On 11/21/2025 6:28 AM, Sean Christopherson wrote:
> On Wed, Sep 03, 2025, Dapeng Mi wrote:
>> From: dongsheng <dongsheng.x.zhang@intel.com>
>>
>> The current implementation mistakenly limits the width of fixed counters
>> to the width of GP counters. Corrects the logic to ensure fixed counters
>> are properly masked according to their own width.
>>
>> Opportunistically refine the GP counter bitwidth processing code.
>>
>> Signed-off-by: dongsheng <dongsheng.x.zhang@intel.com>
>> Co-developed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
>> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
>> Tested-by: Yi Lai <yi1.lai@intel.com>
>> ---
>>  x86/pmu.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/x86/pmu.c b/x86/pmu.c
>> index 04946d10..44c728a5 100644
>> --- a/x86/pmu.c
>> +++ b/x86/pmu.c
>> @@ -556,18 +556,16 @@ static void check_counter_overflow(void)
>>  		int idx;
>>  
>>  		cnt.count = overflow_preset;
>> -		if (pmu_use_full_writes())
>> -			cnt.count &= (1ull << pmu.gp_counter_width) - 1;
>> -
>>  		if (i == pmu.nr_gp_counters) {
>>  			if (!pmu.is_intel)
>>  				break;
>>  
>>  			cnt.ctr = fixed_events[0].unit_sel;
>> -			cnt.count = (&cnt);
> Per commit 7ec3b67a ("x86/pmu: Reset the expected count of the fixed counter 0
> when i386"), re-measuring for the fixed counter is necessary when running a 32-bit
> guests.  I didn't see failures (spotted this by inspection), but I don't see any
> point in making this change without good reason.

Thanks. I didn't realized that the 2nd measure_for_overflow() is intended
to add ...


>
>> -			cnt.count &= (1ull << pmu.gp_counter_width) - 1;
>> +			cnt.count &= (1ull << pmu.fixed_counter_width) - 1;
>>  		} else {
>>  			cnt.ctr = MSR_GP_COUNTERx(i);
>> +			if (pmu_use_full_writes())
>> +				cnt.count &= (1ull << pmu.gp_counter_width) - 1;
>>  		}
>>  
>>  		if (i % 2)
>> -- 
>> 2.34.1
>>

  reply	other threads:[~2025-11-21  1:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03  6:45 [kvm-unit-tests patch v3 0/8] Fix pmu test errors on GNR/SRF/CWF Dapeng Mi
2025-09-03  6:45 ` [kvm-unit-tests patch v3 1/8] x86/pmu: Add helper to detect Intel overcount issues Dapeng Mi
2025-11-20 22:27   ` Sean Christopherson
2025-11-21  1:18     ` Mi, Dapeng
2025-09-03  6:45 ` [kvm-unit-tests patch v3 2/8] x86/pmu: Relax precise count validation for Intel overcounted platforms Dapeng Mi
2025-09-03  6:45 ` [kvm-unit-tests patch v3 3/8] x86/pmu: Fix incorrect masking of fixed counters Dapeng Mi
2025-11-20 22:28   ` Sean Christopherson
2025-11-21  1:25     ` Mi, Dapeng [this message]
2025-09-03  6:45 ` [kvm-unit-tests patch v3 4/8] x86/pmu: Handle instruction overcount issue in overflow test Dapeng Mi
2025-09-03  6:45 ` [kvm-unit-tests patch v3 5/8] x86/pmu: Relax precise count check for emulated instructions tests Dapeng Mi
2025-11-20 22:29   ` Sean Christopherson
2025-11-21  0:53     ` Mi, Dapeng
2025-09-03  6:45 ` [kvm-unit-tests patch v3 6/8] x86/pmu: Expand "llc references" upper limit for broader compatibility Dapeng Mi
2025-09-03  6:46 ` [kvm-unit-tests patch v3 7/8] x86: pmu_pebs: Remove abundant data_cfg_match calculation Dapeng Mi
2025-09-03  6:46 ` [kvm-unit-tests patch v3 8/8] x86: pmu_pebs: Support to validate timed PEBS record on GNR/SRF Dapeng Mi
2025-11-20 22:30 ` [kvm-unit-tests patch v3 0/8] Fix pmu test errors on GNR/SRF/CWF Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6a694a0-5e6d-4cb6-947e-e3b00a4fd057@linux.intel.com \
    --to=dapeng1.mi@linux.intel.com \
    --cc=Manali.Shukla@amd.com \
    --cc=Sandipan.Das@amd.com \
    --cc=dapeng1.mi@intel.com \
    --cc=dongsheng.x.zhang@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mizhang@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yi1.lai@intel.com \
    --cc=zide.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox