From 4435f7ea54a42d654d8a77bc03fe915aef57f936 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Tue, 27 Nov 2012 23:28:54 -0200 Subject: [PATCH] --- yaml --- r: 343537 b: refs/heads/master c: 582b336ec2c0f0076f5650a029fcc9abd4a906f7 h: refs/heads/master i: 343535: 01139a7b12bfd0d1a3ac873d76e8e8f4baabe61f v: v3 --- [refs] | 2 +- trunk/include/linux/sched.h | 8 ++++++++ trunk/kernel/sched/core.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 31577e81ff7b..e4451c4d0339 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 189e11731aa858597095fbe1e6d243bad26bd96b +refs/heads/master: 582b336ec2c0f0076f5650a029fcc9abd4a906f7 diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index 0dd42a02df2e..6eb2ed819e36 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -107,6 +107,14 @@ extern unsigned long this_cpu_load(void); extern void calc_global_load(unsigned long ticks); extern void update_cpu_load_nohz(void); +/* Notifier for when a task gets migrated to a new CPU */ +struct task_migration_notifier { + struct task_struct *task; + int from_cpu; + int to_cpu; +}; +extern void register_task_migration_notifier(struct notifier_block *n); + extern unsigned long get_parent_ip(unsigned long addr); struct seq_file; diff --git a/trunk/kernel/sched/core.c b/trunk/kernel/sched/core.c index 2d8927fda712..c86b8b6e70f4 100644 --- a/trunk/kernel/sched/core.c +++ b/trunk/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);