public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@odin.com>
To: <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
	Mohammed Naser <mnaser@vexxhost.com>,
	"Ingo Molnar" <mingo@kernel.org>, Kirill Tkhai <tkhai@yandex.ru>
Subject: [PATCH 2/2] sched: Update runtime of prev task before doing pick_next_task()
Date: Tue, 26 May 2015 14:50:08 +0300	[thread overview]
Message-ID: <1432641008.6866.59.camel@odin.com> (raw)
In-Reply-To: <20150526114344.14783.90095.stgit@pro>

pick_next_task() puts prev rq's task. This may lead to runtime
expiration and to dequeueing of all scheduling class's tasks
because of throttling. And the current logic is that put_prev_task()
must be called in the pick method of next task's class.

This was fixed for RT and DL classes, while fair class have this
problem. So, instead of doing partial solutions, let's update prev
task's runtime for all classes in __schedule() and fix the problem
completelly.

Also, let's freeze the clock during pick_next_task() to be sure
new expirations of runtime won't happen.

Reported-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Reported-by: Mohammed Naser <mnaser@vexxhost.com>
Signed-off-by: Kirill Tkhai <ktkhai@odin.com>
---
 kernel/sched/core.c     |    3 +++
 kernel/sched/deadline.c |    7 -------
 kernel/sched/rt.c       |    7 -------
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4eec607..0872280 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2806,7 +2806,10 @@ static void __sched __schedule(void)
 
 	if (task_on_rq_queued(prev))
 		update_rq_clock(rq);
+	prev->sched_class->update_curr(rq);
 
+	/* freeze clock to avoid new run time expirations in pick_next_task() */
+	rq_clock_skip_update(rq, true);
 	next = pick_next_task(rq, prev);
 	clear_tsk_need_resched(prev);
 	clear_preempt_need_resched();
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 7a08d59..570eadd 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1102,13 +1102,6 @@ struct task_struct *pick_next_task_dl(struct rq *rq, struct task_struct *prev)
 			return RETRY_TASK;
 	}
 
-	/*
-	 * When prev is DL, we may throttle it in put_prev_task().
-	 * So, we update time before we check for dl_nr_running.
-	 */
-	if (prev->sched_class == &dl_sched_class)
-		update_curr_dl(rq);
-
 	if (unlikely(!dl_rq->dl_nr_running))
 		return NULL;
 
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 7d7093c5..3437e7e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1480,13 +1480,6 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev)
 			return RETRY_TASK;
 	}
 
-	/*
-	 * We may dequeue prev's rt_rq in put_prev_task().
-	 * So, we update time before rt_nr_running check.
-	 */
-	if (prev->sched_class == &rt_sched_class)
-		update_curr_rt(rq);
-
 	if (!rt_rq->rt_queued)
 		return NULL;
 




       reply	other threads:[~2015-05-26 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150526114344.14783.90095.stgit@pro>
2015-05-26 11:50 ` Kirill Tkhai [this message]
2015-05-26 17:48   ` [PATCH 2/2] sched: Update runtime of prev task before doing pick_next_task() bsegall

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=1432641008.6866.59.camel@odin.com \
    --to=ktkhai@odin.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mnaser@vexxhost.com \
    --cc=peterz@infradead.org \
    --cc=tkhai@yandex.ru \
    /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