Re: [kvm-unit-tests patch v6 08/18] x86: pmu: Fix cycles event validation failure

Sean Christopherson
2025-02-14T21:07:58Z

On Sat, Sep 14, 2024, Dapeng Mi wrote:
> +static void warm_up(void)
> +{
> + int i = 8;
> +
> + /*
> + * Since cycles event is always run as the first event, there would be
> + * a warm-up state to warm up the cache, it leads to the measured cycles
> + * value may exceed the pre-defined cycles upper boundary and cause
> + * false positive. To avoid this, introduce an warm-up state before
> + * the real verification.
> + */
> + while (i--)
> + loop();

Use a for-loop.

> +}
> +
> static void check_counters(void)
> {
> if (is_fep_available())
> check_emulated_instr();
>
> + warm_up();
> check_gp_counters();
> check_fixed_counters();
> check_rdpmc();
> --
> 2.40.1
>