/* Find a PMC slot for the freshly enabled / scheduled in event:  */
static int x86_pmu_enable(struct perf_event *event)
/* Find a PMC slot for the freshly enabled / scheduled in event:  */
static int x86_pmu_enable(struct perf_event *event)
{
	struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
	struct hw_perf_event *hwc = &event->hw;
	int idx;
	idx = x86_schedule_event(cpuc, hwc);
	if (idx < 0)
		return idx;
	perf_events_lapic_init();
	x86_pmu.disable(hwc, idx);
	cpuc->events[idx] = event;
	set_bit(idx, cpuc->active_mask);
	x86_perf_event_set_period(event, hwc, idx);
	x86_pmu.enable(hwc, idx);
	perf_event_update_userpage(event);
	return 0;
}