Re: [GIT PULL] perf crash fix

Peter Zijlstra
2010-06-03T08:02:43Z

On Thu, 2010-06-03 at 05:13 +0200, Frederic Weisbecker wrote:

> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 858f56f..b666d7d 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -1510,20 +1510,16 @@ do { \
> return div64_u64(dividend, divisor);
> }
>
> -static void perf_event_stop(struct perf_event *event)
> +static void perf_event_stop_hwevent(struct perf_event *event)
> {
> - if (!event->pmu->stop)
> - return event->pmu->disable(event);
> -
> - return event->pmu->stop(event);
> + if (event->pmu->stop && !is_software_event(event))
> + return event->pmu->stop(event);
> }
>
> -static int perf_event_start(struct perf_event *event)
> +static int perf_event_start_hwevent(struct perf_event *event)
> {
> - if (!event->pmu->start)
> - return event->pmu->enable(event);
> -
> - return event->pmu->start(event);
> + if (event->pmu->start && !is_software_event(event))
> + return event->pmu->start(event);
> }
>
> static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
> @@ -1546,9 +1542,9 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
>
> if (atomic64_read(&hwc->period_left) > 8*sample_period) {
> perf_disable();
> - perf_event_stop(event);
> + perf_event_stop_hwevent(event);
> atomic64_set(&hwc->period_left, 0);
> - perf_event_start(event);
> + perf_event_start_hwevent(event);
> perf_enable();
> }
> }

Urhm,. isn't is much easier to simply give the software events a NOP
stop/start callback?

kernel/perf_event.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 858f56f..16c99e1 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4276,9 +4276,15 @@ static void perf_swevent_disable(struct perf_event *event)
hlist_del_rcu(&event->hlist_entry);
}

+static void perf_swevent_nop(struct perf_event *event)
+{
+}
+
static const struct pmu perf_ops_generic = {
.enable = perf_swevent_enable,
.disable = perf_swevent_disable,
+ .start = perf_swevent_nop,
+ .stop = perf_swevent_nop,
.read = perf_swevent_read,
.unthrottle = perf_swevent_unthrottle,
};