aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authoreranian@google.com <eranian@google.com>2010-03-11 01:26:05 -0500
committerIngo Molnar <mingo@elte.hu>2010-03-11 09:23:28 -0500
commit9b33fa6ba0e2f90fdf407501db801c2511121564 (patch)
treef5314e450afae1f1d4a9feadb0693e20584f62a6 /kernel
parentcaa0142d84ceb0fc83e28f0475d0a7316cb6df77 (diff)
perf_events: Improve task_sched_in()
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> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1268288765-5326-1-git-send-email-eranian@google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/perf_event.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 52c69a34d697..3853d49c7d56 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1368,6 +1368,8 @@ void perf_event_task_sched_in(struct task_struct *task)
1368 if (cpuctx->task_ctx == ctx) 1368 if (cpuctx->task_ctx == ctx)
1369 return; 1369 return;
1370 1370
1371 perf_disable();
1372
1371 /* 1373 /*
1372 * We want to keep the following priority order: 1374 * We want to keep the following priority order:
1373 * cpu pinned (that don't need to move), task pinned, 1375 * cpu pinned (that don't need to move), task pinned,
@@ -1380,6 +1382,8 @@ void perf_event_task_sched_in(struct task_struct *task)
1380 ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE); 1382 ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE);
1381 1383
1382 cpuctx->task_ctx = ctx; 1384 cpuctx->task_ctx = ctx;
1385
1386 perf_enable();
1383} 1387}
1384 1388
1385#define MAX_INTERRUPTS (~0ULL) 1389#define MAX_INTERRUPTS (~0ULL)