>  /*
>   * Probe the cstate events and insert the available one into sysfs attrs
> - * Return false if there is no available events.
> + * Return false if there are no available events.
>   */
> -static bool cstate_probe_msr(struct perf_cstate_msr *msr,
> -                          struct attribute   **events_attrs,
> -                          int max_event_nr)
> +static bool __init cstate_probe_msr(const unsigned long evmsk,
> +                                 struct perf_cstate_msr *msr,
> +                                 struct attribute **attrs)
>  {
> -     int i, j = 0;
> +     bool found = false;
> +     unsigned int bit;
>       u64 val;
> 
> -     /* Probe the cstate events. */
> -     for (i = 0; i < max_event_nr; i++) {
> -             if (!msr[i].test(i) || rdmsrl_safe(msr[i].msr, &val))
> -                     msr[i].attr = NULL;
> -     }

I think we need to update msr[i].attr as well.
Because in cstate_pmu_event_init we still need it to do check.

Thanks,
Kan
> -
> -     /* List remaining events in the sysfs attrs. */
> -     for (i = 0; i < max_event_nr; i++) {
> -             if (msr[i].attr)
> -                     events_attrs[j++] = &msr[i].attr->attr.attr;
> +     for_each_set_bit(bit, &evmsk, sizeof(evmsk) * BITS_PER_BYTE) {
> +             /* Verify whether the MSR is accessible */
> +             if (!rdmsrl_safe(msr[bit].msr, &val)) {
> +                     *attrs++ = &msr[bit].attr->attr.attr;
> +                     found = true;
> +             }
>       }
> -     events_attrs[j] = NULL;
> -
> -     return (j > 0) ? true : false;
> +     *attrs = NULL;
> +     return found;
>  }
> 

Reply via email to