[PATCH 3/4] perf_counter: optimize disable of time based sw counters

From: Peter Zijlstra
Date: Wed May 20 2009 - 06:26:57 EST


Currently we call hrtimer_cancel() unconditionally on disable of time based
software counters. Avoid when possible.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/perf_counter.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -2716,7 +2716,8 @@ static int cpu_clock_perf_counter_enable

static void cpu_clock_perf_counter_disable(struct perf_counter *counter)
{
- hrtimer_cancel(&counter->hw.hrtimer);
+ if (counter->hw.irq_period)
+ hrtimer_cancel(&counter->hw.hrtimer);
cpu_clock_perf_counter_update(counter);
}

@@ -2767,7 +2768,8 @@ static int task_clock_perf_counter_enabl

static void task_clock_perf_counter_disable(struct perf_counter *counter)
{
- hrtimer_cancel(&counter->hw.hrtimer);
+ if (counter->hw.irq_period)
+ hrtimer_cancel(&counter->hw.hrtimer);
task_clock_perf_counter_update(counter, counter->ctx->time);

}

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/