Skip to content

Commit

Permalink
sched: fix SysRq-N (normalize RT tasks)
Browse files Browse the repository at this point in the history
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 over all threads is to use a
do_each_thread() + while_each_thread() loop.

Reported-by: Gene Heskett <gene.heskett@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Jun 18, 2007
1 parent 4cc2150 commit a0f98a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand Down

0 comments on commit a0f98a1

Please sign in to comment.