[tip:perfcounters/core] perf_counter: Optimize disable of time based sw counters

From: tip-bot for Peter Zijlstra
Date: Wed May 20 2009 - 13:19:52 EST


Commit-ID: b986d7ec0f8b7ea3cc7366d80a137fbe839df227
Gitweb: http://git.kernel.org/tip/b986d7ec0f8b7ea3cc7366d80a137fbe839df227
Author: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
AuthorDate: Wed, 20 May 2009 12:21:21 +0200
Committer: Ingo Molnar <mingo@xxxxxxx>
CommitDate: Wed, 20 May 2009 12:43:33 +0200

perf_counter: Optimize disable of time based sw counters

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

[ Impact: micro-optimize the code ]

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
Cc: John Kacur <jkacur@xxxxxxxxxx>
LKML-Reference: <20090520102553.388185031@xxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
kernel/perf_counter.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index db02eb1..473ed2c 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -2716,7 +2716,8 @@ static int cpu_clock_perf_counter_enable(struct perf_counter *counter)

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_enable(struct perf_counter *counter)

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/