From patchwork Tue Nov 4 11:13:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 40127 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB240240A6 for ; Tue, 4 Nov 2014 11:15:54 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id w7sf2033261lbi.8 for ; Tue, 04 Nov 2014 03:15:53 -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=b+pg/r3ZBTLjcjmk7gLAGH23vt7CqAKoysQ5qENlV8w=; b=HHHUzh9SHJdHzaChk0an/2inmJerIeAVKhkPn+RWQ9kTjgvs0bLXpLP9JV/d4eFCFi FWn6S4R51HgDXL34/5jtlg9uffTS75qnhBCnT9E+l3RNEKZf4MdRFToVeBt3RiY7Hagx L1DMuhgz8hpHcm9bMDynf+3L9wv4Wx/+spEe2yzkf05ZSOh5rKLTJek9nd2RdiiPiBEB PpAai4U9l42/tgO3iGiAvyPaWjxSoq3DqUvYZp2WaRUw+9nMCXXy2xjxzutlJ3Rdd+qd NxjdGmgdPeKnby2kdbvWZifl+saXljRTiw00+77jg0Z0CHwRhNyD2uV1fzs9o3PEddIF 0EcQ== X-Gm-Message-State: ALoCoQn3hYv9CBH9YBAQ7Y88RNw3qOEwCcAeisD4l6D90JsyJ44nC+5Xr/nS8PUrNwRf26D0w68n X-Received: by 10.180.73.73 with SMTP id j9mr4049250wiv.3.1415099753804; Tue, 04 Nov 2014 03:15:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls752479lae.38.gmail; Tue, 04 Nov 2014 03:15:53 -0800 (PST) X-Received: by 10.112.150.68 with SMTP id ug4mr58437544lbb.82.1415099753354; Tue, 04 Nov 2014 03:15:53 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id b6si9826lae.131.2014.11.04.03.15.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Nov 2014 03:15:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so4233277lbv.38 for ; Tue, 04 Nov 2014 03:15:53 -0800 (PST) X-Received: by 10.112.77.74 with SMTP id q10mr57894709lbw.66.1415099753193; Tue, 04 Nov 2014 03:15:53 -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.184.201 with SMTP id ew9csp98510lbc; Tue, 4 Nov 2014 03:15:52 -0800 (PST) X-Received: by 10.68.106.194 with SMTP id gw2mr837201pbb.109.1415099751581; Tue, 04 Nov 2014 03:15:51 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dt17si17699478pdb.181.2014.11.04.03.15.50 for ; Tue, 04 Nov 2014 03:15:51 -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 S1752557AbaKDLPe (ORCPT + 25 others); Tue, 4 Nov 2014 06:15:34 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:39271 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750706AbaKDLPb (ORCPT ); Tue, 4 Nov 2014 06:15:31 -0500 Received: by mail-pd0-f178.google.com with SMTP id fp1so13596580pdb.9 for ; Tue, 04 Nov 2014 03:15:29 -0800 (PST) X-Received: by 10.70.60.138 with SMTP id h10mr7240888pdr.154.1415099729648; Tue, 04 Nov 2014 03:15:29 -0800 (PST) Received: from wangdeqiang.com ([210.21.223.3]) by mx.google.com with ESMTPSA id ol3sm158568pbb.17.2014.11.04.03.15.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Nov 2014 03:15:29 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v2 2/6] sched/rt: Optimize select_task_rq_rt() for non-RT curr task Date: Tue, 4 Nov 2014 19:13:01 +0800 Message-Id: <1415099585-31174-2-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415099585-31174-1-git-send-email-pang.xunlei@linaro.org> References: <1415099585-31174-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.217.179 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: , When selecting the cpu for a waking RT task, if curr is a non-RT task which is bound only on this cpu, then we can give it a chance to select a different cpu(definitely an idle cpu if existing) for the RT task to avoid curr starving. Signed-off-by: pang.xunlei --- kernel/sched/rt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index da6922e..dc1f7f0 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1340,6 +1340,11 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) * runqueue. Otherwise simply start this RT task * on its current runqueue. * + * If the current task on @p's runqueue is a non-RT task, + * and this task is bound on current runqueue, then try to + * see if we can wake this RT task up on a different runqueue, + * we will definitely find an idle cpu if there is any. + * * We want to avoid overloading runqueues. If the woken * task is a higher priority, then it will stay on this CPU * and the lower prio task should be moved to another CPU. @@ -1356,9 +1361,8 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) * This test is optimistic, if we get it wrong the load-balancer * will have to sort it out. */ - if (curr && unlikely(rt_task(curr)) && - (curr->nr_cpus_allowed < 2 || - curr->prio <= p->prio)) { + if (curr && unlikely(curr->nr_cpus_allowed < 2 || + curr->prio <= p->prio)) { int target = find_lowest_rq(p); if (target != -1)