public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Luca Abeni <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bristot@redhat.com, peterz@infradead.org,
	mathieu.poirier@linaro.org, linux-kernel@vger.kernel.org,
	hpa@zytor.com, efault@gmx.de, mingo@kernel.org,
	juri.lelli@arm.com, rostedt@goodmis.org, tglx@linutronix.de,
	luca.abeni@santannapisa.it, torvalds@linux-foundation.org
Subject: [tip:sched/core] sched/deadline: Fix switching to -deadline
Date: Tue, 10 Oct 2017 03:56:12 -0700	[thread overview]
Message-ID: <tip-295d6d5e373607729bcc8182c25afe964655714f@git.kernel.org> (raw)
In-Reply-To: <1504778971-13573-3-git-send-email-luca.abeni@santannapisa.it>

Commit-ID:  295d6d5e373607729bcc8182c25afe964655714f
Gitweb:     https://git.kernel.org/tip/295d6d5e373607729bcc8182c25afe964655714f
Author:     Luca Abeni <luca.abeni@santannapisa.it>
AuthorDate: Thu, 7 Sep 2017 12:09:29 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 10 Oct 2017 11:43:30 +0200

sched/deadline: Fix switching to -deadline

Fix a bug introduced in:

  72f9f3fdc928 ("sched/deadline: Remove dl_new from struct sched_dl_entity")

After that commit, when switching to -deadline if the scheduling
deadline of a task is in the past then switched_to_dl() calls
setup_new_entity() to properly initialize the scheduling deadline
and runtime.

The problem is that the task is enqueued _before_ having its parameters
initialized by setup_new_entity(), and this can cause problems.
For example, a task with its out-of-date deadline in the past will
potentially be enqueued as the highest priority one; however, its
adjusted deadline may not be the earliest one.

This patch fixes the problem by initializing the task's parameters before
enqueuing it.

Signed-off-by: luca abeni <luca.abeni@santannapisa.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Juri Lelli <juri.lelli@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1504778971-13573-3-git-send-email-luca.abeni@santannapisa.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/deadline.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 0191ec7..9d45354 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1364,6 +1364,10 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
 		update_dl_entity(dl_se, pi_se);
 	} else if (flags & ENQUEUE_REPLENISH) {
 		replenish_dl_entity(dl_se, pi_se);
+	} else if ((flags & ENQUEUE_RESTORE) &&
+		  dl_time_before(dl_se->deadline,
+				 rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) {
+		setup_new_dl_entity(dl_se);
 	}
 
 	__enqueue_dl_entity(dl_se);
@@ -2255,13 +2259,6 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 
 		return;
 	}
-	/*
-	 * If p is boosted we already updated its params in
-	 * rt_mutex_setprio()->enqueue_task(..., ENQUEUE_REPLENISH),
-	 * p's deadline being now already after rq_clock(rq).
-	 */
-	if (dl_time_before(p->dl.deadline, rq_clock(rq)))
-		setup_new_dl_entity(&p->dl);
 
 	if (rq->curr != p) {
 #ifdef CONFIG_SMP

  reply	other threads:[~2017-10-10 11:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 10:09 [PATCH 0/4] SCHED_DEADLINE fixes and cleanups luca abeni
2017-09-07 10:09 ` [PATCH 1/4] sched/sched.h: remove duplicate prototype of __dl_clear_params() luca abeni
2017-09-08  8:33   ` Daniel Bristot de Oliveira
2017-10-10 10:55   ` [tip:sched/core] sched/headers: Remove " tip-bot for luca abeni
2017-09-07 10:09 ` [PATCH 2/4] sched/deadline: fix switching to -deadline luca abeni
2017-10-10 10:56   ` tip-bot for Luca Abeni [this message]
2017-09-07 10:09 ` [PATCH 3/4] sched/deadline: rename __dl_clear() to __dl_sub() luca abeni
2017-09-08  8:26   ` Daniel Bristot de Oliveira
2017-10-10 10:56   ` [tip:sched/core] sched/deadline: Rename " tip-bot for Peter Zijlstra
2017-09-07 10:09 ` [PATCH 4/4] sched/deadline: use C bitfields for the state flags luca abeni
2017-09-08  8:24   ` Daniel Bristot de Oliveira
2017-10-10 10:57   ` [tip:sched/core] sched/deadline: Use " tip-bot for luca abeni
2017-10-02  8:18 ` [PATCH 0/4] SCHED_DEADLINE fixes and cleanups Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-295d6d5e373607729bcc8182c25afe964655714f@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bristot@redhat.com \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=juri.lelli@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luca.abeni@santannapisa.it \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox