public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] sched: fix SysRq-N (normalize RT tasks)
@ 2007-06-14  9:48 Ingo Molnar
  2007-06-14 13:48 ` Gene Heskett
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ingo Molnar @ 2007-06-14  9:48 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Gene Heskett, linux-kernel, Chris Wright

From: Ingo Molnar <mingo@elte.hu>
Subject: [patch] sched: fix SysRq-N (normalize RT tasks)

Gene Heskett reported the following problem while testing CFS: SysRq-N 
is not always effective in normalizing tasks back to SCHED_OTHER.

the reason for that turns out to be the following bug: 
normalize_rt_tasks() uses for_each_process() to iterate through all 
tasks in the system. The problem is, this method does not iterate 
through all tasks, it iterates through all thread groups. The proper 
mechanism to enumerate all tasks is to use a do_each_thread() + 
while_each_thread() loop.

obvious bugfix for v2.6.22 inclusion. -stable candidate as well.

Reported-by: Gene Heskett <gene.heskett@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Index: linux/kernel/sched.c
===================================================================
--- linux/kernel/sched.c
+++ linux/kernel/sched.c
@@ -7071,12 +7071,13 @@ EXPORT_SYMBOL(__might_sleep);
 void normalize_rt_tasks(void)
 {
 	struct prio_array *array;
-	struct task_struct *p;
+	struct task_struct *g, *p;
 	unsigned long flags;
 	struct rq *rq;
 
 	read_lock_irq(&tasklist_lock);
-	for_each_process(p) {
+
+	do_each_thread(g, p) {
 		if (!rt_task(p))
 			continue;
 
@@ -7094,7 +7095,8 @@ void normalize_rt_tasks(void)
 
 		__task_rq_unlock(rq);
 		spin_unlock_irqrestore(&p->pi_lock, flags);
-	}
+	} while_each_thread(g, p);
+
 	read_unlock_irq(&tasklist_lock);
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-06-14 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-14  9:48 [patch] sched: fix SysRq-N (normalize RT tasks) Ingo Molnar
2007-06-14 13:48 ` Gene Heskett
2007-06-14 13:51   ` Ingo Molnar
2007-06-14 14:37     ` Gene Heskett
2007-06-14 14:12 ` Gene Heskett
2007-06-14 19:09 ` Måns Rullgård

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox