Skip to contentSkip to conversation

sched/core: Return possibility to set RT and DL classes back

PATCH In review Kirill Tkhai 3 participants 4 messages Feb 27, 2014 – Mar 3, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: Return possibility to set RT and DL classes back

[PATCH]sched/core: Return possibility to set RT and DL classes back

I found that it's impossible to set RT policy for tasks at the moment.

This is regression after commit [sched: Consider pi boosting in setscheduler()]

				[c365c292d05908c6ea6f32708f331e21033fe71d     ]

Fix that.

CC Thomas Gleixner <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/core.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/sched/core.c +4 -0
index 84b23ce..30cf9ad 100644
@@ -3193,6 +3193,10 @@ static void __setscheduler_params(struct task_struct *p,
 	 * getparam()/getattr() don't report silly values for !rt tasks.
 	 */
 	p->rt_priority = attr->sched_priority;
+
+	p->normal_prio = normal_prio(p);
+	p->prio = rt_mutex_getprio(p);
+
 	set_load_weight(p);
 }
 
#1 lore raw

Thomas, have you seen this?

Nothing works at the moment:

now

   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/3                                                                                                                                            
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/2                                                                                                                                            
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1                                                                                                                                            
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                                                                                                           
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 migration/2                                                                                                                                           
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.04 migration/1                                                                                                                                           
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.20 migration/0

with fix

   21 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/3         
   16 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/2         
   11 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1         
   10 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
   22 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                                                                                                           
   17 root      RT   0     0    0    0 S  0.0  0.0   0:00.03 migration/2                                                                                                                                           
   12 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1                                                                                                                                           
    9 root      RT   0     0    0    0 S  0.0  0.0   0:00.24 migration/0

В Чт, 27/02/2014 в 14:24 +0400, Kirill Tkhai пишет:

Quoted 31 lines

[PATCH]sched/core: Return possibility to set RT and DL classes back

I found that it's impossible to set RT policy for tasks at the moment.

This is regression after commit [sched: Consider pi boosting in setscheduler()]

				[c365c292d05908c6ea6f32708f331e21033fe71d     ]

Fix that.

CC Thomas Gleixner <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/core.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/sched/core.c +4 -0
index 84b23ce..30cf9ad 100644
@@ -3193,6 +3193,10 @@ static void __setscheduler_params(struct task_struct *p,
 	 * getparam()/getattr() don't report silly values for !rt tasks.
 	 */
 	p->rt_priority = attr->sched_priority;
+
+	p->normal_prio = normal_prio(p);
+	p->prio = rt_mutex_getprio(p);
+
 	set_load_weight(p);
 }
 
#2 lore raw
Quoted 4 lines · On Fri, 28 Feb 2014 14:50:43 +0400 Kirill Tkhai <[email protected]> wrote:

Thomas, have you seen this?

Nothing works at the moment:

Noticed the same once rebased on tip/master as of today.

Quoted 48 lines

now

   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/3                                                                                                                                            
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/2                                                                                                                                            
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1                                                                                                                                            
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                                                                                                           
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 migration/2                                                                                                                                           
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.04 migration/1                                                                                                                                           
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.20 migration/0

with fix

   21 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/3         
   16 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/2         
   11 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1         
   10 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
   22 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                                                                                                           
   17 root      RT   0     0    0    0 S  0.0  0.0   0:00.03 migration/2                                                                                                                                           
   12 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1                                                                                                                                           
    9 root      RT   0     0    0    0 S  0.0  0.0   0:00.24 migration/0

В Чт, 27/02/2014 в 14:24 +0400, Kirill Tkhai пишет:

Quoted 23 lines

[PATCH]sched/core: Return possibility to set RT and DL classes back

I found that it's impossible to set RT policy for tasks at the moment.

This is regression after commit [sched: Consider pi boosting in setscheduler()]

				[c365c292d05908c6ea6f32708f331e21033fe71d     ]

Fix that.

