From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755373AbbFSSCd (ORCPT ); Fri, 19 Jun 2015 14:02:33 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49300 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753838AbbFSSCZ (ORCPT ); Fri, 19 Jun 2015 14:02:25 -0400 Date: Fri, 19 Jun 2015 11:01:34 -0700 From: tip-bot for Wanpeng Li Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, juri.lelli@arm.com, hpa@zytor.com, akpm@linux-foundation.org, wanpeng.li@linux.intel.com, bp@alien8.de Reply-To: bp@alien8.de, wanpeng.li@linux.intel.com, akpm@linux-foundation.org, juri.lelli@arm.com, hpa@zytor.com, torvalds@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <1431496867-4194-1-git-send-email-wanpeng.li@linux.intel.com> References: <1431496867-4194-1-git-send-email-wanpeng.li@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/deadline: Optimize pull_dl_task() Git-Commit-ID: 8b5e770ed7c05a65ffd2d33a83c14572696236dc 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: 8b5e770ed7c05a65ffd2d33a83c14572696236dc Gitweb: http://git.kernel.org/tip/8b5e770ed7c05a65ffd2d33a83c14572696236dc Author: Wanpeng Li AuthorDate: Wed, 13 May 2015 14:01:01 +0800 Committer: Ingo Molnar CommitDate: Fri, 19 Jun 2015 10:06:45 +0200 sched/deadline: Optimize pull_dl_task() pull_dl_task() uses pick_next_earliest_dl_task() to select a migration candidate; this is sub-optimal since the next earliest task -- as per the regular runqueue -- might not be migratable at all. This could result in iterating the entire runqueue looking for a task. Instead iterate the pushable queue -- this queue only contains tasks that have at least 2 cpus set in their cpus_allowed mask. Signed-off-by: Wanpeng Li [ Improved the changelog. ] Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Juri Lelli Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1431496867-4194-1-git-send-email-wanpeng.li@linux.intel.com Signed-off-by: Ingo Molnar --- kernel/sched/deadline.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 890ce95..9cbe1c7 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1230,6 +1230,32 @@ next_node: return NULL; } +/* + * Return the earliest pushable rq's task, which is suitable to be executed + * on the CPU, NULL otherwise: + */ +static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu) +{ + struct rb_node *next_node = rq->dl.pushable_dl_tasks_leftmost; + struct task_struct *p = NULL; + + if (!has_pushable_dl_tasks(rq)) + return NULL; + +next_node: + if (next_node) { + p = rb_entry(next_node, struct task_struct, pushable_dl_tasks); + + if (pick_dl_task(rq, p, cpu)) + return p; + + next_node = rb_next(next_node); + goto next_node; + } + + return NULL; +} + static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask_dl); static int find_later_rq(struct task_struct *task) @@ -1514,7 +1540,7 @@ static int pull_dl_task(struct rq *this_rq) if (src_rq->dl.dl_nr_running <= 1) goto skip; - p = pick_next_earliest_dl_task(src_rq, this_cpu); + p = pick_earliest_pushable_dl_task(src_rq, this_cpu); /* * We found a task to be pulled if: -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/