From patchwork Thu Feb 5 15:59:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 44466 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5579421521 for ; Thu, 5 Feb 2015 16:01:46 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf6079629wev.3 for ; Thu, 05 Feb 2015 08:01:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Jy79kzFkN4L1e0m8UIjsgK0BKGh8ywYjuihAdaDoYlY=; b=PUQyXPoNsON/r7FdBDVLAMRBdkFnXyL3m31IKi+HY/OsLudhvD9NPKAzCV0ck4LI7a V15aA7BE4Tgyj32jwiCwiqpV3rhPbN9SF347KBO7nZPi1bg/ApqUIAC3smpHZchzaj2o YXkYKGcaVS5GgJBWl2CnnBBvhmHyxH6773TEaRRO0kvU0xSEGzH1QUrYsJCIV/QP64tR kfYeR9T1kKO6XaMtd2I6+0g722haQvuzpKFRbOeP0LQWEwCP5VAc5l81n6Q5eFrzi0cj tpItZMeSGsxrwQVocOJRJUqBdmmqjiBELr9x3bodby+p7vttj3HMvc9OUv9BgmQIaI+d +cQQ== X-Gm-Message-State: ALoCoQkruaSMhu2o+LbRrfEZMsaQXYCC6rsA38R3H84xFW3+SnCMvV8Zrkj9dLxlvtR6weH0R26X X-Received: by 10.112.180.167 with SMTP id dp7mr608381lbc.14.1423152105598; Thu, 05 Feb 2015 08:01:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.2 with SMTP id ku2ls167832lac.64.gmail; Thu, 05 Feb 2015 08:01:45 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr4506335lav.34.1423152105406; Thu, 05 Feb 2015 08:01:45 -0800 (PST) Received: from mail-lb0-x233.google.com (mail-lb0-x233.google.com. [2a00:1450:4010:c04::233]) by mx.google.com with ESMTPS id an6si4248301lbc.129.2015.02.05.08.01.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 08:01:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::233 as permitted sender) client-ip=2a00:1450:4010:c04::233; Received: by mail-lb0-f179.google.com with SMTP id z11so7782150lbi.10 for ; Thu, 05 Feb 2015 08:01:45 -0800 (PST) X-Received: by 10.152.88.44 with SMTP id bd12mr4424726lab.86.1423152105307; Thu, 05 Feb 2015 08:01:45 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1232171lbj; Thu, 5 Feb 2015 08:01:44 -0800 (PST) X-Received: by 10.70.48.33 with SMTP id i1mr6434492pdn.153.1423152103074; Thu, 05 Feb 2015 08:01:43 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si6664836pdc.112.2015.02.05.08.01.41; Thu, 05 Feb 2015 08:01:42 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758092AbbBEQBY (ORCPT + 29 others); Thu, 5 Feb 2015 11:01:24 -0500 Received: from m50-111.126.com ([123.125.50.111]:52371 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757927AbbBEQBT (ORCPT ); Thu, 5 Feb 2015 11:01:19 -0500 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowAC33y9vk9NUGrIRAQ--.742S3; Thu, 05 Feb 2015 23:59:50 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang Subject: [PATCH v2 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt() Date: Thu, 5 Feb 2015 23:59:34 +0800 Message-Id: <1423151974-22557-2-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423151974-22557-1-git-send-email-xlpang@126.com> References: <1423151974-22557-1-git-send-email-xlpang@126.com> X-CM-TRANSID: jtKowAC33y9vk9NUGrIRAQ--.742S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw1DWrWfAFW7tFyDtF1UKFg_yoW8uF17pa nY934fua1DA3W2gw1Syr4fCr45Gw1fA3y5Jr97ta1jyw45Xa10qr13tF1ayFWjqr4kJaya qr4qy3y2kr1Du3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jT6wZUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbimRmXv00vMKG3MgAAse Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::233 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index b1ea9c0..17dcbfa 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 */