summaryrefslogtreecommitdiff
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorMike Galbraith <efault@gmx.de>2009-06-17 10:46:01 +0200
committerIngo Molnar <mingo@elte.hu>2009-06-17 18:34:17 +0200
commitb9dc29e72fd3dc2a739ce8eafd958220d0745734 (patch)
tree4d9c9130be87a7a876dd623a4ca8891b1232ae41 /kernel/sched.c
parentca94c442535a44d508c99a77e54f21a59f4fc462 (diff)
downloadlwn-b9dc29e72fd3dc2a739ce8eafd958220d0745734.tar.gz
lwn-b9dc29e72fd3dc2a739ce8eafd958220d0745734.zip
sched: Clean up SCHED_RESET_ON_FORK
Make SCHED_RESET_ON_FORK sched_fork() bits a self-contained unlikely code path. Signed-off-by: Mike Galbraith <efault@gmx.de> Acked-by: Lennart Poettering <mzxreary@0pointer.de> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <1245228361.18329.6.camel@marge.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 32e6ede85255..50e4e3d15e83 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2613,28 +2613,30 @@ void sched_fork(struct task_struct *p, int clone_flags)
set_task_cpu(p, cpu);
/*
- * Revert to default priority/policy on fork if requested. Make sure we
- * do not leak PI boosting priority to the child.
+ * Make sure we do not leak PI boosting priority to the child.
*/
- if (current->sched_reset_on_fork &&
- (p->policy == SCHED_FIFO || p->policy == SCHED_RR))
- p->policy = SCHED_NORMAL;
+ p->prio = current->normal_prio;
- if (current->sched_reset_on_fork &&
- (current->normal_prio < DEFAULT_PRIO))
- p->prio = DEFAULT_PRIO;
- else
- p->prio = current->normal_prio;
+ /*
+ * Revert to default priority/policy on fork if requested.
+ */
+ if (unlikely(p->sched_reset_on_fork)) {
+ if (p->policy == SCHED_FIFO || p->policy == SCHED_RR)
+ p->policy = SCHED_NORMAL;
+
+ if (p->normal_prio < DEFAULT_PRIO)
+ p->prio = DEFAULT_PRIO;
+
+ /*
+ * We don't need the reset flag anymore after the fork. It has
+ * fulfilled its duty:
+ */
+ p->sched_reset_on_fork = 0;
+ }
if (!rt_prio(p->prio))
p->sched_class = &fair_sched_class;
- /*
- * We don't need the reset flag anymore after the fork. It has
- * fulfilled its duty:
- */
- p->sched_reset_on_fork = 0;
-
#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
if (likely(sched_info_on()))
memset(&p->sched_info, 0, sizeof(p->sched_info));