.. | .. |
---|
264 | 264 | |
---|
265 | 265 | static int kthread(void *_create) |
---|
266 | 266 | { |
---|
267 | | - static const struct sched_param param = { .sched_priority = 0 }; |
---|
268 | 267 | /* Copy data: it's on kthread's stack */ |
---|
269 | 268 | struct kthread_create_info *create = _create; |
---|
270 | 269 | int (*threadfn)(void *data) = create->threadfn; |
---|
.. | .. |
---|
294 | 293 | init_completion(&self->exited); |
---|
295 | 294 | init_completion(&self->parked); |
---|
296 | 295 | current->vfork_done = &self->exited; |
---|
297 | | - |
---|
298 | | - /* |
---|
299 | | - * The new thread inherited kthreadd's priority and CPU mask. Reset |
---|
300 | | - * back to default in case they have been changed. |
---|
301 | | - */ |
---|
302 | | - sched_setscheduler_nocheck(current, SCHED_NORMAL, ¶m); |
---|
303 | | - set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_KTHREAD)); |
---|
304 | 296 | |
---|
305 | 297 | /* OK, tell user we're spawned, wait for stop or wakeup */ |
---|
306 | 298 | __set_current_state(TASK_UNINTERRUPTIBLE); |
---|
.. | .. |
---|
399 | 391 | } |
---|
400 | 392 | task = create->result; |
---|
401 | 393 | if (!IS_ERR(task)) { |
---|
| 394 | + static const struct sched_param param = { .sched_priority = 0 }; |
---|
402 | 395 | char name[TASK_COMM_LEN]; |
---|
403 | 396 | |
---|
404 | 397 | /* |
---|
.. | .. |
---|
407 | 400 | */ |
---|
408 | 401 | vsnprintf(name, sizeof(name), namefmt, args); |
---|
409 | 402 | set_task_comm(task, name); |
---|
| 403 | + /* |
---|
| 404 | + * root may have changed our (kthreadd's) priority or CPU mask. |
---|
| 405 | + * The kernel thread should not inherit these properties. |
---|
| 406 | + */ |
---|
| 407 | + sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m); |
---|
| 408 | + set_cpus_allowed_ptr(task, |
---|
| 409 | + housekeeping_cpumask(HK_FLAG_KTHREAD)); |
---|
410 | 410 | } |
---|
411 | 411 | kfree(create); |
---|
412 | 412 | return task; |
---|