aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index ac3fb732664..8e7a7ce3ed0 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
@@ -106,7 +107,7 @@ static void create_kthread(struct kthread_create_info *create)
106 */ 107 */
107 sched_setscheduler(create->result, SCHED_NORMAL, &param); 108 sched_setscheduler(create->result, SCHED_NORMAL, &param);
108 set_user_nice(create->result, KTHREAD_NICE_LEVEL); 109 set_user_nice(create->result, KTHREAD_NICE_LEVEL);
109 set_cpus_allowed(create->result, CPU_MASK_ALL); 110 set_cpus_allowed_ptr(create->result, CPU_MASK_ALL_PTR);
110 } 111 }
111 complete(&create->done); 112 complete(&create->done);
112} 113}
@@ -171,12 +172,11 @@ EXPORT_SYMBOL(kthread_create);
171 */ 172 */
172void kthread_bind(struct task_struct *k, unsigned int cpu) 173void 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);
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}
226EXPORT_SYMBOL(kthread_stop); 230EXPORT_SYMBOL(kthread_stop);
@@ -233,7 +237,7 @@ int kthreadd(void *unused)
233 set_task_comm(tsk, "kthreadd"); 237 set_task_comm(tsk, "kthreadd");
234 ignore_signals(tsk); 238 ignore_signals(tsk);
235 set_user_nice(tsk, KTHREAD_NICE_LEVEL); 239 set_user_nice(tsk, KTHREAD_NICE_LEVEL);
236 set_cpus_allowed(tsk, CPU_MASK_ALL); 240 set_cpus_allowed_ptr(tsk, CPU_MASK_ALL_PTR);
237 241
238 current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG; 242 current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG;
239 243