Commit c6df8d5a authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf: Fix crash in swevents

Frederic reported that because swevents handling doesn't disable IRQs
anymore, we can get a recursion of perf_adjust_period(), once from
overflow handling and once from the tick.

If both call ->disable, we get a double hlist_del_rcu() and trigger
a LIST_POISON2 dereference.

Since we don't actually need to stop/start a swevent to re-programm
the hardware (lack of hardware to program), simply nop out these
callbacks for the swevent pmu.
Reported-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1275557609.27810.35218.camel@twins>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent da3fd1a0
...@@ -4055,13 +4055,6 @@ static void perf_swevent_overflow(struct perf_event *event, u64 overflow, ...@@ -4055,13 +4055,6 @@ static void perf_swevent_overflow(struct perf_event *event, u64 overflow,
} }
} }
static void perf_swevent_unthrottle(struct perf_event *event)
{
/*
* Nothing to do, we already reset hwc->interrupts.
*/
}
static void perf_swevent_add(struct perf_event *event, u64 nr, static void perf_swevent_add(struct perf_event *event, u64 nr,
int nmi, struct perf_sample_data *data, int nmi, struct perf_sample_data *data,
struct pt_regs *regs) struct pt_regs *regs)
...@@ -4276,11 +4269,22 @@ static void perf_swevent_disable(struct perf_event *event) ...@@ -4276,11 +4269,22 @@ static void perf_swevent_disable(struct perf_event *event)
hlist_del_rcu(&event->hlist_entry); hlist_del_rcu(&event->hlist_entry);
} }
static void perf_swevent_void(struct perf_event *event)
{
}
static int perf_swevent_int(struct perf_event *event)
{
return 0;
}
static const struct pmu perf_ops_generic = { static const struct pmu perf_ops_generic = {
.enable = perf_swevent_enable, .enable = perf_swevent_enable,
.disable = perf_swevent_disable, .disable = perf_swevent_disable,
.start = perf_swevent_int,
.stop = perf_swevent_void,
.read = perf_swevent_read, .read = perf_swevent_read,
.unthrottle = perf_swevent_unthrottle, .unthrottle = perf_swevent_void, /* hwc->interrupts already reset */
}; };
/* /*
...@@ -4561,8 +4565,10 @@ static int swevent_hlist_get(struct perf_event *event) ...@@ -4561,8 +4565,10 @@ static int swevent_hlist_get(struct perf_event *event)
static const struct pmu perf_ops_tracepoint = { static const struct pmu perf_ops_tracepoint = {
.enable = perf_trace_enable, .enable = perf_trace_enable,
.disable = perf_trace_disable, .disable = perf_trace_disable,
.start = perf_swevent_int,
.stop = perf_swevent_void,
.read = perf_swevent_read, .read = perf_swevent_read,
.unthrottle = perf_swevent_unthrottle, .unthrottle = perf_swevent_void,
}; };
static int perf_tp_filter_match(struct perf_event *event, static int perf_tp_filter_match(struct perf_event *event,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment