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 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>

authored by Ingo Molnar and committed by Linus Torvalds a0f98a1c 4cc21505

+5 -3
+5 -3
kernel/sched.c
··· 7071 7071 void normalize_rt_tasks(void) 7072 7072 { 7073 7073 struct prio_array *array; 7074 - struct task_struct *p; 7074 + struct task_struct *g, *p; 7075 7075 unsigned long flags; 7076 7076 struct rq *rq; 7077 7077 7078 7078 read_lock_irq(&tasklist_lock); 7079 - for_each_process(p) { 7079 + 7080 + do_each_thread(g, p) { 7080 7081 if (!rt_task(p)) 7081 7082 continue; 7082 7083 ··· 7095 7094 7096 7095 __task_rq_unlock(rq); 7097 7096 spin_unlock_irqrestore(&p->pi_lock, flags); 7098 - } 7097 + } while_each_thread(g, p); 7098 + 7099 7099 read_unlock_irq(&tasklist_lock); 7100 7100 } 7101 7101