Re: [PATCH v3 06/11] KVM: selftests: Test consistency of CPUID with num of fixed counters

From: Sean Christopherson
Date: Thu Aug 17 2023 - 19:05:47 EST


On Mon, Aug 14, 2023, Jinrong Liang wrote:
> @@ -239,6 +272,14 @@ static void intel_test_counters_num(void)
> if (!perf_caps[i])
> test_oob_gp_counter(0, 2, perf_caps[i], 0);
> }
> +
> + for (ecx = 0;
> + ecx <= kvm_cpu_property(X86_PROPERTY_PMU_FIXED_COUNTERS_BITMASK) + 1;

This is the perfect time to use a local variable:

for (ecx = 0; ecx <= fixed_counters_bitmask; ecx++)

> + ecx++) {
> + intel_test_oob_fixed_ctr(0, ecx, GP_VECTOR);
> + intel_test_oob_fixed_ctr(nr_fixed_counters, ecx, GP_VECTOR);
> + intel_test_oob_fixed_ctr(nr_fixed_counters + 1, ecx, GP_VECTOR);
> + }
> }
>
> int main(int argc, char *argv[])
> --
> 2.39.3
>