LKML Archive on lore.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>,
	Xunlei Pang <pang.xunlei@linaro.org>
Subject: [PATCH RESEND 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt()
Date: Wed,  4 Feb 2015 09:12:21 +0800	[thread overview]
Message-ID: <1423012341-30265-2-git-send-email-xlpang@126.com> (raw)
In-Reply-To: <1423012341-30265-1-git-send-email-xlpang@126.com>

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

check_preempt_curr() doesn't call sched_class::check_preempt_curr
when the class of current is a higher level. So if there is a DL
task running when doing this for RT, check_preempt_equal_prio()
will definitely miss, which may result in some response latency
for this RT task if it is pinned and there're some same-priority
migratable rt tasks already queued.

We should do the similar thing in select_task_rq_rt() when first
picking rt tasks after running out of DL tasks.

This patch tackles the issue by peeking the next rt task(RT1), and
if find RT1 migratable, just requeue it to the tail of the rq using
requeue_task_rt(rq, p, 0). In this way:
- If there do have another rt task(RT2) with the same priority as
  RT1, RT2 will finally be picked as the running task. While RT1
  will be pushed onto another cpu via RT1's post_schedule(), as
  RT1 is migratable. The difference from check_preempt_equal_prio()
  here is that we just don't care whether RT2 is migratable.

- Otherwise, if there's no rt task with the same priority as RT1,
  RT1 will still be picked as the running task after the requeuing.

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

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 4dacb6e..b2385ee 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1477,6 +1477,21 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev)
 
 	put_prev_task(rq, prev);
 
+#ifdef CONFIG_SMP
+		/*
+		 * If there's a running deadline task, check_preempt_curr()
+		 * doesn't invoke check_preempt_curr_rt() for rt tasks, so
+		 * we can do it here.
+		 */
+		if (prev->sched_class == &dl_sched_class &&
+		    rq->rt.rt_nr_total > 1) {
+			p = _pick_next_task_rt(rq, 1); /* peek only */
+			if (p->nr_cpus_allowed != 1 &&
+			    cpupri_find(&rq->rd->cpupri, p, NULL))
+				requeue_task_rt(rq, p, 0);
+		}
+#endif
+
 	p = _pick_next_task_rt(rq, 0);
 
 	/* The running task is never eligible for pushing */
-- 
1.9.1



  reply	other threads:[~2015-02-04  1:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04  1:12 [PATCH RESEND 1/2] sched/rt: Check to push the task when changing its affinity Xunlei Pang
2015-02-04  1:12 ` Xunlei Pang [this message]
2015-02-04  3:17   ` [PATCH RESEND 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt() Steven Rostedt
2015-02-04 13:05     ` Xunlei Pang
2015-02-04  3:14 ` [PATCH RESEND 1/2] sched/rt: Check to push the task when changing its affinity Steven Rostedt
2015-02-04 12:59   ` Xunlei Pang

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=1423012341-30265-2-git-send-email-xlpang@126.com \
    --to=xlpang@126.com \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pang.xunlei@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --subject='Re: [PATCH RESEND 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).