提交 c350a04e 编写于 作者: M Mike Galbraith 提交者: Ingo Molnar

sched: fix broken SCHED_RESET_ON_FORK handling

Setting child->prio = current->normal_prio _after_ SCHED_RESET_ON_FORK has
been handled for an RT parent gives birth to a deranged mutant child with
non-RT policy, but RT prio and sched_class.

Move PI leakage protection up, always set priorities and weight, and if the
child is leaving RT class, reset rt_priority to the proper value.
Signed-off-by: NMike Galbraith <efault@gmx.de>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1311779695.8691.2.camel@marge.simson.netSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 2c2efaed
...@@ -2843,20 +2843,24 @@ void sched_fork(struct task_struct *p) ...@@ -2843,20 +2843,24 @@ void sched_fork(struct task_struct *p)
*/ */
p->state = TASK_RUNNING; p->state = TASK_RUNNING;
/*
* Make sure we do not leak PI boosting priority to the child.
*/
p->prio = current->normal_prio;
/* /*
* Revert to default priority/policy on fork if requested. * Revert to default priority/policy on fork if requested.
*/ */
if (unlikely(p->sched_reset_on_fork)) { if (unlikely(p->sched_reset_on_fork)) {
if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) { if (task_has_rt_policy(p)) {
p->policy = SCHED_NORMAL; p->policy = SCHED_NORMAL;
p->normal_prio = p->static_prio;
}
if (PRIO_TO_NICE(p->static_prio) < 0) {
p->static_prio = NICE_TO_PRIO(0); p->static_prio = NICE_TO_PRIO(0);
p->normal_prio = p->static_prio; p->rt_priority = 0;
set_load_weight(p); } else if (PRIO_TO_NICE(p->static_prio) < 0)
} p->static_prio = NICE_TO_PRIO(0);
p->prio = p->normal_prio = __normal_prio(p);
set_load_weight(p);
/* /*
* We don't need the reset flag anymore after the fork. It has * We don't need the reset flag anymore after the fork. It has
...@@ -2865,11 +2869,6 @@ void sched_fork(struct task_struct *p) ...@@ -2865,11 +2869,6 @@ void sched_fork(struct task_struct *p)
p->sched_reset_on_fork = 0; p->sched_reset_on_fork = 0;
} }
/*
* Make sure we do not leak PI boosting priority to the child.
*/
p->prio = current->normal_prio;
if (!rt_prio(p->prio)) if (!rt_prio(p->prio))
p->sched_class = &fair_sched_class; p->sched_class = &fair_sched_class;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册