|
@@ -3208,10 +3208,6 @@ int perf_event_task_disable(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-#ifndef PERF_EVENT_INDEX_OFFSET
|
|
|
-# define PERF_EVENT_INDEX_OFFSET 0
|
|
|
-#endif
|
|
|
-
|
|
|
static int perf_event_index(struct perf_event *event)
|
|
|
{
|
|
|
if (event->hw.state & PERF_HES_STOPPED)
|
|
@@ -3220,7 +3216,7 @@ static int perf_event_index(struct perf_event *event)
|
|
|
if (event->state != PERF_EVENT_STATE_ACTIVE)
|
|
|
return 0;
|
|
|
|
|
|
- return event->hw.idx + 1 - PERF_EVENT_INDEX_OFFSET;
|
|
|
+ return event->pmu->event_idx(event);
|
|
|
}
|
|
|
|
|
|
static void calc_timer_values(struct perf_event *event,
|
|
@@ -4992,6 +4988,11 @@ static int perf_swevent_init(struct perf_event *event)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int perf_swevent_event_idx(struct perf_event *event)
|
|
|
+{
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static struct pmu perf_swevent = {
|
|
|
.task_ctx_nr = perf_sw_context,
|
|
|
|
|
@@ -5001,6 +5002,8 @@ static struct pmu perf_swevent = {
|
|
|
.start = perf_swevent_start,
|
|
|
.stop = perf_swevent_stop,
|
|
|
.read = perf_swevent_read,
|
|
|
+
|
|
|
+ .event_idx = perf_swevent_event_idx,
|
|
|
};
|
|
|
|
|
|
#ifdef CONFIG_EVENT_TRACING
|
|
@@ -5087,6 +5090,8 @@ static struct pmu perf_tracepoint = {
|
|
|
.start = perf_swevent_start,
|
|
|
.stop = perf_swevent_stop,
|
|
|
.read = perf_swevent_read,
|
|
|
+
|
|
|
+ .event_idx = perf_swevent_event_idx,
|
|
|
};
|
|
|
|
|
|
static inline void perf_tp_register(void)
|
|
@@ -5306,6 +5311,8 @@ static struct pmu perf_cpu_clock = {
|
|
|
.start = cpu_clock_event_start,
|
|
|
.stop = cpu_clock_event_stop,
|
|
|
.read = cpu_clock_event_read,
|
|
|
+
|
|
|
+ .event_idx = perf_swevent_event_idx,
|
|
|
};
|
|
|
|
|
|
/*
|
|
@@ -5378,6 +5385,8 @@ static struct pmu perf_task_clock = {
|
|
|
.start = task_clock_event_start,
|
|
|
.stop = task_clock_event_stop,
|
|
|
.read = task_clock_event_read,
|
|
|
+
|
|
|
+ .event_idx = perf_swevent_event_idx,
|
|
|
};
|
|
|
|
|
|
static void perf_pmu_nop_void(struct pmu *pmu)
|
|
@@ -5405,6 +5414,11 @@ static void perf_pmu_cancel_txn(struct pmu *pmu)
|
|
|
perf_pmu_enable(pmu);
|
|
|
}
|
|
|
|
|
|
+static int perf_event_idx_default(struct perf_event *event)
|
|
|
+{
|
|
|
+ return event->hw.idx + 1;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* Ensures all contexts with the same task_ctx_nr have the same
|
|
|
* pmu_cpu_context too.
|
|
@@ -5594,6 +5608,9 @@ got_cpu_context:
|
|
|
pmu->pmu_disable = perf_pmu_nop_void;
|
|
|
}
|
|
|
|
|
|
+ if (!pmu->event_idx)
|
|
|
+ pmu->event_idx = perf_event_idx_default;
|
|
|
+
|
|
|
list_add_rcu(&pmu->entry, &pmus);
|
|
|
ret = 0;
|
|
|
unlock:
|