On Fri, Nov 14, 2014 at 03:43:45PM +0200, Alexander Shishkin wrote:
> +static __init int pt_init(void)
> +{
> +     int ret, cpu, prior_warn = 0;
> +
> +     BUILD_BUG_ON(sizeof(struct topa) > PAGE_SIZE);
> +     get_online_cpus();
> +     for_each_online_cpu(cpu) {
> +             u64 ctl;
> +
> +             ret = rdmsrl_safe_on_cpu(cpu, MSR_IA32_RTIT_CTL, &ctl);
> +             if (!ret && (ctl & RTIT_CTL_TRACEEN))
> +                     prior_warn++;
> +     }
> +     put_online_cpus();
> +
> +     ret = pt_pmu_hw_init();
> +     if (ret)
> +             return ret;
> +
> +     if (!pt_cap_get(PT_CAP_topa_output)) {
> +             pr_warn("ToPA output is not supported on this CPU\n");
> +             return -ENODEV;
> +     }
> +
> +     if (prior_warn)
> +             pr_warn("PT is enabled at boot time, traces may be empty\n");

Should we not also add_exclusive(pt) here?

Also, if its already enabled, should we not return ENODEV as well, no
saying who or what programmed it, we should not be touching it.

> +     if (!pt_cap_get(PT_CAP_topa_multiple_entries))
> +             pt_pmu.pmu.capabilities =
> +                     PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_AUX_SW_DOUBLEBUF;
> +
> +     pt_pmu.pmu.capabilities |= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE;
> +     pt_pmu.pmu.attr_groups  = pt_attr_groups;
> +     pt_pmu.pmu.task_ctx_nr  = perf_hw_context;
> +     pt_pmu.pmu.event_init   = pt_event_init;
> +     pt_pmu.pmu.add          = pt_event_add;
> +     pt_pmu.pmu.del          = pt_event_del;
> +     pt_pmu.pmu.start        = pt_event_start;
> +     pt_pmu.pmu.stop         = pt_event_stop;
> +     pt_pmu.pmu.read         = pt_event_read;
> +     pt_pmu.pmu.setup_aux    = pt_buffer_setup_aux;
> +     pt_pmu.pmu.free_aux     = pt_buffer_free_aux;
> +     ret = perf_pmu_register(&pt_pmu.pmu, "intel_pt", -1);
> +
> +     return ret;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to