From patchwork Wed Nov 19 15:46:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 41183 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EACD2241C9 for ; Wed, 19 Nov 2014 15:46:56 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf613558lab.0 for ; Wed, 19 Nov 2014 07:46:55 -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=LgapagUCJinH3cizOns9zfFebn/88TuPNQ8h0Y5WWgg=; b=bzwshJNWhgjZ4IRoJn1pk5UGANvK+PBTtKkUpD2Ady6NXCxpJSyg0n34hL2cKTUkOa uii5XCdhyvjjXQbcWf2bzXHPEAbeDh6+vU7sT5brl9LsogziGwH3RCufvTvVVvaZfcJI 2U8mZAbZRkG8XGdTPp/TIvo5GlnBoB2frUur92AjAznb4MnX7JkYS4LBPKVxY5mBDHEe BjoJVaP9fjzIceFPc14LvA3xaoVXe/CePSBvIMHjdPWhFo7iquZim/qOez3HPVy+CAnp UJwX1dGRn2114BGih3/N+U+0DZ35zWKC5FrxSqpavmapML6cbwQWJJI+wAy6zAMbmNTb EUZw== X-Gm-Message-State: ALoCoQncWdTEzutxNetFPm4XufSVCe12pmNoWGMX0sRL/fROk0ma1OsLqWPbeMxa0/Z359hqZUEz X-Received: by 10.194.133.39 with SMTP id oz7mr4230539wjb.3.1416412015874; Wed, 19 Nov 2014 07:46:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.33 with SMTP id cb1ls1568301lad.89.gmail; Wed, 19 Nov 2014 07:46:55 -0800 (PST) X-Received: by 10.112.146.37 with SMTP id sz5mr6079972lbb.27.1416412015163; Wed, 19 Nov 2014 07:46:55 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id jc4si2114060lbc.137.2014.11.19.07.46.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 07:46:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so704069lbv.38 for ; Wed, 19 Nov 2014 07:46:55 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr5926811lbc.66.1416412014992; Wed, 19 Nov 2014 07:46: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 ew9csp105695lbc; Wed, 19 Nov 2014 07:46:54 -0800 (PST) X-Received: by 10.69.20.42 with SMTP id gz10mr46865244pbd.91.1416412013078; Wed, 19 Nov 2014 07:46:53 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zm1si3163499pbc.201.2014.11.19.07.46.52 for ; Wed, 19 Nov 2014 07:46:53 -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 S1756066AbaKSPqu (ORCPT + 26 others); Wed, 19 Nov 2014 10:46:50 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:57520 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754480AbaKSPqs (ORCPT ); Wed, 19 Nov 2014 10:46:48 -0500 Received: by mail-pa0-f53.google.com with SMTP id kq14so458465pab.40 for ; Wed, 19 Nov 2014 07:46:48 -0800 (PST) X-Received: by 10.70.44.70 with SMTP id c6mr47182593pdm.45.1416412008169; Wed, 19 Nov 2014 07:46:48 -0800 (PST) Received: from vptest-PC.zte.com.cn ([167.160.116.27]) by mx.google.com with ESMTPSA id r2sm2136022pdi.60.2014.11.19.07.46.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 07:46:47 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v2 1/4] sched/deadline: Modify cpudl.free_cpus to reflect rd->span Date: Wed, 19 Nov 2014 23:46:19 +0800 Message-Id: <1416411982-1204-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.217.179 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 Reviewed-by: Wanpeng Li --- 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 100644 --- 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)