aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 96cff2f8710b..4fbc456f393d 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
@@ -20,6 +21,9 @@ static DEFINE_SPINLOCK(kthread_create_lock);
20static LIST_HEAD(kthread_create_list); 21static LIST_HEAD(kthread_create_list);
21struct task_struct *kthreadd_task; 22struct task_struct *kthreadd_task;
22 23
24DEFINE_TRACE(sched_kthread_stop);
25DEFINE_TRACE(sched_kthread_stop_ret);
26
23struct kthread_create_info 27struct kthread_create_info
24{ 28{
25 /* Information passed to kthread() from kthreadd. */ 29 /* Information passed to kthread() from kthreadd. */
@@ -171,12 +175,11 @@ EXPORT_SYMBOL(kthread_create);
171 */ 175 */
172void kthread_bind(struct task_struct *k, unsigned int cpu) 176void kthread_bind(struct task_struct *k, unsigned int cpu)
173{ 177{
174 if (k->state != TASK_UNINTERRUPTIBLE) { 178 /* Must have done schedule() in kthread() before we set_task_cpu */
179 if (!wait_task_inactive(k, TASK_UNINTERRUPTIBLE)) {
175 WARN_ON(1); 180 WARN_ON(1);
176 return; 181 return;
177 } 182 }
178 /* Must have done schedule() in kthread() before we set_task_cpu */
179 wait_task_inactive(k, 0);
180 set_task_cpu(k, cpu); 183 set_task_cpu(k, cpu);
181 k->cpus_allowed = cpumask_of_cpu(cpu); 184 k->cpus_allowed = cpumask_of_cpu(cpu);
182 k->rt.nr_cpus_allowed = 1; 185 k->rt.nr_cpus_allowed = 1;
@@ -206,6 +209,8 @@ int kthread_stop(struct task_struct *k)
206 /* It could exit after stop_info.k set, but before wake_up_process. */ 209 /* It could exit after stop_info.k set, but before wake_up_process. */
207 get_task_struct(k); 210 get_task_struct(k);
208 211
212 trace_sched_kthread_stop(k);
213
209 /* Must init completion *before* thread sees kthread_stop_info.k */ 214 /* Must init completion *before* thread sees kthread_stop_info.k */
210 init_completion(&kthread_stop_info.done); 215 init_completion(&kthread_stop_info.done);
211 smp_wmb(); 216 smp_wmb();
@@ -221,6 +226,8 @@ int kthread_stop(struct task_struct *k)
221 ret = kthread_stop_info.err; 226 ret = kthread_stop_info.err;
222 mutex_unlock(&kthread_stop_lock); 227 mutex_unlock(&kthread_stop_lock);
223 228
229 trace_sched_kthread_stop_ret(ret);
230
224 return ret; 231 return ret;
225} 232}
226EXPORT_SYMBOL(kthread_stop); 233EXPORT_SYMBOL(kthread_stop);