From patchwork Mon Nov 3 10:30:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 40012 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 725A621894 for ; Mon, 3 Nov 2014 10:31:59 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf2652367eek.1 for ; Mon, 03 Nov 2014 02:31:58 -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=PJSIBlCYw4tZLM7LYoIzGr5m28udS9rLHIcmkFVqTlo=; b=ahzJ1yjqx13rH+CDAjd/KmNgUtWQXu65YxRkbm49YpE+ZQ9EGtuw2Kb4H8rhgt2Sv1 9HwbUxsAU1odMiTCcKEh8H6KMUD5WDyqmybPJhxK/+Zfdrw5zaZ6z562Ba8iAtKrho08 xVHtwO3YSuUlPTHLX0GPMsXuxatMVxq9VHPDj0C64HDebD/v1zaHmTO+OLsKybRHyJzk 4thVsBiqqh7P7fy8L2nqp9CLo20dwUsZeuRetmA/wZxdgxIEdihyKvUT8h4Vn3UQhiW9 oMc0MGK1CrgR2X6cHJPaAsyjYyQ0sndCTAWnj920Cz+C0jLBTw/UlEaNTH8J0DWDj+b8 kf1g== X-Gm-Message-State: ALoCoQl2IMSP2HdYBy5aQKwRxcWOx2Ig4ucE6wZEOvHfl3BYiyuBA1o3YHOeg3lEXT5g6HoV8g70 X-Received: by 10.112.97.35 with SMTP id dx3mr176769lbb.20.1415010718723; Mon, 03 Nov 2014 02:31:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.227 with SMTP id v3ls760843lav.91.gmail; Mon, 03 Nov 2014 02:31:58 -0800 (PST) X-Received: by 10.152.22.194 with SMTP id g2mr49763484laf.33.1415010718542; Mon, 03 Nov 2014 02:31:58 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ke10si31899503lbc.41.2014.11.03.02.31.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 02:31:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gq15so9384291lab.35 for ; Mon, 03 Nov 2014 02:31:58 -0800 (PST) X-Received: by 10.112.218.101 with SMTP id pf5mr13531697lbc.46.1415010718454; Mon, 03 Nov 2014 02:31:58 -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.84.229 with SMTP id c5csp214130lbz; Mon, 3 Nov 2014 02:31:57 -0800 (PST) X-Received: by 10.68.132.199 with SMTP id ow7mr90319pbb.164.1415010716489; Mon, 03 Nov 2014 02:31:56 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yv8si15050690pac.79.2014.11.03.02.31.55 for ; Mon, 03 Nov 2014 02:31:56 -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 S1751535AbaKCKbb (ORCPT + 25 others); Mon, 3 Nov 2014 05:31:31 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:47568 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbaKCKbW (ORCPT ); Mon, 3 Nov 2014 05:31:22 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so11875732pab.18 for ; Mon, 03 Nov 2014 02:31:22 -0800 (PST) X-Received: by 10.66.252.34 with SMTP id zp2mr42926299pac.64.1415010681954; Mon, 03 Nov 2014 02:31:21 -0800 (PST) Received: from wangdeqiang.com ([210.21.223.3]) by mx.google.com with ESMTPSA id no8sm16803468pdb.63.2014.11.03.02.31.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 02:31:21 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , "pang.xunlei" Subject: [PATCH 3/3] sched/rt: Optimize select_task_rq_rt() for non-RT curr task Date: Mon, 3 Nov 2014 18:30:20 +0800 Message-Id: <1415010620-6176-3-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415010620-6176-1-git-send-email-pang.xunlei@linaro.org> References: <1415010620-6176-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.48 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 d024e6c..89202ab 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1319,6 +1319,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. @@ -1335,9 +1340,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)