lkml.org 
[lkml]   [2010]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf_events: improve task_sched_in()
Date
This patch is an optimization in perf_event_task_sched_in() to avoid scheduling
the events twice in a row. Without it, the perf_disable()/perf_enable() pair
is invoked twice, thereby pinned events counts while scheduling flexible events
and we go throuh hw_perf_enable() twice. By encapsulating, the whole sequence
into perf_disable()/perf_enable() we ensure, hw_perf_enable() is going to be
invoked only once because of the refcount protection.

Signed-off-by: Stephane Eranian <eranian@google.com>
--
perf_event.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1382,6 +1382,8 @@ void perf_event_task_sched_in(struct task_struct *task)
if (cpuctx->task_ctx == ctx)
return;

+ perf_disable();
+
/*
* We want to keep the following priority order:
* cpu pinned (that don't need to move), task pinned,
@@ -1394,6 +1396,8 @@ void perf_event_task_sched_in(struct task_struct *task)
ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE);

cpuctx->task_ctx = ctx;
+
+ perf_enable();
}

#define MAX_INTERRUPTS (~0ULL)

\
 
 \ /
  Last update: 2010-03-11 07:29    [W:0.039 / U:14.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site