[PATCH 2/3] UBUNTU: [Upstream] sched: Clean up SCHED_RESET_ON_FORK

Luke Yelavich themuso at ubuntu.com
Tue Aug 25 02:25:01 UTC 2009


From: Mike Galbraith <efault at gmx.de>

Make SCHED_RESET_ON_FORK sched_fork() bits a self-contained unlikely code path.

OriginalAuthor: Mike Galbraith <efault at gmx.de>
OriginalLocation: git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-tip.git
Signed-off-by: Mike Galbraith <efault at gmx.de>
Acked-by: Lennart Poettering <mzxreary at 0pointer.de>
Cc: Peter Zijlstra <peterz at infradead.org>
LKML-Reference: <1245228361.18329.6.camel at marge.simson.net>
Signed-off-by: Ingo Molnar <mingo at elte.hu>
Signed-off-by: Luke Yelavich <luke.yelavich at canonical.com>
---
 kernel/sched.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 0c21f69..904fe73 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2637,28 +2637,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));
-- 
1.6.3.3





More information about the kernel-team mailing list