CC Thomas Gleixner <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/core.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/sched/core.c +0 -0
index 84b23ce..30cf9ad 100644
@@ -3193,6 +3193,10 @@ static void __setscheduler_params(struct task_struct *p,
 	 * getparam()/getattr() don't report silly values for !rt tasks.
 	 */
 	p->rt_priority = attr->sched_priority;
Quoted 8 lines

kernel/sched/core.c static void __setscheduler_params(struct task_struct *p, · line 3202

Quoted 8 lines
kernel/sched/core.c +4 -0
+
+	p->normal_prio = normal_prio(p);
+	p->prio = rt_mutex_getprio(p);
+
 	set_load_weight(p);
 }
 

I'd propose what follows, so that we can still use __setscheduler_params() as it is.

Regards,

- Juri

Quoted 1 line

From 73bae0ad978db6e75f492eea9adff12ec9d6d2a3 Mon Sep 17 00:00:00 2001

From: Juri Lelli <[email protected]>
Date: Sat, 1 Mar 2014 16:43:30 +0100
Subject: [PATCH] sched/core: restore __setscheduler() behavior

Commit c365c29 introduced __setscheduler_params(), that is now used to only store a task's new scheduling parameters in the case it is priority boosted.

Before this change, __setscheduler() was in charge of changing tasks normal_prio and prio, and the latter is used to actually perform sched_class change. Unfortunately, the commit above broke this behavior, causing tasks to remain in fair_sched_class.

Restore the old behaviour setting normal_prio and prio to the right values after the __setscheduler_params() call.

---
 kernel/sched/core.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/sched/core.c +7 -0
index ee8004c..04ae20d 100644
@@ -3206,6 +3206,13 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
 {
 	__setscheduler_params(p, attr);
 
+	/*
+	 * Since we checked before with rt_mutex_check_prio(),
+	 * we don't have pi waiters or our top waiter has lower
+	 * priority (user space view) than what we got.
+	 */
+	p->prio = p->normal_prio = normal_prio(p);
+
 	if (dl_prio(p->prio))
 		p->sched_class = &dl_sched_class;
 	else if (rt_prio(p->prio))
Signature · 1 line
1.7.9.5
maintainer
#3 lore raw
Quoted 9 lines · Juri Lelli

From 73bae0ad978db6e75f492eea9adff12ec9d6d2a3 Mon Sep 17 00:00:00 2001
From: Juri Lelli <[email protected]>
Date: Sat, 1 Mar 2014 16:43:30 +0100
Subject: [PATCH] sched/core: restore __setscheduler() behavior

Commit c365c29 introduced __setscheduler_params(), that is now used to only store a task's new scheduling parameters in the case it is priority boosted.

Quoted 7 lines

Before this change, __setscheduler() was in charge of changing tasks normal_prio and prio, and the latter is used to actually perform sched_class change. Unfortunately, the commit above broke this behavior, causing tasks to remain in fair_sched_class.

Restore the old behaviour setting normal_prio and prio to the right values after the __setscheduler_params() call.

Please also add a Fixes: tag when appropriate, and add to Cc all those two were involved with the original patch.

Fixes c365c292d059 ("sched: Consider pi boosting in setscheduler()")
Quoted 13 lines
---
 kernel/sched/core.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/sched/core.c +0 -0
index ee8004c..04ae20d 100644
@@ -3206,6 +3206,13 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
 {
 	__setscheduler_params(p, attr);
 

kernel/sched/core.c static void __setscheduler(struct rq *rq, struct task_struct *p, · line 3218

Quoted 10 lines
kernel/sched/core.c +7 -0
+	/*
+	 * Since we checked before with rt_mutex_check_prio(),
+	 * we don't have pi waiters or our top waiter has lower
+	 * priority (user space view) than what we got.
+	 */
+	p->prio = p->normal_prio = normal_prio(p);
+
 	if (dl_prio(p->prio))
 		p->sched_class = &dl_sched_class;
 	else if (rt_prio(p->prio))

So there is one more caller of this: normalize_task() but since that is only used to force set all tasks to SCHED_NORMAL ignoring the PI stuff seems perfectly fine.