From patchwork Sun Feb 8 15:51:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 44502 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 46D6821521 for ; Sun, 8 Feb 2015 15:51:53 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf15812750wev.3 for ; Sun, 08 Feb 2015 07:51:52 -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=nZrBNrVQbWX62hNPwRRnOUY2hDC/qN2H378BaFJtsAA=; b=DE2uo7Tvg6ZrgJgNmiPlal9yymxWBrETn84fMNKkQjbdzdXqjVAnr/A9IsVSfQCAHM khZ1XfbiyyZuMM+HRbhs2oXJqz+QiZQavyKfKqdNIMujT7/JXke9c1TXDUVByNeGXJVG lib3LQMnNF7J42UbfXROeTmF4zVByxt2PyZyE5FaDxK4dXZp0Db2kMIYRUOxwmD94n2L wbCs2+it+9SpQ4ujWaIrB+5K+MAEkDPGe5af0Bnxb8PqiMhjdKDW+f0fMvoM/oh9Hqfi UHGYl9tP3yhdwJOGwaI0A6ivpefouNazueh7c6Y09ZZj5CvFxDWknmsfS6APF/vVrJDo LGyg== X-Gm-Message-State: ALoCoQlG0EtieTxq+8WL42JUyVpaQdD+yU/ofnexku3ashcCUTL+k+X5O7+ykzNMESKfUNJJqtc7 X-Received: by 10.112.46.106 with SMTP id u10mr923044lbm.3.1423410712163; Sun, 08 Feb 2015 07:51:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.72 with SMTP id h8ls415212laa.46.gmail; Sun, 08 Feb 2015 07:51:52 -0800 (PST) X-Received: by 10.152.37.166 with SMTP id z6mr4595887laj.98.1423410711987; Sun, 08 Feb 2015 07:51:51 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id l3si2371981laf.125.2015.02.08.07.51.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 07:51:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labgf13 with SMTP id gf13so9169415lab.3 for ; Sun, 08 Feb 2015 07:51:51 -0800 (PST) X-Received: by 10.112.213.38 with SMTP id np6mr12321925lbc.36.1423410711182; Sun, 08 Feb 2015 07:51:51 -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 h5csp2899658lbj; Sun, 8 Feb 2015 07:51:50 -0800 (PST) X-Received: by 10.66.194.129 with SMTP id hw1mr21707100pac.143.1423410708853; Sun, 08 Feb 2015 07:51:48 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si18548801pdc.112.2015.02.08.07.51.48; Sun, 08 Feb 2015 07:51:48 -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 S1756939AbbBHPvq (ORCPT + 29 others); Sun, 8 Feb 2015 10:51:46 -0500 Received: from mail-pd0-f176.google.com ([209.85.192.176]:39757 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbbBHPvo (ORCPT ); Sun, 8 Feb 2015 10:51:44 -0500 Received: by pdjy10 with SMTP id y10so3058427pdj.6 for ; Sun, 08 Feb 2015 07:51:43 -0800 (PST) X-Received: by 10.66.102.2 with SMTP id fk2mr21254998pab.149.1423410703585; Sun, 08 Feb 2015 07:51:43 -0800 (PST) Received: from vptest-PC.zte.com.cn ([101.78.161.162]) by mx.google.com with ESMTPSA id y4sm13747390pdj.59.2015.02.08.07.51.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 07:51:43 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang Subject: [PATCH v3 2/2] sched/rt: Add check_preempt_equal_prio() logic in pick_next_task_rt() Date: Sun, 8 Feb 2015 23:51:26 +0800 Message-Id: <1423410686-1928-2-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1423410686-1928-1-git-send-email-pang.xunlei@linaro.org> References: <1423410686-1928-1-git-send-email-pang.xunlei@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , 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 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 */