* [PATCH] sched: Set correct normal_prio and prio values in sched_fork()
@ 2009-09-24 6:47 Peter Williams
2009-10-05 11:20 ` Peter Zijlstra
2009-10-05 11:47 ` [tip:sched/urgent] " tip-bot for Peter Williams
0 siblings, 2 replies; 7+ messages in thread
From: Peter Williams @ 2009-09-24 6:47 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
normal_prio should be updated if policy changes from RT to SCHED_MORMAL
or if static_prio/nice is changed. Some paths through sched_fork()
ignore this requirement and may result in normal_prio having an invalid
value.
Fixing this issue allows the call to effective_prio() in
wake_up_new_task() to be removed.
Signed-off-by: Peter Williams <pwil3058@bigpond.net.au>
diff --git a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2515,22 +2515,17 @@ void sched_fork(struct task_struct *p, i
__sched_fork(p);
/*
- * Make sure we do not leak PI boosting priority to the child.
- */
- p->prio = current->normal_prio;
-
- /*
* Revert to default priority/policy on fork if requested.
*/
if (unlikely(p->sched_reset_on_fork)) {
- if (p->policy == SCHED_FIFO || p->policy == SCHED_RR)
+ if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) {
p->policy = SCHED_NORMAL;
-
- if (p->normal_prio < DEFAULT_PRIO)
- p->prio = DEFAULT_PRIO;
+ p->normal_prio = p->static_prio;
+ }
if (PRIO_TO_NICE(p->static_prio) < 0) {
p->static_prio = NICE_TO_PRIO(0);
+ p->normal_prio = p->static_prio;
set_load_weight(p);
}
@@ -2541,6 +2536,11 @@ void sched_fork(struct task_struct *p, i
p->sched_reset_on_fork = 0;
}
+ /*
+ * Make sure we do not leak PI boosting priority to the child.
+ */
+ p->prio = current->normal_prio;
+
if (!rt_prio(p->prio))
p->sched_class = &fair_sched_class;
@@ -2581,8 +2581,6 @@ void wake_up_new_task(struct task_struct
BUG_ON(p->state != TASK_RUNNING);
update_rq_clock(rq);
- p->prio = effective_prio(p);
-
if (!p->sched_class->task_new || !current->se.on_rq) {
activate_task(rq, p, 0);
} else {
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] sched: Set correct normal_prio and prio values in sched_fork()
2009-09-24 6:47 [PATCH] sched: Set correct normal_prio and prio values in sched_fork() Peter Williams
@ 2009-10-05 11:20 ` Peter Zijlstra
2009-10-05 11:47 ` [tip:sched/urgent] " tip-bot for Peter Williams
1 sibling, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2009-10-05 11:20 UTC (permalink / raw)
To: Peter Williams; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
On Thu, 2009-09-24 at 06:47 +0000, Peter Williams wrote:
> normal_prio should be updated if policy changes from RT to SCHED_MORMAL
> or if static_prio/nice is changed. Some paths through sched_fork()
> ignore this requirement and may result in normal_prio having an invalid
> value.
>
> Fixing this issue allows the call to effective_prio() in
> wake_up_new_task() to be removed.
>
> Signed-off-by: Peter Williams <pwil3058@bigpond.net.au>
/me twists his brain into a pretsel, squints his eyes and sees its
obvious ;-)
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Thank Peter!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:sched/urgent] sched: Set correct normal_prio and prio values in sched_fork()
2009-09-24 6:47 [PATCH] sched: Set correct normal_prio and prio values in sched_fork() Peter Williams
2009-10-05 11:20 ` Peter Zijlstra
@ 2009-10-05 11:47 ` tip-bot for Peter Williams
2009-12-12 5:55 ` Arve Hjønnevåg
1 sibling, 1 reply; 7+ messages in thread
From: tip-bot for Peter Williams @ 2009-10-05 11:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, a.p.zijlstra, efault, pwil3058, tglx,
mingo
Commit-ID: f83f9ac2632732bd1678150b5a03d152f912fe72
Gitweb: http://git.kernel.org/tip/f83f9ac2632732bd1678150b5a03d152f912fe72
Author: Peter Williams <pwil3058@bigpond.net.au>
AuthorDate: Thu, 24 Sep 2009 06:47:10 +0000
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 5 Oct 2009 13:42:20 +0200
sched: Set correct normal_prio and prio values in sched_fork()
normal_prio should be updated if policy changes from RT to
SCHED_MORMAL or if static_prio/nice is changed.
Some paths through sched_fork() ignore this requirement and may
result in normal_prio having an invalid value.
Fixing this issue allows the call to effective_prio() in
wake_up_new_task() to be removed.
Signed-off-by: Peter Williams <pwil3058@bigpond.net.au>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <f8f46736fd4e7f090ac0.1253774830@mudlark.pw.nest>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 1535f38..76c0e96 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2515,22 +2515,17 @@ void sched_fork(struct task_struct *p, int clone_flags)
__sched_fork(p);
/*
- * Make sure we do not leak PI boosting priority to the child.
- */
- p->prio = current->normal_prio;
-
- /*
* Revert to default priority/policy on fork if requested.
*/
if (unlikely(p->sched_reset_on_fork)) {
- if (p->policy == SCHED_FIFO || p->policy == SCHED_RR)
+ if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) {
p->policy = SCHED_NORMAL;
-
- if (p->normal_prio < DEFAULT_PRIO)
- p->prio = DEFAULT_PRIO;
+ p->normal_prio = p->static_prio;
+ }
if (PRIO_TO_NICE(p->static_prio) < 0) {
p->static_prio = NICE_TO_PRIO(0);
+ p->normal_prio = p->static_prio;
set_load_weight(p);
}
@@ -2541,6 +2536,11 @@ void sched_fork(struct task_struct *p, int clone_flags)
p->sched_reset_on_fork = 0;
}
+ /*
+ * Make sure we do not leak PI boosting priority to the child.
+ */
+ p->prio = current->normal_prio;
+
if (!rt_prio(p->prio))
p->sched_class = &fair_sched_class;
@@ -2581,8 +2581,6 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
BUG_ON(p->state != TASK_RUNNING);
update_rq_clock(rq);
- p->prio = effective_prio(p);
-
if (!p->sched_class->task_new || !current->se.on_rq) {
activate_task(rq, p, 0);
} else {
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [tip:sched/urgent] sched: Set correct normal_prio and prio values in sched_fork()
2009-10-05 11:47 ` [tip:sched/urgent] " tip-bot for Peter Williams
@ 2009-12-12 5:55 ` Arve Hjønnevåg
2009-12-12 6:07 ` Mike Galbraith
0 siblings, 1 reply; 7+ messages in thread
From: Arve Hjønnevåg @ 2009-12-12 5:55 UTC (permalink / raw)
To: mingo, hpa, linux-kernel, a.p.zijlstra, efault, tglx, pwil3058,
mingo
Cc: linux-tip-commits
On Mon, Oct 5, 2009 at 3:47 AM, tip-bot for Peter Williams
<pwil3058@bigpond.net.au> wrote:
> Commit-ID: f83f9ac2632732bd1678150b5a03d152f912fe72
> Gitweb: http://git.kernel.org/tip/f83f9ac2632732bd1678150b5a03d152f912fe72
> Author: Peter Williams <pwil3058@bigpond.net.au>
> AuthorDate: Thu, 24 Sep 2009 06:47:10 +0000
> Committer: Ingo Molnar <mingo@elte.hu>
> CommitDate: Mon, 5 Oct 2009 13:42:20 +0200
>
> sched: Set correct normal_prio and prio values in sched_fork()
>
> normal_prio should be updated if policy changes from RT to
> SCHED_MORMAL or if static_prio/nice is changed.
>
> Some paths through sched_fork() ignore this requirement and may
> result in normal_prio having an invalid value.
>
> Fixing this issue allows the call to effective_prio() in
> wake_up_new_task() to be removed.
>
This change causes a lot of threads with a 0 nice value to get a prio
value of 140 instead of 120 (at least on my android arm msm build). I
don't know if this has any impact on how they are scheduled since the
load weight is unaffected, but it at least makes the output of ps more
confusing.
--
Arve Hjønnevåg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [tip:sched/urgent] sched: Set correct normal_prio and prio values in sched_fork()
2009-12-12 5:55 ` Arve Hjønnevåg
@ 2009-12-12 6:07 ` Mike Galbraith
2009-12-12 6:16 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Mike Galbraith @ 2009-12-12 6:07 UTC (permalink / raw)
To: Arve Hjønnevåg
Cc: mingo, hpa, linux-kernel, a.p.zijlstra, tglx, pwil3058, mingo,
linux-tip-commits
On Fri, 2009-12-11 at 21:55 -0800, Arve Hjønnevåg wrote:
> On Mon, Oct 5, 2009 at 3:47 AM, tip-bot for Peter Williams
> <pwil3058@bigpond.net.au> wrote:
> > Commit-ID: f83f9ac2632732bd1678150b5a03d152f912fe72
> > Gitweb: http://git.kernel.org/tip/f83f9ac2632732bd1678150b5a03d152f912fe72
> > Author: Peter Williams <pwil3058@bigpond.net.au>
> > AuthorDate: Thu, 24 Sep 2009 06:47:10 +0000
> > Committer: Ingo Molnar <mingo@elte.hu>
> > CommitDate: Mon, 5 Oct 2009 13:42:20 +0200
> >
> > sched: Set correct normal_prio and prio values in sched_fork()
> >
> > normal_prio should be updated if policy changes from RT to
> > SCHED_MORMAL or if static_prio/nice is changed.
> >
> > Some paths through sched_fork() ignore this requirement and may
> > result in normal_prio having an invalid value.
> >
> > Fixing this issue allows the call to effective_prio() in
> > wake_up_new_task() to be removed.
> >
>
> This change causes a lot of threads with a 0 nice value to get a prio
> value of 140 instead of 120 (at least on my android arm msm build). I
> don't know if this has any impact on how they are scheduled since the
> load weight is unaffected, but it at least makes the output of ps more
> confusing.
There's a patch in tip to correct this, hasn't swam upstream yet.
-Mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [tip:sched/urgent] sched: Set correct normal_prio and prio values in sched_fork()
2009-12-12 6:07 ` Mike Galbraith
@ 2009-12-12 6:16 ` Ingo Molnar
2009-12-15 4:19 ` Arve Hjønnevåg
0 siblings, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2009-12-12 6:16 UTC (permalink / raw)
To: Mike Galbraith
Cc: Arve Hj?nnev?g, mingo, hpa, linux-kernel, a.p.zijlstra, tglx,
pwil3058, linux-tip-commits
* Mike Galbraith <efault@gmx.de> wrote:
> On Fri, 2009-12-11 at 21:55 -0800, Arve Hj??nnev??g wrote:
> > On Mon, Oct 5, 2009 at 3:47 AM, tip-bot for Peter Williams
> > <pwil3058@bigpond.net.au> wrote:
> > > Commit-ID: f83f9ac2632732bd1678150b5a03d152f912fe72
> > > Gitweb: http://git.kernel.org/tip/f83f9ac2632732bd1678150b5a03d152f912fe72
> > > Author: Peter Williams <pwil3058@bigpond.net.au>
> > > AuthorDate: Thu, 24 Sep 2009 06:47:10 +0000
> > > Committer: Ingo Molnar <mingo@elte.hu>
> > > CommitDate: Mon, 5 Oct 2009 13:42:20 +0200
> > >
> > > sched: Set correct normal_prio and prio values in sched_fork()
> > >
> > > normal_prio should be updated if policy changes from RT to
> > > SCHED_MORMAL or if static_prio/nice is changed.
> > >
> > > Some paths through sched_fork() ignore this requirement and may
> > > result in normal_prio having an invalid value.
> > >
> > > Fixing this issue allows the call to effective_prio() in
> > > wake_up_new_task() to be removed.
> > >
> >
> > This change causes a lot of threads with a 0 nice value to get a prio
> > value of 140 instead of 120 (at least on my android arm msm build). I
> > don't know if this has any impact on how they are scheduled since the
> > load weight is unaffected, but it at least makes the output of ps more
> > confusing.
>
> There's a patch in tip to correct this, hasn't swam upstream yet.
just sent the pull request to Linus for the latest scheduler fixes.
Meanwhile you can try latest -tip with the fix:
http://people.redhat.com/mingo/tip.git/README
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [tip:sched/urgent] sched: Set correct normal_prio and prio values in sched_fork()
2009-12-12 6:16 ` Ingo Molnar
@ 2009-12-15 4:19 ` Arve Hjønnevåg
0 siblings, 0 replies; 7+ messages in thread
From: Arve Hjønnevåg @ 2009-12-15 4:19 UTC (permalink / raw)
To: Ingo Molnar
Cc: Mike Galbraith, mingo, hpa, linux-kernel, a.p.zijlstra, tglx,
pwil3058, linux-tip-commits
On Fri, Dec 11, 2009 at 10:16 PM, Ingo Molnar <mingo@elte.hu> wrote:
>
> * Mike Galbraith <efault@gmx.de> wrote:
>
>> On Fri, 2009-12-11 at 21:55 -0800, Arve Hj??nnev??g wrote:
>> > On Mon, Oct 5, 2009 at 3:47 AM, tip-bot for Peter Williams
>> > <pwil3058@bigpond.net.au> wrote:
>> > > Commit-ID: f83f9ac2632732bd1678150b5a03d152f912fe72
>> > > Gitweb: http://git.kernel.org/tip/f83f9ac2632732bd1678150b5a03d152f912fe72
>> > > Author: Peter Williams <pwil3058@bigpond.net.au>
>> > > AuthorDate: Thu, 24 Sep 2009 06:47:10 +0000
>> > > Committer: Ingo Molnar <mingo@elte.hu>
>> > > CommitDate: Mon, 5 Oct 2009 13:42:20 +0200
>> > >
>> > > sched: Set correct normal_prio and prio values in sched_fork()
>> > >
>> > > normal_prio should be updated if policy changes from RT to
>> > > SCHED_MORMAL or if static_prio/nice is changed.
>> > >
>> > > Some paths through sched_fork() ignore this requirement and may
>> > > result in normal_prio having an invalid value.
>> > >
>> > > Fixing this issue allows the call to effective_prio() in
>> > > wake_up_new_task() to be removed.
>> > >
>> >
>> > This change causes a lot of threads with a 0 nice value to get a prio
>> > value of 140 instead of 120 (at least on my android arm msm build). I
>> > don't know if this has any impact on how they are scheduled since the
>> > load weight is unaffected, but it at least makes the output of ps more
>> > confusing.
>>
>> There's a patch in tip to correct this, hasn't swam upstream yet.
>
> just sent the pull request to Linus for the latest scheduler fixes.
> Meanwhile you can try latest -tip with the fix:
>
> http://people.redhat.com/mingo/tip.git/README
>
> Ingo
>
Thanks. The fix is upstream now though, so I just cherry-picked it from there.
--
Arve Hjønnevåg
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-12-15 4:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 6:47 [PATCH] sched: Set correct normal_prio and prio values in sched_fork() Peter Williams
2009-10-05 11:20 ` Peter Zijlstra
2009-10-05 11:47 ` [tip:sched/urgent] " tip-bot for Peter Williams
2009-12-12 5:55 ` Arve Hjønnevåg
2009-12-12 6:07 ` Mike Galbraith
2009-12-12 6:16 ` Ingo Molnar
2009-12-15 4:19 ` Arve Hjønnevåg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox