lkml.org 
[lkml]   [2015]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt()
Date
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 | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 04c58b7..26114f5 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1482,6 +1482,22 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev)

put_prev_task(rq, prev);

+#ifdef CONFIG_SMP
+ /*
+ * If there's a running higher class task, check_preempt_curr()
+ * doesn't invoke check_preempt_equal_prio() for rt tasks, so
+ * we can do the similar thing here.
+ */
+ if (rq->rt.rt_nr_total > 1 &&
+ (prev->sched_class == &dl_sched_class ||
+ prev->sched_class == &stop_sched_class)) {
+ p = peek_next_task_rt(rq);
+ 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);

/* The running task is never eligible for pushing */
--
1.9.1


\
 
 \ /
  Last update: 2015-02-08 17:01    [W:0.063 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site