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

* Re: [patch] sched: fix SysRq-N (normalize RT tasks)
  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:12 ` Gene Heskett
  2007-06-14 19:09 ` Måns Rullgård
  2 siblings, 1 reply; 6+ messages in thread
From: Gene Heskett @ 2007-06-14 13:48 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, Andrew Morton, linux-kernel, Chris Wright

On Thursday 14 June 2007, Ingo Molnar wrote:
>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);
> }

Ingo:  I appended this patch to the cfs-v16 patch for 2.6.22-rc4, and got this 
while applying it:

patching file kernel/sched.c
Hunk #1 FAILED at 7071.
Hunk #2 FAILED at 7095.
2 out of 2 hunks FAILED -- saving rejects to file kernel/sched.c.rej
done

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
One man tells a falsehood, a hundred repeat it as true.

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

* Re: [patch] sched: fix SysRq-N (normalize RT tasks)
  2007-06-14 13:48 ` Gene Heskett
@ 2007-06-14 13:51   ` Ingo Molnar
  2007-06-14 14:37     ` Gene Heskett
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2007-06-14 13:51 UTC (permalink / raw)
  To: Gene Heskett; +Cc: Linus Torvalds, Andrew Morton, linux-kernel, Chris Wright


* Gene Heskett <gene.heskett@gmail.com> wrote:

> Ingo: I appended this patch to the cfs-v16 patch for 2.6.22-rc4, and 
> got this while applying it:
> 
> patching file kernel/sched.c
> Hunk #1 FAILED at 7071.
> Hunk #2 FAILED at 7095.
> 2 out of 2 hunks FAILED -- saving rejects to file kernel/sched.c.rej

yep, this fix is already included in CFS. (in fact in CFS i also changed 
this function to renormalizing negative-nice tasks to nice-0 - but this 
is not something upstream has to pick up for .22.)

	Ingo

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

* Re: [patch] sched: fix SysRq-N (normalize RT tasks)
  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 14:12 ` Gene Heskett
  2007-06-14 19:09 ` Måns Rullgård
  2 siblings, 0 replies; 6+ messages in thread
From: Gene Heskett @ 2007-06-14 14:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, Andrew Morton, linux-kernel, Chris Wright

On Thursday 14 June 2007, Ingo Molnar wrote:
>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);
> }

When I looked at sched.c, I found it about 1000 lines shorter than the offsets 
listed above.  So I took it back out and will test the plain 
2.6.22-rc4-cfs-v16 shortly.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
To save a single life is better than to build a seven story pagoda.

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

* Re: [patch] sched: fix SysRq-N (normalize RT tasks)
  2007-06-14 13:51   ` Ingo Molnar
@ 2007-06-14 14:37     ` Gene Heskett
  0 siblings, 0 replies; 6+ messages in thread
From: Gene Heskett @ 2007-06-14 14:37 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, Andrew Morton, linux-kernel, Chris Wright

On Thursday 14 June 2007, Ingo Molnar wrote:
>* Gene Heskett <gene.heskett@gmail.com> wrote:
>> Ingo: I appended this patch to the cfs-v16 patch for 2.6.22-rc4, and
>> got this while applying it:
>>
>> patching file kernel/sched.c
>> Hunk #1 FAILED at 7071.
>> Hunk #2 FAILED at 7095.
>> 2 out of 2 hunks FAILED -- saving rejects to file kernel/sched.c.rej
>
>yep, this fix is already included in CFS. (in fact in CFS i also changed
>this function to renormalizing negative-nice tasks to nice-0 - but this
>is not something upstream has to pick up for .22.)
>
>	Ingo

I built it without it, but I saw something else that's been mentioned before 
here:

  MODPOST vmlinux
WARNING: arch/i386/kernel/built-in.o(.text+0x844d): Section mismatch: 
reference to .init.text:amd_init_mtrr (between 'mtrr_bp_init' 
and 'mtrr_save_state')
WARNING: arch/i386/kernel/built-in.o(.text+0x8452): Section mismatch: 
reference to .init.text:cyrix_init_mtrr (between 'mtrr_bp_init' 
and 'mtrr_save_state')
WARNING: arch/i386/kernel/built-in.o(.text+0x8457): Section mismatch: 
reference to .init.text:centaur_init_mtrr (between 'mtrr_bp_init' 
and 'mtrr_save_state')
WARNING: arch/i386/kernel/built-in.o(.text+0x9274): Section mismatch: 
reference to .init.text: (between 'get_mtrr_state' and 'generic_get_mtrr')
WARNING: arch/i386/kernel/built-in.o(.text+0x9288): Section mismatch: 
reference to .init.text: (between 'get_mtrr_state' and 'generic_get_mtrr')
WARNING: arch/i386/kernel/built-in.o(.text+0x92ac): Section mismatch: 
reference to .init.text: (between 'get_mtrr_state' and 'generic_get_mtrr')

Which looks a little worrisome.  Its done, so I'll see if it will boot.

It did.  I had several items that failed on the shutdown, NDI why, but 
everything seemed to restart ok.  Now to live with it for a day or so.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Netscape is not a newsreader, and probably never shall be.
	-- Tom Christiansen

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

* Re: [patch] sched: fix SysRq-N (normalize RT tasks)
  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 14:12 ` Gene Heskett
@ 2007-06-14 19:09 ` Måns Rullgård
  2 siblings, 0 replies; 6+ messages in thread
From: Måns Rullgård @ 2007-06-14 19:09 UTC (permalink / raw)
  To: linux-kernel

Ingo Molnar <mingo@elte.hu> writes:

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

Was this always a bug or did the meaning of for_each_process() change
since this code was added?

-- 
Måns Rullgård
mans@mansr.com


^ 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