Skip to contentSkip to conversation

sched: various fixes

GIT PULL In review Steven Rostedt 4 participants 7 messages Jun 14, 2011 – Jun 15, 2011

lore
Share & tools
lore
#0 lore raw

Ingo,

Please pull the latest tip/sched/urgent tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-rt.git
tip/sched/urgent

Head SHA1: 349d467dc2c8d22df6a891562843bb7d8409f93f

Hillf Danton (1):
sched: Fix need_resched() when checking peempt

Steven Rostedt (1):
sched: Check if lowest_mask is initialized in find_lowest_rq

----

 kernel/sched_rt.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
#1 lore raw

PATCH 1/2 sched: Fix need_resched() when checking peempt

From: Hillf Danton <[email protected]>

The RT preempt check tests the wrong task if NEED_RESCHED is set. It currently checks the local CPU task. It is suppose to check the task that is running on the run queue we are about to wake another task on.

---
 kernel/sched_rt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched_rt.c +1 -1
index 88725c9..9b8d5dc 100644
@@ -1096,7 +1096,7 @@ static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flag
 	 * to move current somewhere else, making room for our non-migratable
 	 * task.
 	 */
-	if (p->prio == rq->curr->prio && !need_resched())
+	if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
 		check_preempt_equal_prio(rq, p);
 #endif
 }
Signature · 1 line
1.7.4.4
#2 lore raw

[tip:sched/urgent] sched: Fix need_resched() when checking peempt

Commit-ID:  8dd0de8be31b4b966d17750a0b10df2f575c91ac
Gitweb:     http://git.kernel.org/tip/8dd0de8be31b4b966d17750a0b10df2f575c91ac
Author:     Hillf Danton <[email protected]>
AuthorDate: Tue, 14 Jun 2011 18:36:24 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 15 Jun 2011 09:50:32 +0200

sched: Fix need_resched() when checking peempt

The RT preempt check tests the wrong task if NEED_RESCHED is set. It currently checks the local CPU task. It is supposed to check the task that is running on the runqueue we are about to wake another task on.

---
 kernel/sched_rt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched_rt.c +1 -1
index 88725c9..9b8d5dc 100644
@@ -1096,7 +1096,7 @@ static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flag
 	 * to move current somewhere else, making room for our non-migratable
 	 * task.
 	 */
-	if (p->prio == rq->curr->prio && !need_resched())
+	if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
 		check_preempt_equal_prio(rq, p);
 #endif
 }
#3 lore raw

PATCH 2/2 sched: Check if lowest_mask is initialized in find_lowest_rq

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

On system boot up, the lowest_mask is initialized with early_initcall. But RT tasks may wake up on other early_initcall callers before the lowest_mask is initialized, causing a system crash.

The commit d72bce0e67 rcu: Cure load woes
was the first commit to wake up RT tasks in early init. Before this commit this bug should not happen.

---
 kernel/sched_rt.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_rt.c +4 -0
index 9b8d5dc..10d0182 100644
@@ -1239,6 +1239,10 @@ static int find_lowest_rq(struct task_struct *task)
 	int this_cpu = smp_processor_id();
 	int cpu      = task_cpu(task);
 
+	/* Make sure the mask is initialized first */
+	if (unlikely(!lowest_mask))
+		return -1;
+
 	if (task->rt.nr_cpus_allowed == 1)
 		return -1; /* No other targets possible */
 
Signature · 1 line
1.7.4.4
Tested-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] sched: Check if lowest_mask is initialized in find_lowest_rq

Quoted 9 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

On system boot up, the lowest_mask is initialized with early_initcall. But RT tasks may wake up on other early_initcall callers before the lowest_mask is initialized, causing a system crash.

The commit d72bce0e67 rcu: Cure load woes
was the first commit to wake up RT tasks in early init. Before this commit this bug should not happen.

I never was able to reproduce this, but after adding Shaohua's patch, I need this one too on some systems. So:

Quoted 29 lines
---
 kernel/sched_rt.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_rt.c +4 -0
index 9b8d5dc..10d0182 100644
@@ -1239,6 +1239,10 @@ static int find_lowest_rq(struct task_struct *task)
 	int this_cpu = smp_processor_id();
 	int cpu      = task_cpu(task);
 
+	/* Make sure the mask is initialized first */
+	if (unlikely(!lowest_mask))
+		return -1;
+
 	if (task->rt.nr_cpus_allowed == 1)
 		return -1; /* No other targets possible */
 
Signature · 1 line
1.7.4.4
Acked-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] sched: Check if lowest_mask is initialized in find_lowest_rq

In reply to Steven Rostedt
Quoted 4 lines · Steven Rostedt

plain text document attachment (0002-sched-Check-if-lowest_mask-is-initialized-in-find_lo.patch)
From: Steven Rostedt <[email protected]>

Quoted 8 lines

On system boot up, the lowest_mask is initialized with early_initcall. But RT tasks may wake up on other early_initcall callers before the lowest_mask is initialized, causing a system crash.

The commit d72bce0e67 rcu: Cure load woes
was the first commit to wake up RT tasks in early init. Before this commit this bug should not happen.

Quoted 24 lines
---
 kernel/sched_rt.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_rt.c +4 -0
index 9b8d5dc..10d0182 100644
@@ -1239,6 +1239,10 @@ static int find_lowest_rq(struct task_struct *task)
 	int this_cpu = smp_processor_id();
 	int cpu      = task_cpu(task);
 
+	/* Make sure the mask is initialized first */
+	if (unlikely(!lowest_mask))
+		return -1;
+
 	if (task->rt.nr_cpus_allowed == 1)
 		return -1; /* No other targets possible */
 
#6 lore raw

[tip:sched/urgent] sched: Check if lowest_mask is initialized in find_lowest_rq()

In reply to Steven Rostedt
Commit-ID:  0da938c44921cfb690283d3b0c9c48a10375db2c
Gitweb:     http://git.kernel.org/tip/0da938c44921cfb690283d3b0c9c48a10375db2c
Author:     Steven Rostedt <[email protected]>
AuthorDate: Tue, 14 Jun 2011 18:36:25 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 15 Jun 2011 11:44:48 +0200

sched: Check if lowest_mask is initialized in find_lowest_rq()

On system boot up, the lowest_mask is initialized with an early_initcall(). But RT tasks may wake up on other early_initcall() callers before the lowest_mask is initialized, causing a system crash.

Commit "d72bce0e67 rcu: Cure load woes" was the first commit to wake up RT tasks in early init. Before this commit this bug should not happen.

---
 kernel/sched_rt.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/sched_rt.c +4 -0
index 9b8d5dc..10d0182 100644
@@ -1239,6 +1239,10 @@ static int find_lowest_rq(struct task_struct *task)
 	int this_cpu = smp_processor_id();
 	int cpu      = task_cpu(task);
 
+	/* Make sure the mask is initialized first */
+	if (unlikely(!lowest_mask))
+		return -1;
+
 	if (task->rt.nr_cpus_allowed == 1)
 		return -1; /* No other targets possible */