diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-04-06 05:45:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-07 04:49:01 -0400 |
commit | bce379bf358738ab8efc8cda2594a299ac685085 (patch) | |
tree | 0840adf32eefc15c5c07e7487c192fd270643057 /kernel/perf_counter.c | |
parent | 849691a6cd40270ff5f4a8846d5f6bf8df663ffc (diff) |
perf_counter: minimize context time updates
Push the update_context_time() calls up the stack so that we get less
invokations and thereby a less noisy output:
before:
# ./perfstat -e 1:0 -e 1:1 -e 1:1 -e 1:1 -l ls > /dev/null
Performance counter stats for 'ls':
10.163691 cpu clock ticks (msecs) (scaled from 98.94%)
10.215360 task clock ticks (msecs) (scaled from 98.18%)
10.185549 task clock ticks (msecs) (scaled from 98.53%)
10.183581 task clock ticks (msecs) (scaled from 98.71%)
Wall-clock time elapsed: 11.912858 msecs
after:
# ./perfstat -e 1:0 -e 1:1 -e 1:1 -e 1:1 -l ls > /dev/null
Performance counter stats for 'ls':
9.316630 cpu clock ticks (msecs)
9.280789 task clock ticks (msecs)
9.280789 task clock ticks (msecs)
9.280789 task clock ticks (msecs)
Wall-clock time elapsed: 9.574872 msecs
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090406094518.618876874@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r-- | kernel/perf_counter.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index f4f7596f7841..863703b3158f 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -319,6 +319,8 @@ static void __perf_counter_disable(void *info) | |||
319 | 319 | ||
320 | spin_lock_irqsave(&ctx->lock, flags); | 320 | spin_lock_irqsave(&ctx->lock, flags); |
321 | 321 | ||
322 | update_context_time(ctx); | ||
323 | |||
322 | /* | 324 | /* |
323 | * If the counter is on, turn it off. | 325 | * If the counter is on, turn it off. |
324 | * If it is in error state, leave it in error state. | 326 | * If it is in error state, leave it in error state. |
@@ -797,6 +799,8 @@ void perf_counter_task_sched_out(struct task_struct *task, int cpu) | |||
797 | if (likely(!cpuctx->task_ctx)) | 799 | if (likely(!cpuctx->task_ctx)) |
798 | return; | 800 | return; |
799 | 801 | ||
802 | update_context_time(ctx); | ||
803 | |||
800 | regs = task_pt_regs(task); | 804 | regs = task_pt_regs(task); |
801 | perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs); | 805 | perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs); |
802 | __perf_counter_sched_out(ctx, cpuctx); | 806 | __perf_counter_sched_out(ctx, cpuctx); |
@@ -2336,7 +2340,6 @@ static void task_clock_perf_counter_update(struct perf_counter *counter) | |||
2336 | u64 prev, now; | 2340 | u64 prev, now; |
2337 | s64 delta; | 2341 | s64 delta; |
2338 | 2342 | ||
2339 | update_context_time(counter->ctx); | ||
2340 | now = counter->ctx->time; | 2343 | now = counter->ctx->time; |
2341 | 2344 | ||
2342 | prev = atomic64_xchg(&counter->hw.prev_count, now); | 2345 | prev = atomic64_xchg(&counter->hw.prev_count, now); |
@@ -2349,7 +2352,6 @@ static int task_clock_perf_counter_enable(struct perf_counter *counter) | |||
2349 | struct hw_perf_counter *hwc = &counter->hw; | 2352 | struct hw_perf_counter *hwc = &counter->hw; |
2350 | u64 now; | 2353 | u64 now; |
2351 | 2354 | ||
2352 | update_context_time(counter->ctx); | ||
2353 | now = counter->ctx->time; | 2355 | now = counter->ctx->time; |
2354 | 2356 | ||
2355 | atomic64_set(&hwc->prev_count, now); | 2357 | atomic64_set(&hwc->prev_count, now); |
@@ -2372,6 +2374,7 @@ static void task_clock_perf_counter_disable(struct perf_counter *counter) | |||
2372 | 2374 | ||
2373 | static void task_clock_perf_counter_read(struct perf_counter *counter) | 2375 | static void task_clock_perf_counter_read(struct perf_counter *counter) |
2374 | { | 2376 | { |
2377 | update_context_time(counter->ctx); | ||
2375 | task_clock_perf_counter_update(counter); | 2378 | task_clock_perf_counter_update(counter); |
2376 | } | 2379 | } |
2377 | 2380 | ||