From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753652AbbBARxb (ORCPT ); Sun, 1 Feb 2015 12:53:31 -0500 Received: from terminus.zytor.com ([198.137.202.10]:58535 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753489AbbBARxS (ORCPT ); Sun, 1 Feb 2015 12:53:18 -0500 Date: Sun, 1 Feb 2015 09:52:24 -0800 From: tip-bot for Tim Chen Message-ID: Cc: suruchi.a.kadu@intel.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, sbohrer@rgmadvisors.com, peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de, doug.nelson@intel.com, torvalds@linux-foundation.org, tim.c.chen@linux.intel.com, hpa@zytor.com Reply-To: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, torvalds@linux-foundation.org, tim.c.chen@linux.intel.com, doug.nelson@intel.com, linux-kernel@vger.kernel.org, suruchi.a.kadu@intel.com, sbohrer@rgmadvisors.com, peterz@infradead.org, rostedt@goodmis.org In-Reply-To: <1421430374.2399.27.camel@schen9-desk2.jf.intel.com> References: <1421430374.2399.27.camel@schen9-desk2.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/rt: Reduce rq lock contention by eliminating locking of non-feasible target Git-Commit-ID: 80e3d87b2c5582db0ab5e39610ce3707d97ba409 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 80e3d87b2c5582db0ab5e39610ce3707d97ba409 Gitweb: http://git.kernel.org/tip/80e3d87b2c5582db0ab5e39610ce3707d97ba409 Author: Tim Chen AuthorDate: Fri, 12 Dec 2014 15:38:12 -0800 Committer: Ingo Molnar CommitDate: Fri, 30 Jan 2015 19:38:49 +0100 sched/rt: Reduce rq lock contention by eliminating locking of non-feasible target This patch adds checks that prevens futile attempts to move rt tasks to a CPU with active tasks of equal or higher priority. This reduces run queue lock contention and improves the performance of a well known OLTP benchmark by 0.7%. Signed-off-by: Tim Chen Signed-off-by: Peter Zijlstra (Intel) Cc: Shawn Bohrer Cc: Suruchi Kadu Cc: Doug Nelson Cc: Steven Rostedt Cc: Linus Torvalds Link: http://lkml.kernel.org/r/1421430374.2399.27.camel@schen9-desk2.jf.intel.com Signed-off-by: Ingo Molnar --- kernel/sched/rt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 6725e3c..f4d4b07 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1340,7 +1340,12 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) curr->prio <= p->prio)) { int target = find_lowest_rq(p); - if (target != -1) + /* + * Don't bother moving it if the destination CPU is + * not running a lower priority task. + */ + if (target != -1 && + p->prio < cpu_rq(target)->rt.highest_prio.curr) cpu = target; } rcu_read_unlock(); @@ -1617,6 +1622,16 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) lowest_rq = cpu_rq(cpu); + if (lowest_rq->rt.highest_prio.curr <= task->prio) { + /* + * Target rq has tasks of equal or higher priority, + * retrying does not release any lock and is unlikely + * to yield a different result. + */ + lowest_rq = NULL; + break; + } + /* if the prio of this runqueue changed, try again */ if (double_lock_balance(rq, lowest_rq)) { /*