RE: [tip:perf/core] perf/x86: Add an MSR PMU driver

Liang, Kan
2015-08-06T17:44:41Z

> + /* Probe the MSRs. */
> + for (i = PERF_MSR_TSC + 1; i < PERF_MSR_EVENT_MAX; i++) {
> + u64 val;
>
> - default:
> - err = -ENOTSUPP;
> + if (!msr[i].test() || rdmsrl_safe(msr[i].msr, &val))
> + msr[i].attr = NULL;
> }
>
> - if (err != 0) {
> - pr_cont("no msr PMU driver.\n");
> - return 0;
> + /* List remaining MSRs in the sysfs attrs. */
> + for (i = 0; i < PERF_MSR_EVENT_MAX; i++) {

i should start from PERF_MSR_TSC + 1. The tsc has already been
inserted into events_attrs by default.

> + if (msr[i].attr)
> + events_attrs[j++] = &msr[i].attr->attr.attr;
> }
> + events_attrs[j] = NULL;
>
> perf_pmu_register(&pmu_msr, "msr", -1);
>