From patchwork Thu Jan 29 15:53:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 43949 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8AAF32410D for ; Thu, 29 Jan 2015 16:00:31 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf12245207wev.0 for ; Thu, 29 Jan 2015 08:00:30 -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=zBK60VqCpeXD22wVYVYr8r1FEpFJBTdycyS9ILjAmq0=; b=hzR8DtPFizPh+9gZy7wIw3Kmp2OjnvCTvnU2iRyYn5Ku1cIUcDMIItB4NjbaMs2GNx WaOHqnrlk9EP6V9am6nnO4bfeFFU3GOUXBM6kmLp84dG+zpD1z6hGveIvzJcDJI1V794 5szh+KtRMOKdxnLoGGC4qQ/aYfgQQTqAVvmIAilAXukU+z+gyMrpUd06R74bEhOiYafx JlMd5YOwQInH7zfBTUkipbC4yjh2ufyG1NQDjKANdnFzEVO3V4h6j+BbkmrXR9pD8gPN fyuiNds/2wrjQ8f2zT7ULRDIXsNO3TN3wBuRlV/QVn0c7DRv73CI8UW1GqRTBJAI8jAR 8QSQ== X-Gm-Message-State: ALoCoQk6Ha9gAEvXsHHLGpoucowV5FJWX6KCv5g3dUpiSR2Ltra55qJfqFC0n4gbMYehUnkAMn6R X-Received: by 10.152.37.130 with SMTP id y2mr208679laj.8.1422547230823; Thu, 29 Jan 2015 08:00:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.11 with SMTP id lk11ls334235lac.8.gmail; Thu, 29 Jan 2015 08:00:30 -0800 (PST) X-Received: by 10.112.211.168 with SMTP id nd8mr1815481lbc.18.1422547230649; Thu, 29 Jan 2015 08:00:30 -0800 (PST) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com. [2a00:1450:4010:c04::22c]) by mx.google.com with ESMTPS id s10si7826262lae.47.2015.01.29.08.00.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 08:00:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) client-ip=2a00:1450:4010:c04::22c; Received: by mail-lb0-f172.google.com with SMTP id l4so29716994lbv.3 for ; Thu, 29 Jan 2015 08:00:30 -0800 (PST) X-Received: by 10.152.116.43 with SMTP id jt11mr1602326lab.69.1422547230390; Thu, 29 Jan 2015 08:00:30 -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.35.133 with SMTP id h5csp1806326lbj; Thu, 29 Jan 2015 08:00:29 -0800 (PST) X-Received: by 10.70.134.142 with SMTP id pk14mr1727994pdb.17.1422547225119; Thu, 29 Jan 2015 08:00:25 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si10418459pdp.89.2015.01.29.08.00.23; Thu, 29 Jan 2015 08:00:25 -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 S1755059AbbA2QAR (ORCPT + 29 others); Thu, 29 Jan 2015 11:00:17 -0500 Received: from m50-111.126.com ([123.125.50.111]:42443 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750840AbbA2QAP (ORCPT ); Thu, 29 Jan 2015 11:00:15 -0500 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowABHc+eGV8pUbY0NDQ--.885S2; Thu, 29 Jan 2015 23:53:54 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang Subject: [PATCH v2 1/4] sched/deadline: Modify cpudl::free_cpus to reflect root_domain::online Date: Thu, 29 Jan 2015 23:53:17 +0800 Message-Id: <1422546800-2935-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jtKowABHc+eGV8pUbY0NDQ--.885S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAr4kKFWUuF4UZF1DZr47Arb_yoWrCr4Dpr 1qkrW7Jr4UJrW5W3s0y395ArZ3uwnaq34ku3sagF9YyF9ayrnavFn8Xa43uryUJr1kuF12 vFWqg39Fg34Utr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jk8n5UUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi6BKQv08OtIF5DgAAsW Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com 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: , From: Xunlei Pang Currently, cpudl::free_cpus contains all cpus during init, see cpudl_init(). When calling cpudl_find(), we have to mask rd->span to avoid selecting the cpu outside current root domain, because cpus_allowed is undependable when performing clustered scheduling using the cpuset, see find_later_rq(). This patch adds cpudl_set_freecpu() and cpudl_clear_freecpu() for changing cpudl::free_cpus when doing rq_online_dl()/rq_offline_dl(), so we can avoid the rd->span operation when calling cpudl_find() in find_later_rq(). Signed-off-by: Xunlei Pang --- kernel/sched/cpudeadline.c | 28 ++++++++++++++++++++++++---- kernel/sched/cpudeadline.h | 2 ++ kernel/sched/deadline.c | 5 ++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 539ca3c..fd9d3fb 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,26 @@ 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_clear_freecpu - Clear the cpudl.free_cpus + * @cp: the cpudl max-heap context + * @cpu: rd attached cpu + */ +void cpudl_clear_freecpu(struct cpudl *cp, int cpu) +{ + cpumask_clear_cpu(cpu, cp->free_cpus); +} + +/* * cpudl_init - initialize the cpudl structure * @cp: the cpudl max-heap context */ @@ -203,7 +225,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 +233,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..1a0a6ef 100644 --- a/kernel/sched/cpudeadline.h +++ b/kernel/sched/cpudeadline.h @@ -24,6 +24,8 @@ 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_clear_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 b52092f..e7b2722 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1165,9 +1165,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) @@ -1562,6 +1559,7 @@ static void rq_online_dl(struct rq *rq) if (rq->dl.overloaded) dl_set_overload(rq); + cpudl_set_freecpu(&rq->rd->cpudl, rq->cpu); if (rq->dl.dl_nr_running > 0) cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr, 1); } @@ -1573,6 +1571,7 @@ static void rq_offline_dl(struct rq *rq) dl_clear_overload(rq); cpudl_set(&rq->rd->cpudl, rq->cpu, 0, 0); + cpudl_clear_freecpu(&rq->rd->cpudl, rq->cpu); } void init_sched_dl_class(void)