public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xunlei Pang <xlpang@126.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Juri Lelli <juri.lelli@gmail.com>, Ingo Molnar <mingo@redhat.com>,
	Xunlei Pang <pang.xunlei@linaro.org>
Subject: [PATCH v3 2/4] sched/deadline: Check to push the task away after its affinity was changed
Date: Tue, 12 May 2015 22:46:42 +0800	[thread overview]
Message-ID: <1431442004-18716-2-git-send-email-xlpang@126.com> (raw)
In-Reply-To: <1431442004-18716-1-git-send-email-xlpang@126.com>

From: Xunlei Pang <pang.xunlei@linaro.org>

(Sync up the same behaviour as that of RT.)

We may suffer from extra dl overload rq due to the affinity,
so when the affinity of any runnable dl task is changed, we
should check to trigger balancing, otherwise it will cause
some unnecessary delayed real-time response. Unfortunately,
current DL global scheduler does nothing about this.

This patch modified set_cpus_allowed_dl(), if the target task
is runnable but not running and not throttled, it tries to push
it away once it got migratable.

The patch also solves a problem about move_queued_task() called
in set_cpus_allowed_ptr():
When a smaller deadline value dl task got migrated due to its curr
cpu isn't in the new affinity mask, after move_queued_task() it
will miss the chance of pushing away, because check_preempt_curr()
called by move_queued_task() doens't set the "need resched flag"
for smaller deadline value tasks.

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 kernel/sched/deadline.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 3baffb2..968612b 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1615,11 +1615,12 @@ static bool set_cpus_allowed_dl(struct task_struct *p,
 	weight = cpumask_weight(new_mask);
 
 	/*
-	 * Only update if the process changes its state from whether it
-	 * can migrate or not.
+	 * Skip updating the migration stuff if the process doesn't change
+	 * its migrate state, but still need to check if it can be pushed
+	 * away due to its new affinity.
 	 */
 	if ((p->nr_cpus_allowed > 1) == (weight > 1))
-		return false;
+		goto check_push;
 
 	/*
 	 * The process used to be able to migrate OR it can now migrate
@@ -1637,6 +1638,18 @@ static bool set_cpus_allowed_dl(struct task_struct *p,
 
 	update_dl_migration(&rq->dl);
 
+check_push:
+	if (weight > 1 &&
+	    !task_running(rq, p) &&
+	    !test_tsk_need_resched(rq->curr) &&
+	    !cpumask_subset(new_mask, &p->cpus_allowed)) {
+		/* Update new affinity and try to push. */
+		cpumask_copy(&p->cpus_allowed, new_mask);
+		p->nr_cpus_allowed = weight;
+		push_dl_tasks(rq);
+		return true;
+	}
+
 	return false;
 }
 
-- 
1.9.1



  reply	other threads:[~2015-05-12 14:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:46 [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed Xunlei Pang
2015-05-12 14:46 ` Xunlei Pang [this message]
2015-05-12 14:46 ` [PATCH v3 3/4] sched/rt: Remove redundant conditions from task_woken_rt() Xunlei Pang
2015-05-12 14:46 ` [PATCH v3 4/4] sched/deadline: Remove redundant conditions from task_woken_dl() Xunlei Pang
2015-05-29 13:16 ` [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed Peter Zijlstra
     [not found]   ` <OF8BB81194.1A32A464-ON48257E54.004C068A-48257E54.004D51E2@zte.com.cn>
2015-05-30  8:20     ` Peter Zijlstra
2015-05-30 10:54       ` Peter Zijlstra
2015-05-30 16:30         ` Steven Rostedt

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=1431442004-18716-2-git-send-email-xlpang@126.com \
    --to=xlpang@126.com \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pang.xunlei@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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