From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934054AbbBDBOY (ORCPT ); Tue, 3 Feb 2015 20:14:24 -0500 Received: from m15-114.126.com ([220.181.15.114]:38657 "EHLO m15-114.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754605AbbBDBOV (ORCPT ); Tue, 3 Feb 2015 20:14:21 -0500 From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang 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 Message-Id: <1423012341-30265-2-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423012341-30265-1-git-send-email-xlpang@126.com> References: <1423012341-30265-1-git-send-email-xlpang@126.com> X-CM-TRANSID: DsmowADn8VwectFU_IBWAA--.619S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw1DWrWfAFW7tFyDtF1UKFg_yoW8ur1Upa 1Fk34fua1DA3W2q3WSyr4fAr45Gw1rA3yrJr97ta1jkw45Xa1jvr1ayF1ayrWjqr4kJa13 trsFy3y7Gr4Du3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jTq2NUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiXAaWv1R0UwKpzwAAsk Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xunlei Pang 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 --- 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