diff options
-rw-r--r-- | include/linux/sched.h | 8 | ||||
-rw-r--r-- | kernel/sched/core.c | 15 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0dd42a02df2e..6eb2ed819e36 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -107,6 +107,14 @@ extern unsigned long this_cpu_load(void); | |||
107 | extern void calc_global_load(unsigned long ticks); | 107 | extern void calc_global_load(unsigned long ticks); |
108 | extern void update_cpu_load_nohz(void); | 108 | extern void update_cpu_load_nohz(void); |
109 | 109 | ||
110 | /* Notifier for when a task gets migrated to a new CPU */ | ||
111 | struct task_migration_notifier { | ||
112 | struct task_struct *task; | ||
113 | int from_cpu; | ||
114 | int to_cpu; | ||
115 | }; | ||
116 | extern void register_task_migration_notifier(struct notifier_block *n); | ||
117 | |||
110 | extern unsigned long get_parent_ip(unsigned long addr); | 118 | extern unsigned long get_parent_ip(unsigned long addr); |
111 | 119 | ||
112 | struct seq_file; | 120 | struct seq_file; |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2d8927fda712..c86b8b6e70f4 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) | |||
922 | rq->skip_clock_update = 1; | 922 | rq->skip_clock_update = 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | static ATOMIC_NOTIFIER_HEAD(task_migration_notifier); | ||
926 | |||
927 | void register_task_migration_notifier(struct notifier_block *n) | ||
928 | { | ||
929 | atomic_notifier_chain_register(&task_migration_notifier, n); | ||
930 | } | ||
931 | |||
925 | #ifdef CONFIG_SMP | 932 | #ifdef CONFIG_SMP |
926 | void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | 933 | void set_task_cpu(struct task_struct *p, unsigned int new_cpu) |
927 | { | 934 | { |
@@ -952,8 +959,16 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | |||
952 | trace_sched_migrate_task(p, new_cpu); | 959 | trace_sched_migrate_task(p, new_cpu); |
953 | 960 | ||
954 | if (task_cpu(p) != new_cpu) { | 961 | if (task_cpu(p) != new_cpu) { |
962 | struct task_migration_notifier tmn; | ||
963 | |||
955 | p->se.nr_migrations++; | 964 | p->se.nr_migrations++; |
956 | perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0); | 965 | perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0); |
966 | |||
967 | tmn.task = p; | ||
968 | tmn.from_cpu = task_cpu(p); | ||
969 | tmn.to_cpu = new_cpu; | ||
970 | |||
971 | atomic_notifier_call_chain(&task_migration_notifier, 0, &tmn); | ||
957 | } | 972 | } |
958 | 973 | ||
959 | __set_task_cpu(p, new_cpu); | 974 | __set_task_cpu(p, new_cpu); |