summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2012-11-27 23:28:54 -0200
committerMarcelo Tosatti <mtosatti@redhat.com>2012-11-27 23:29:09 -0200
commit582b336ec2c0f0076f5650a029fcc9abd4a906f7 (patch)
tree4827fe468a1aac8be0227cac5bab922b32c2facc /kernel
parent189e11731aa858597095fbe1e6d243bad26bd96b (diff)
downloadop-kernel-dev-582b336ec2c0f0076f5650a029fcc9abd4a906f7.zip
op-kernel-dev-582b336ec2c0f0076f5650a029fcc9abd4a906f7.tar.gz
sched: add notifier for cross-cpu migrations
Originally from Jeremy Fitzhardinge. Acked-by: Ingo Molnar <mingo@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/core.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927f..c86b8b6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -922,6 +922,13 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
rq->skip_clock_update = 1;
}
+static ATOMIC_NOTIFIER_HEAD(task_migration_notifier);
+
+void register_task_migration_notifier(struct notifier_block *n)
+{
+ atomic_notifier_chain_register(&task_migration_notifier, n);
+}
+
#ifdef CONFIG_SMP
void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
{
@@ -952,8 +959,16 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
trace_sched_migrate_task(p, new_cpu);
if (task_cpu(p) != new_cpu) {
+ struct task_migration_notifier tmn;
+
p->se.nr_migrations++;
perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0);
+
+ tmn.task = p;
+ tmn.from_cpu = task_cpu(p);
+ tmn.to_cpu = new_cpu;
+
+ atomic_notifier_call_chain(&task_migration_notifier, 0, &tmn);
}
__set_task_cpu(p, new_cpu);
OpenPOWER on IntegriCloud