Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933278AbdCWKdZ (ORCPT ); Thu, 23 Mar 2017 06:33:25 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:50640 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932855AbdCWKdW (ORCPT ); Thu, 23 Mar 2017 06:33:22 -0400 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.23 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: , CC: , , , Subject: [PATCH 4/8] sched/deadline: Factor out the selecting of suitable max cpu Date: Thu, 23 Mar 2017 19:32:39 +0900 Message-ID: <1490265163-29981-5-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> References: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:19, Serialize by Router on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:19, Serialize complete at 2017/03/23 19:33:19 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1858 Lines: 57 Currently, dl scheduler selects a cpu having the maximum dl on pushing. On success, it would be a fast path, but it might fail because of the task's affinity or dl value, so we need a slow path in case of failure. As a first step in adding a slow path, factor out the selecting into helper function, cpudl_fast_find(). Signed-off-by: Byungchul Park --- kernel/sched/cpudeadline.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index f1a6ce4..f03479c 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -115,6 +115,19 @@ static inline u64 cpudl_maximum_dl(struct cpudl *cp) return cp->elements[0].dl; } +static int cpudl_fast_find(struct cpudl *cp, struct task_struct *p) +{ + const struct sched_dl_entity *dl_se = &p->dl; + int max_cpu = cpudl_maximum_cpu(cp); + u64 max_dl = cpudl_maximum_dl(cp); + + if (cpumask_test_cpu(max_cpu, &p->cpus_allowed) && + dl_time_before(dl_se->deadline, max_dl)) + return max_cpu; + + return -1; +} + /* * cpudl_find - find the best (later-dl) CPU in the system * @cp: the cpudl max-heap context @@ -127,16 +140,14 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, struct cpumask *later_mask) { int best_cpu = -1; - const struct sched_dl_entity *dl_se = &p->dl; if (later_mask && cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { best_cpu = cpumask_any(later_mask); goto out; - } else if (cpumask_test_cpu(cpudl_maximum_cpu(cp), &p->cpus_allowed) && - dl_time_before(dl_se->deadline, cpudl_maximum_dl(cp))) { - best_cpu = cpudl_maximum_cpu(cp); - if (later_mask) + } else { + best_cpu = cpudl_fast_find(cp, p); + if (best_cpu != -1 && later_mask) cpumask_set_cpu(best_cpu, later_mask); } -- 1.9.1