* [PATCH] sched: Make sure task has correct sched_class after policy change
@ 2009-09-23 2:03 Peter Williams
0 siblings, 0 replies; 7+ messages in thread
From: Peter Williams @ 2009-09-23 2:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Peter Zijlstra, Mike Galbraith, Linux Kernel Mailing
>From the code in rt_mutex_setprio(), it is evident that the intention
is that task's with a RT 'prio' value as a consequence of receiving a PI
boost also have their 'sched_class' field set to '&rt_sched_class'.
However, the code in __setscheduler() could result in this intention
being frustrated.
This patch fixes this problem.
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
@@ -6159,6 +6159,8 @@ __setscheduler(struct rq *rq, struct tas
p->normal_prio = normal_prio(p);
/* we are holding p->pi_lock already */
p->prio = rt_mutex_getprio(p);
+ if (rt_prio(prio))
+ p->sched_class = &rt_sched_class;
set_load_weight(p);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] sched: Make sure task has correct sched_class after policy change
@ 2009-09-23 2:21 Peter Williams
2009-09-23 6:32 ` Peter Zijlstra
0 siblings, 1 reply; 7+ messages in thread
From: Peter Williams @ 2009-09-23 2:21 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Peter Zijlstra, Mike Galbraith, Linux Kernel Mailing
>From the code in rt_mutex_setprio(), it is evident that the intention
is that task's with a RT 'prio' value as a consequence of receiving a PI
boost also have their 'sched_class' field set to '&rt_sched_class'.
However, the code in __setscheduler() could result in this intention
being frustrated.
This patch fixes this problem.
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
@@ -6159,6 +6159,8 @@ __setscheduler(struct rq *rq, struct tas
p->normal_prio = normal_prio(p);
/* we are holding p->pi_lock already */
p->prio = rt_mutex_getprio(p);
+ if (rt_prio(p->prio))
+ p->sched_class = &rt_sched_class;
set_load_weight(p);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched: Make sure task has correct sched_class after policy change
2009-09-23 2:21 [PATCH] sched: Make sure task has correct sched_class after policy change Peter Williams
@ 2009-09-23 6:32 ` Peter Zijlstra
2009-09-23 12:40 ` Peter Williams
2009-10-14 13:13 ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
0 siblings, 2 replies; 7+ messages in thread
From: Peter Zijlstra @ 2009-09-23 6:32 UTC (permalink / raw)
To: Peter Williams; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
On Wed, 2009-09-23 at 02:21 +0000, Peter Williams wrote:
> From the code in rt_mutex_setprio(), it is evident that the intention
> is that task's with a RT 'prio' value as a consequence of receiving a PI
> boost also have their 'sched_class' field set to '&rt_sched_class'.
> However, the code in __setscheduler() could result in this intention
> being frustrated.
>
> This patch fixes this problem.
>
> Signed-off-by: Peter Williams <pwil3058@bigpond.net.au>
I think you're right, but the problem seems to be that it sets
sched_class based on policy, which seems fragile in the face of PI.
How about the alternative below?
---
kernel/sched.c | 17 ++++-------------
1 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 91843ba..753a52c 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6129,23 +6129,14 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio)
{
BUG_ON(p->se.on_rq);
- p->policy = policy;
- switch (p->policy) {
- case SCHED_NORMAL:
- case SCHED_BATCH:
- case SCHED_IDLE:
- p->sched_class = &fair_sched_class;
- break;
- case SCHED_FIFO:
- case SCHED_RR:
- p->sched_class = &rt_sched_class;
- break;
- }
-
p->rt_priority = prio;
p->normal_prio = normal_prio(p);
/* we are holding p->pi_lock already */
p->prio = rt_mutex_getprio(p);
+ if (rt_prio(p->prio))
+ p->sched_class = &rt_sched_class;
+ else
+ p->sched_class = &fair_sched_class;
set_load_weight(p);
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] sched: Make sure task has correct sched_class after policy change
2009-09-23 6:32 ` Peter Zijlstra
@ 2009-09-23 12:40 ` Peter Williams
2009-10-12 0:36 ` Peter Williams
2009-10-14 13:13 ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
1 sibling, 1 reply; 7+ messages in thread
From: Peter Williams @ 2009-09-23 12:40 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
On 23/09/09 16:32, Peter Zijlstra wrote:
> On Wed, 2009-09-23 at 02:21 +0000, Peter Williams wrote:
>> From the code in rt_mutex_setprio(), it is evident that the intention
>> is that task's with a RT 'prio' value as a consequence of receiving a PI
>> boost also have their 'sched_class' field set to '&rt_sched_class'.
>> However, the code in __setscheduler() could result in this intention
>> being frustrated.
>>
>> This patch fixes this problem.
>>
>> Signed-off-by: Peter Williams<pwil3058@bigpond.net.au>
>
> I think you're right, but the problem seems to be that it sets
> sched_class based on policy, which seems fragile in the face of PI.
>
> How about the alternative below?
Yes, that's what I meant to do i.e. use p->prio in the if condition. I
sent a second patch with a fix but your solution is neater :-).
>
> ---
> kernel/sched.c | 17 ++++-------------
> 1 files changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 91843ba..753a52c 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -6129,23 +6129,14 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio)
> {
> BUG_ON(p->se.on_rq);
>
> - p->policy = policy;
> - switch (p->policy) {
> - case SCHED_NORMAL:
> - case SCHED_BATCH:
> - case SCHED_IDLE:
> - p->sched_class =&fair_sched_class;
> - break;
> - case SCHED_FIFO:
> - case SCHED_RR:
> - p->sched_class =&rt_sched_class;
> - break;
> - }
> -
> p->rt_priority = prio;
> p->normal_prio = normal_prio(p);
> /* we are holding p->pi_lock already */
> p->prio = rt_mutex_getprio(p);
> + if (rt_prio(p->prio))
> + p->sched_class =&rt_sched_class;
> + else
> + p->sched_class =&fair_sched_class;
> set_load_weight(p);
> }
Peter
--
Peter Williams pwil3058@bigpond.net.au
"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched: Make sure task has correct sched_class after policy change
2009-09-23 12:40 ` Peter Williams
@ 2009-10-12 0:36 ` Peter Williams
2009-10-12 15:34 ` Peter Zijlstra
0 siblings, 1 reply; 7+ messages in thread
From: Peter Williams @ 2009-10-12 0:36 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
On 23/09/09 22:40, Peter Williams wrote:
> On 23/09/09 16:32, Peter Zijlstra wrote:
>> On Wed, 2009-09-23 at 02:21 +0000, Peter Williams wrote:
>>> From the code in rt_mutex_setprio(), it is evident that the intention
>>> is that task's with a RT 'prio' value as a consequence of receiving a PI
>>> boost also have their 'sched_class' field set to '&rt_sched_class'.
>>> However, the code in __setscheduler() could result in this intention
>>> being frustrated.
>>>
>>> This patch fixes this problem.
>>>
>>> Signed-off-by: Peter Williams<pwil3058@bigpond.net.au>
>>
>> I think you're right, but the problem seems to be that it sets
>> sched_class based on policy, which seems fragile in the face of PI.
>>
>> How about the alternative below?
>
> Yes, that's what I meant to do i.e. use p->prio in the if condition. I
> sent a second patch with a fix but your solution is neater :-).
>
>>
>> ---
>> kernel/sched.c | 17 ++++-------------
>> 1 files changed, 4 insertions(+), 13 deletions(-)
>>
>> diff --git a/kernel/sched.c b/kernel/sched.c
>> index 91843ba..753a52c 100644
>> --- a/kernel/sched.c
>> +++ b/kernel/sched.c
>> @@ -6129,23 +6129,14 @@ __setscheduler(struct rq *rq, struct
>> task_struct *p, int policy, int prio)
>> {
>> BUG_ON(p->se.on_rq);
>>
>> - p->policy = policy;
>> - switch (p->policy) {
>> - case SCHED_NORMAL:
>> - case SCHED_BATCH:
>> - case SCHED_IDLE:
>> - p->sched_class =&fair_sched_class;
>> - break;
>> - case SCHED_FIFO:
>> - case SCHED_RR:
>> - p->sched_class =&rt_sched_class;
>> - break;
>> - }
>> -
>> p->rt_priority = prio;
>> p->normal_prio = normal_prio(p);
>> /* we are holding p->pi_lock already */
>> p->prio = rt_mutex_getprio(p);
>> + if (rt_prio(p->prio))
>> + p->sched_class =&rt_sched_class;
>> + else
>> + p->sched_class =&fair_sched_class;
>> set_load_weight(p);
>> }
>
> Peter
What ever happened to this patch? It doesn't seem to have made it into
the main line yet.
Cheers
Peter
--
Peter Williams pwil3058@bigpond.net.au
"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sched: Make sure task has correct sched_class after policy change
2009-10-12 0:36 ` Peter Williams
@ 2009-10-12 15:34 ` Peter Zijlstra
0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2009-10-12 15:34 UTC (permalink / raw)
To: Peter Williams; +Cc: Ingo Molnar, Mike Galbraith, Linux Kernel Mailing
On Mon, 2009-10-12 at 10:36 +1000, Peter Williams wrote:
> What ever happened to this patch? It doesn't seem to have made it into
> the main line yet.
I,.. uhm,.. guess I'm turning senile and utterly forgot about it.
Queued it, thanks for reminding me!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:sched/urgent] sched: Make sure task has correct sched_class after policy change
2009-09-23 6:32 ` Peter Zijlstra
2009-09-23 12:40 ` Peter Williams
@ 2009-10-14 13:13 ` tip-bot for Peter Zijlstra
1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Peter Zijlstra @ 2009-10-14 13:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, a.p.zijlstra, pwil3058, tglx, mingo
Commit-ID: 67d08dfed042855431dc99c9e0e6f6f7e85737ef
Gitweb: http://git.kernel.org/tip/67d08dfed042855431dc99c9e0e6f6f7e85737ef
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 12 Oct 2009 17:20:54 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 14 Oct 2009 15:02:35 +0200
sched: Make sure task has correct sched_class after policy change
>From the code in rt_mutex_setprio(), it is evident that the
intention is that task's with a RT 'prio' value as a consequence of
receiving a PI boost also have their 'sched_class' field set to
'&rt_sched_class'.
However, Peter noticed that the code in __setscheduler() could
result in this intention being frustrated. Fix it.
Reported-by: Peter Williams <pwil3058@bigpond.net.au>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1253687579.7695.89.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 17 ++++-------------
1 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 789001d..2d7a002 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6145,23 +6145,14 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio)
{
BUG_ON(p->se.on_rq);
- p->policy = policy;
- switch (p->policy) {
- case SCHED_NORMAL:
- case SCHED_BATCH:
- case SCHED_IDLE:
- p->sched_class = &fair_sched_class;
- break;
- case SCHED_FIFO:
- case SCHED_RR:
- p->sched_class = &rt_sched_class;
- break;
- }
-
p->rt_priority = prio;
p->normal_prio = normal_prio(p);
/* we are holding p->pi_lock already */
p->prio = rt_mutex_getprio(p);
+ if (rt_prio(p->prio))
+ p->sched_class = &rt_sched_class;
+ else
+ p->sched_class = &fair_sched_class;
set_load_weight(p);
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-10-14 13:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-23 2:21 [PATCH] sched: Make sure task has correct sched_class after policy change Peter Williams
2009-09-23 6:32 ` Peter Zijlstra
2009-09-23 12:40 ` Peter Williams
2009-10-12 0:36 ` Peter Williams
2009-10-12 15:34 ` Peter Zijlstra
2009-10-14 13:13 ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2009-09-23 2:03 [PATCH] " Peter Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox