From patchwork Thu Nov 20 17:28:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 41253 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 96106241C9 for ; Thu, 20 Nov 2014 17:28:55 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf2094284lam.2 for ; Thu, 20 Nov 2014 09:28:54 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=/cSlLOQhOLV6jAK3UchWskwxjuINS19I5hETto3J7HU=; b=ICr8Oxddzyzm6H+3qEWXscDU0fdgDEmfRQMrKrqivmTlHlmXiEJTaoEZP9f/RXHEld spaxFiPALcpCviTgZOFVmd9oUDmT7g+2Tbt7aqAwgiEvCZKL26ctBMR42W48XDZN1yso oWVm1y3DL56tt5jhQmvuq0QpYbkEVW05Au3hv21g3HBKxv9hP0k5DKkXz7fsfhGf0L/m 30KtJSSW2VEMS8BCn+LyBvq7SPXUfJdBtpj5DwBP5xex4C+BektjtXC58klVWEAgmVDa 9eOb46Y2aRQLXq5gjD6ock8K6KDDGTSgHBwoPbIUBpTol/1u/0jc+KQoqVePGgr8fR0X /RMw== X-Gm-Message-State: ALoCoQnnZt5TetutiPGNcSjpkopjkeJk+P8zHMvfLJHZf0i7KdNORYl9tVmumFC9S+AgQUJn6s7y X-Received: by 10.112.151.38 with SMTP id un6mr2755631lbb.0.1416504534543; Thu, 20 Nov 2014 09:28:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.1 with SMTP id bc1ls98835lab.24.gmail; Thu, 20 Nov 2014 09:28:54 -0800 (PST) X-Received: by 10.112.147.225 with SMTP id tn1mr12516110lbb.37.1416504534256; Thu, 20 Nov 2014 09:28:54 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id c6si2720090laa.50.2014.11.20.09.28.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gf13so2844179lab.27 for ; Thu, 20 Nov 2014 09:28:54 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr12298729lbo.32.1416504534076; Thu, 20 Nov 2014 09:28:54 -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 ew9csp303268lbc; Thu, 20 Nov 2014 09:28:53 -0800 (PST) X-Received: by 10.66.65.168 with SMTP id y8mr58864340pas.48.1416504532098; Thu, 20 Nov 2014 09:28:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ip5si3839671pbc.246.2014.11.20.09.28.51 for ; Thu, 20 Nov 2014 09:28:52 -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 S1757608AbaKTR2t (ORCPT + 26 others); Thu, 20 Nov 2014 12:28:49 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:39090 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756396AbaKTR2s (ORCPT ); Thu, 20 Nov 2014 12:28:48 -0500 Received: by mail-pa0-f41.google.com with SMTP id rd3so2956142pab.14 for ; Thu, 20 Nov 2014 09:28:47 -0800 (PST) X-Received: by 10.68.132.225 with SMTP id ox1mr57696031pbb.85.1416504527587; Thu, 20 Nov 2014 09:28:47 -0800 (PST) Received: from vptest-PC.zte.com.cn ([167.160.116.65]) by mx.google.com with ESMTPSA id tv4sm2604342pab.28.2014.11.20.09.28.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Nov 2014 09:28:46 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v3 1/3] sched/deadline: Modify cpudl.free_cpus to reflect rd->span Date: Fri, 21 Nov 2014 01:28:03 +0800 Message-Id: <1416504485-8180-1-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.0.4 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.54 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: , Currently, cpudl.free_cpus contains all cpus during init(see cpudl_init()), so when calling cpudl_find() we have to add rd->span cpumask(cpus_allowed is undependable when performing clustered scheduling using the cpuset) to avoid selecting the cpu outside current root domain, see find_later_rq(). This patch adds cpudl_set_freecpu() to initialize cpudl.free_cpus when doing rq_attach_root(), so we can avoid the extra rd->span operation when calling cpudl_find(). Signed-off-by: pang.xunlei --- kernel/sched/core.c | 2 ++ kernel/sched/cpudeadline.c | 18 ++++++++++++++---- kernel/sched/cpudeadline.h | 1 + kernel/sched/deadline.c | 3 --- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 240157c..1b417de 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5584,6 +5584,8 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd) rq->rd = rd; cpumask_set_cpu(rq->cpu, rd->span); + cpudl_set_freecpu(&rd->cpudl, rq->cpu); + if (cpumask_test_cpu(rq->cpu, cpu_active_mask)) set_rq_online(rq); diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 539ca3c..c79f0d7 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -107,7 +107,9 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, int best_cpu = -1; const struct sched_dl_entity *dl_se = &p->dl; - if (later_mask && cpumask_and(later_mask, later_mask, cp->free_cpus)) { + if (later_mask && + cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed) && + cpumask_and(later_mask, later_mask, cpu_active_mask)) { best_cpu = cpumask_any(later_mask); goto out; } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && @@ -186,6 +188,16 @@ out: } /* + * cpudl_set_freecpu - Set the cpudl.free_cpus + * @cp: the cpudl max-heap context + * @cpu: rd attached cpu + */ +void cpudl_set_freecpu(struct cpudl *cp, int cpu) +{ + cpumask_set_cpu(cpu, cp->free_cpus); +} + +/* * cpudl_init - initialize the cpudl structure * @cp: the cpudl max-heap context */ @@ -203,7 +215,7 @@ int cpudl_init(struct cpudl *cp) if (!cp->elements) return -ENOMEM; - if (!alloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { + if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { kfree(cp->elements); return -ENOMEM; } @@ -211,8 +223,6 @@ int cpudl_init(struct cpudl *cp) for_each_possible_cpu(i) cp->elements[i].idx = IDX_INVALID; - cpumask_setall(cp->free_cpus); - return 0; } diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h index 020039b..4a10a65 100755 --- a/kernel/sched/cpudeadline.h +++ b/kernel/sched/cpudeadline.h @@ -24,6 +24,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, struct cpumask *later_mask); void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid); int cpudl_init(struct cpudl *cp); +void cpudl_set_freecpu(struct cpudl *cp, int cpu); void cpudl_cleanup(struct cpudl *cp); #endif /* CONFIG_SMP */ diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 5285332..bd83272 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1187,9 +1187,6 @@ static int find_later_rq(struct task_struct *task) * We have to consider system topology and task affinity * first, then we can look for a suitable cpu. */ - cpumask_copy(later_mask, task_rq(task)->rd->span); - cpumask_and(later_mask, later_mask, cpu_active_mask); - cpumask_and(later_mask, later_mask, &task->cpus_allowed); best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, task, later_mask); if (best_cpu == -1)