Skip to contentSkip to conversation

sched/rt: Do not try to push tasks if pinned task switches to RT

PATCH Kirill Tkhai 5 participants 7 messages Jan 29, 2013 – Apr 18, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw
Quoted 34 lines · Kirill Tkhai
Quoted 4 lines

Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

Thanks, but I have one minor nit.

Quoted 13 lines
CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>

---
kernel/sched/rt.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +0 -0
index 4e8f0f4..5f7d92b 100644

kernel/sched/rt.c static void switched_to_rt(struct rq *rq, struct task_struct *p) · line 1928

Quoted 5 lines
kernel/sched/rt.c +1 -1
@@ -1925,9 +1925,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
 */
 if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
- if (rq->rt.overloaded && push_rt_task(rq) &&
+ if (rq->rt.overloaded && p->nr_cpus_allowed > 1 &&

I would swap the order here. That is, check p->nr_cpus_allowed before rq->rt.overloaded. The order doesn't really matter, and even though rq->rt.overloaded is probably more likely to be 0, it is used by other CPUs. And as a micro-optimization, I rather read something that is used by only one CPU than to read something that may be modified by many CPUs.

Quoted 2 lines

-- Steve

I corrected. Thanks.

[PATCH]sched/rt: Do not try to push tasks if pinned task switches to RT

Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>
---
 kernel/sched/rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index 4e8f0f4..5aab032 100644
@@ -1925,9 +1925,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
 	 */
 	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->rt.overloaded && push_rt_task(rq) &&
+		if (p->nr_cpus_allowed > 1 && rq->rt.overloaded &&
 		    /* Don't resched if we changed runqueues */
-		    rq != task_rq(p))
+		    push_rt_task(rq) && rq != task_rq(p))
 			check_resched = 0;
 #endif /* CONFIG_SMP */
 		if (check_resched && p->prio < rq->curr->prio)
reviewer Acked-by
#1 lore raw

Peter,

I'm going through my inbox (over a year old), and found this patch from Kirill. It looks fine to me. You can apply it with my

-- Steve

[PATCH]sched/rt: Do not try to push tasks if pinned task switches to RT

Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>
---
 kernel/sched/rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index 4e8f0f4..5aab032 100644
@@ -1925,9 +1925,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
 	 */
 	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->rt.overloaded && push_rt_task(rq) &&
+		if (p->nr_cpus_allowed > 1 && rq->rt.overloaded &&
 		    /* Don't resched if we changed runqueues */
-		    rq != task_rq(p))
+		    push_rt_task(rq) && rq != task_rq(p))
 			check_resched = 0;
 #endif /* CONFIG_SMP */
 		if (check_resched && p->prio < rq->curr->prio)
#2 lore raw
Quoted 29 lines · Steven Rostedt

Peter,

I'm going through my inbox (over a year old), and found this patch from Kirill. It looks fine to me. You can apply it with my

-- Steve

[PATCH]sched/rt: Do not try to push tasks if pinned task switches to RT

Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>
---
 kernel/sched/rt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +0 -0
index 4e8f0f4..5aab032 100644
@@ -1925,9 +1925,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
 	 */

kernel/sched/rt.c static void switched_to_rt(struct rq *rq, struct task_struct *p) · line 1933

Quoted 10 lines
kernel/sched/rt.c +2 -2
 	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->rt.overloaded && push_rt_task(rq) &&
+		if (p->nr_cpus_allowed > 1 && rq->rt.overloaded &&
 		    /* Don't resched if we changed runqueues */
-		    rq != task_rq(p))
+		    push_rt_task(rq) && rq != task_rq(p))
 			check_resched = 0;
 #endif /* CONFIG_SMP */
 		if (check_resched && p->prio < rq->curr->prio)

would there not need to be a check for p->migrate_disable ? push_rt_task() is not checking and so a high prio RT task preemting a low prio RT task in a migrate_disable() section would actually push it off this cpu ? atleast I did not find why that would not happen.

thx!
hofrat

#3 lore raw

12.03.2014, 14:39, "Nicholas Mc Guire" <[email protected]>:

Quoted 42 lines · Steven Rostedt
Quoted 24 lines

 Peter,

 I'm going through my inbox (over a year old), and found this patch from Kirill. It looks fine to me. You can apply it with my

 -- Steve

 [PATCH]sched/rt: Do not try to push tasks if pinned task switches to RT

 Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC linux-rt-users <[email protected]>

 ---
  kernel/sched/rt.c |    4 ++--

  1 files changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

 diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
 index 4e8f0f4..5aab032 100644
 --- a/kernel/sched/rt.c
 +++ b/kernel/sched/rt.c
 @@ -1925,9 +1925,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p) */
          if (p->on_rq && rq->curr != p) {
  #ifdef CONFIG_SMP
 - if (rq->rt.overloaded && push_rt_task(rq) &&
 + if (p->nr_cpus_allowed > 1 && rq->rt.overloaded &&
                      /* Don't resched if we changed runqueues */
 -    rq != task_rq(p))
 +    push_rt_task(rq) && rq != task_rq(p))
                          check_resched = 0;
  #endif /* CONFIG_SMP */
                  if (check_resched && p->prio < rq->curr->prio)

Quoted 5 lines

would there not need to be a check for p->migrate_disable ? push_rt_task() is not checking and so a high prio RT task preemting a low prio RT task in a migrate_disable() section would actually push it off this cpu ? atleast I did not find why that would not happen.

Hi, Nicholas!

p is not rq->curr, so its p->migrate_disable state is already updated and it can't be pushed (nr_cpus_allowed == 1 and it's not pushable).

(If I understand right, that you worry about this).

Kirill

Quoted 2 lines

thx!
hofrat

maintainer
#5 lore raw
In reply to Steven Rostedt
Quoted 5 lines · Steven Rostedt

Peter,

I'm going through my inbox (over a year old), and found this patch from Kirill. It looks fine to me. You can apply it with my

Thanks!

#4 lore raw
In reply to Kirill Tkhai
Quoted 6 lines · On Wed, 12 Mar 2014 16:23:48 +0400 Kirill Tkhai <[email protected]> wrote:
Quoted 5 lines

would there not need to be a check for p->migrate_disable ? push_rt_task() is not checking and so a high prio RT task preemting a low prio RT task in a migrate_disable() section would actually push it off this cpu ? atleast I did not find why that would not happen.

Quoted 7 lines

Hi, Nicholas!

p is not rq->curr, so its p->migrate_disable state is already updated and it can't be pushed (nr_cpus_allowed == 1 and it's not pushable).

(If I understand right, that you worry about this).

Correct. If p has migrate_disabled set and scheduled out, then when it gets scheduled out, its cpu affinity gets set to only the current cpu and nr_cpu_allowed to 1. No need to check here if p->migrate_disabled is set.

-- Steve

#6 lore raw
In reply to Steven Rostedt
sched/rt: Do not try to push tasks if pinned task switches to RT
Commit-ID:  10447917551e0fffb8d1892d46e633c3e0a9c1ec
Gitweb:     http://git.kernel.org/tip/10447917551e0fffb8d1892d46e633c3e0a9c1ec
Author:     Kirill V Tkhai <[email protected]>
AuthorDate: Wed, 12 Mar 2014 06:18:33 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 18 Apr 2014 12:07:23 +0200

sched/rt: Do not try to push tasks if pinned task switches to RT

Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled).

---
 kernel/sched/rt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/rt.c +2 -2
index bd2267a..1e4992e 100644
@@ -1892,9 +1892,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
 	 */
 	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->rt.overloaded && push_rt_task(rq) &&
+		if (p->nr_cpus_allowed > 1 && rq->rt.overloaded &&
 		    /* Don't resched if we changed runqueues */
-		    rq != task_rq(p))
+		    push_rt_task(rq) && rq != task_rq(p))
 			check_resched = 0;
 #endif /* CONFIG_SMP */
 		if (check_resched && p->prio < rq->curr->prio)