perf_events: improve task_sched_in()
PATCH 1/1 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.
--
perf_event.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/perf_event.c +4 -0
@@ -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)
Quoted 6 lines · On Wed, 2010-03-10 at 22:26 -0800, [email protected] wrote:
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 throuhhw_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.
Agreed, this makes perfect sense.
Quoted 25 lines
Signed-off-by Stephane Eranian <[email protected]>--
perf_event.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/perf_event.c +4
-0@@ -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)
[tip:perf/core] perf_events: Improve task_sched_in()
In reply to [email protected]Commit-ID: 9b33fa6ba0e2f90fdf407501db801c2511121564 Gitweb: http://git.kernel.org/tip/9b33fa6ba0e2f90fdf407501db801c2511121564 Author: [email protected] <[email protected]> AuthorDate: Wed, 10 Mar 2010 22:26:05 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 11 Mar 2010 15:23:28 +0100
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.
LKML-Reference: <[email protected]>
--- kernel/perf_event.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/perf_event.c +4 -0
@@ -1368,6 +1368,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,
@@ -1380,6 +1382,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)