Commit f83f9ac2 authored by Peter Williams's avatar Peter Williams Committed by Ingo Molnar

sched: Set correct normal_prio and prio values in sched_fork()

normal_prio should be updated if policy changes from RT to
SCHED_MORMAL or if static_prio/nice is changed.

Some paths through sched_fork() ignore this requirement and may
result in normal_prio having an invalid value.

Fixing this issue allows the call to effective_prio() in
wake_up_new_task() to be removed.
Signed-off-by: default avatarPeter Williams <pwil3058@bigpond.net.au>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <f8f46736fd4e7f090ac0.1253774830@mudlark.pw.nest>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 374576a8
...@@ -2514,23 +2514,18 @@ void sched_fork(struct task_struct *p, int clone_flags) ...@@ -2514,23 +2514,18 @@ void sched_fork(struct task_struct *p, int clone_flags)
__sched_fork(p); __sched_fork(p);
/*
* 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 (p->policy == SCHED_FIFO || p->policy == SCHED_RR) {
p->policy = SCHED_NORMAL; p->policy = SCHED_NORMAL;
p->normal_prio = p->static_prio;
if (p->normal_prio < DEFAULT_PRIO) }
p->prio = DEFAULT_PRIO;
if (PRIO_TO_NICE(p->static_prio) < 0) { 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;
set_load_weight(p); set_load_weight(p);
} }
...@@ -2541,6 +2536,11 @@ void sched_fork(struct task_struct *p, int clone_flags) ...@@ -2541,6 +2536,11 @@ void sched_fork(struct task_struct *p, int clone_flags)
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;
...@@ -2581,8 +2581,6 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags) ...@@ -2581,8 +2581,6 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
BUG_ON(p->state != TASK_RUNNING); BUG_ON(p->state != TASK_RUNNING);
update_rq_clock(rq); update_rq_clock(rq);
p->prio = effective_prio(p);
if (!p->sched_class->task_new || !current->se.on_rq) { if (!p->sched_class->task_new || !current->se.on_rq) {
activate_task(rq, p, 0); activate_task(rq, p, 0);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment