Skip to contentSkip to conversation

sched/deadline: switched_to_dl() -- skip if task is current

PATCH In review Kirill Tkhai 3 participants 3 messages Jan 28, 2014 – Feb 10, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched/deadline: switched_to_dl() -- skip if task is current

v2: Changed comment

When p is current and it's not of dl class, then there are no other dl taks in the rq. If we had had pushable tasks in some other rq, they would have been pushed earlier. So, skip "p == rq->curr" case.

[This is confirmed by Juri Lelli and LKML was CC'ed, but
unfotunately I can't find direct link on lkml.org]

CC Juri Lelli <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/deadline.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
index 0de2482..dd19d6d 100644
@@ -1559,7 +1559,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 	if (unlikely(p->dl.dl_throttled))
 		return;
 
-	if (p->on_rq || rq->curr != p) {
+	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */
#1 lore raw
Quoted 4 lines · Kirill Tkhai

v2: Changed comment

When p is current and it's not of dl class, then there are no other dl taks in the rq. If we had had pushable tasks in some other rq,

^ tasks

Quoted 5 lines

they would have been pushed earlier. So, skip "p == rq->curr" case.

[This is confirmed by Juri Lelli and LKML was CC'ed, but
unfotunately I can't find direct link on lkml.org]

This was the story:

Quoted 58 lines · Juri Lelli
Quoted 21 lines · Kirill Tkhai
Quoted 5 lines

17.12.2013, 16:48, "Peter Zijlstra" <[email protected]>:
From: Dario Faggioli <[email protected]>

Introduces the data structures, constants and symbols needed for SCHED_DEADLINE implementation.

[snipped]

Quoted 12 lines
(quoted diff) +12 -0
+static void switched_to_dl(struct rq *rq, struct task_struct *p)
+{
+	/*
+	 * If p is throttled, don't consider the possibility
+	 * of preempting rq->curr, the check will be done right
+	 * after its runtime will get replenished.
+	 */
+	if (unlikely(p->dl.dl_throttled))
+		return;
+
+	if (!p->on_rq || rq->curr != p) {
+		if (task_has_dl_policy(rq->curr))
Quoted 9 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+			check_preempt_curr_dl(rq, p, 0);
+		else
+			resched_task(rq->curr);
+	}
+}

The second if() looks a little strange. Why is "!p->on_rq ||" here? RT class has another logic.

You are right, good catch! :)

This has to be changed in

  if (p->on_rq && rq->curr != p)

as in RT.

Thanks,

- Juri

CC Juri Lelli <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/sched/deadline.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +0 -0
index 0de2482..dd19d6d 100644

kernel/sched/deadline.c static void switched_to_dl(struct rq *rq, struct task_struct *p) · line 1565

Quoted 8 lines
kernel/sched/deadline.c +1 -1
@@ -1559,7 +1559,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 	if (unlikely(p->dl.dl_throttled))
 		return;
 
-	if (p->on_rq || rq->curr != p) {
+	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */

So the patch looks good. Not sure about the changelog, though :).

Thanks,

- Juri

#2 lore raw

[tip:sched/core] sched/deadline: Skip in switched_to_dl() if task is current

In reply to Kirill Tkhai
sched/deadline: Skip in switched_to_dl() if task is current
Commit-ID:  390f3258cb2d031f1c17aa32e771ebd336e89073
Gitweb:     http://git.kernel.org/tip/390f3258cb2d031f1c17aa32e771ebd336e89073
Author:     Kirill Tkhai <[email protected]>
AuthorDate: Tue, 28 Jan 2014 11:26:14 +0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 9 Feb 2014 13:31:48 +0100

sched/deadline: Skip in switched_to_dl() if task is current

When p is current and it's not of dl class, then there are no other dl taks in the rq. If we had had pushable tasks in some other rq, they would have been pushed earlier. So, skip "p == rq->curr" case.

---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
index 0dd5e09..b5700bc 100644
@@ -1560,7 +1560,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 	if (unlikely(p->dl.dl_throttled))
 		return;
 
-	if (p->on_rq || rq->curr != p) {
+	if (p->on_rq && rq->curr != p) {
 #ifdef CONFIG_SMP
 		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */