diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-11-20 16:19:46 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-21 08:11:36 -0500 |
commit | d6ff86cfb50a72df820e7e839836d55d245306fb (patch) | |
tree | e615cbbc693da8c5000d5eb3a022207c7f85605a /kernel | |
parent | 81520183878a8813c71c9372de28bb70913ba549 (diff) |
perf: Optimize perf_event_task_ctx()
Remove a rcu_read_{,un}lock() pair and a few conditionals.
We can remove the rcu_read_lock() by increasing the scope of one
in the calling function.
We can do away with the system_state check if the machine still
boots after this patch (seems to be the case).
We can do away with the list_empty() check because the bare
list_for_each_entry_rcu() reduces to that now that we've removed
everything else.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091120212508.452227115@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_event.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index cda17acfcaf8..2afb305944af 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -3267,15 +3267,10 @@ static void perf_event_task_ctx(struct perf_event_context *ctx, | |||
3267 | { | 3267 | { |
3268 | struct perf_event *event; | 3268 | struct perf_event *event; |
3269 | 3269 | ||
3270 | if (system_state != SYSTEM_RUNNING || list_empty(&ctx->event_list)) | ||
3271 | return; | ||
3272 | |||
3273 | rcu_read_lock(); | ||
3274 | list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { | 3270 | list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { |
3275 | if (perf_event_task_match(event)) | 3271 | if (perf_event_task_match(event)) |
3276 | perf_event_task_output(event, task_event); | 3272 | perf_event_task_output(event, task_event); |
3277 | } | 3273 | } |
3278 | rcu_read_unlock(); | ||
3279 | } | 3274 | } |
3280 | 3275 | ||
3281 | static void perf_event_task_event(struct perf_task_event *task_event) | 3276 | static void perf_event_task_event(struct perf_task_event *task_event) |
@@ -3283,11 +3278,11 @@ static void perf_event_task_event(struct perf_task_event *task_event) | |||
3283 | struct perf_cpu_context *cpuctx; | 3278 | struct perf_cpu_context *cpuctx; |
3284 | struct perf_event_context *ctx = task_event->task_ctx; | 3279 | struct perf_event_context *ctx = task_event->task_ctx; |
3285 | 3280 | ||
3281 | rcu_read_lock(); | ||
3286 | cpuctx = &get_cpu_var(perf_cpu_context); | 3282 | cpuctx = &get_cpu_var(perf_cpu_context); |
3287 | perf_event_task_ctx(&cpuctx->ctx, task_event); | 3283 | perf_event_task_ctx(&cpuctx->ctx, task_event); |
3288 | put_cpu_var(perf_cpu_context); | 3284 | put_cpu_var(perf_cpu_context); |
3289 | 3285 | ||
3290 | rcu_read_lock(); | ||
3291 | if (!ctx) | 3286 | if (!ctx) |
3292 | ctx = rcu_dereference(task_event->task->perf_event_ctxp); | 3287 | ctx = rcu_dereference(task_event->task->perf_event_ctxp); |
3293 | if (ctx) | 3288 | if (ctx) |