diff options
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r-- | kernel/kthread.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c index 96cff2f8710b..8e7a7ce3ed0a 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/mutex.h> | 15 | #include <linux/mutex.h> |
16 | #include <trace/sched.h> | ||
16 | 17 | ||
17 | #define KTHREAD_NICE_LEVEL (-5) | 18 | #define KTHREAD_NICE_LEVEL (-5) |
18 | 19 | ||
@@ -171,12 +172,11 @@ EXPORT_SYMBOL(kthread_create); | |||
171 | */ | 172 | */ |
172 | void kthread_bind(struct task_struct *k, unsigned int cpu) | 173 | void kthread_bind(struct task_struct *k, unsigned int cpu) |
173 | { | 174 | { |
174 | if (k->state != TASK_UNINTERRUPTIBLE) { | 175 | /* Must have done schedule() in kthread() before we set_task_cpu */ |
176 | if (!wait_task_inactive(k, TASK_UNINTERRUPTIBLE)) { | ||
175 | WARN_ON(1); | 177 | WARN_ON(1); |
176 | return; | 178 | return; |
177 | } | 179 | } |
178 | /* Must have done schedule() in kthread() before we set_task_cpu */ | ||
179 | wait_task_inactive(k, 0); | ||
180 | set_task_cpu(k, cpu); | 180 | set_task_cpu(k, cpu); |
181 | k->cpus_allowed = cpumask_of_cpu(cpu); | 181 | k->cpus_allowed = cpumask_of_cpu(cpu); |
182 | k->rt.nr_cpus_allowed = 1; | 182 | k->rt.nr_cpus_allowed = 1; |
@@ -206,6 +206,8 @@ int kthread_stop(struct task_struct *k) | |||
206 | /* It could exit after stop_info.k set, but before wake_up_process. */ | 206 | /* It could exit after stop_info.k set, but before wake_up_process. */ |
207 | get_task_struct(k); | 207 | get_task_struct(k); |
208 | 208 | ||
209 | trace_sched_kthread_stop(k); | ||
210 | |||
209 | /* Must init completion *before* thread sees kthread_stop_info.k */ | 211 | /* Must init completion *before* thread sees kthread_stop_info.k */ |
210 | init_completion(&kthread_stop_info.done); | 212 | init_completion(&kthread_stop_info.done); |
211 | smp_wmb(); | 213 | smp_wmb(); |
@@ -221,6 +223,8 @@ int kthread_stop(struct task_struct *k) | |||
221 | ret = kthread_stop_info.err; | 223 | ret = kthread_stop_info.err; |
222 | mutex_unlock(&kthread_stop_lock); | 224 | mutex_unlock(&kthread_stop_lock); |
223 | 225 | ||
226 | trace_sched_kthread_stop_ret(ret); | ||
227 | |||
224 | return ret; | 228 | return ret; |
225 | } | 229 | } |
226 | EXPORT_SYMBOL(kthread_stop); | 230 | EXPORT_SYMBOL(kthread_stop); |