From patchwork Mon Nov 17 16:11: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: 40929 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 074B924035 for ; Mon, 17 Nov 2014 16:12:03 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id t10sf2050594eei.4 for ; Mon, 17 Nov 2014 08:12:02 -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=6fBrJiSjYYjrF2anIB9N0DHjSkvjlM9hL6Qwu4bB+bY=; b=BZwRrN269Q71hmh92PkNHcBP4f79AzucfmOTAQnuMzyFZVHwuDHCF/eu8gIwFZaEvR xfPRhmH+GFgxpgGgPco2ceiwhr8CZirF4vsIjX/6sM7s+BIZk1ZTRNPpA6krD7nkE2KY BGl14EfMu9V+tv58SNXMro5qpVWrZskmtFLA34cHeBypwZwh+dv5DYtwccvoh2TWEdDW NKtP5i0I2MxX4nZrfrmAqDn36h0N7Lo97iKwwEITumebUK19OQXWUBgG1Kn0Cb5oblUn 5yz5FAlxvXYfwMXIyOWEuTtrVWfBn4NPi4nhEdsRiX8JyLKKnmEdDCNuimrr5SmuQgIj vWig== X-Gm-Message-State: ALoCoQn1eNAm4URjoDMMN40+Zw50b8/rq1Zei3WMmp07LUx6+cpuhgyd4LT/PnvJsKpZPHoJDGXY X-Received: by 10.112.188.199 with SMTP id gc7mr8985912lbc.6.1416240722192; Mon, 17 Nov 2014 08:12:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.169 with SMTP id 9ls1241855lan.109.gmail; Mon, 17 Nov 2014 08:12:01 -0800 (PST) X-Received: by 10.152.87.171 with SMTP id az11mr28068707lab.37.1416240721629; Mon, 17 Nov 2014 08:12:01 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id z4si43422701laz.128.2014.11.17.08.12.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 08:12:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so4754403lam.35 for ; Mon, 17 Nov 2014 08:12:01 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr28621051lal.29.1416240721236; Mon, 17 Nov 2014 08:12:01 -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 ew9csp1179936lbc; Mon, 17 Nov 2014 08:12:00 -0800 (PST) X-Received: by 10.66.66.234 with SMTP id i10mr30560828pat.44.1416240719510; Mon, 17 Nov 2014 08:11:59 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id re4si30764781pdb.252.2014.11.17.08.11.58 for ; Mon, 17 Nov 2014 08:11:59 -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 S1751829AbaKQQL5 (ORCPT + 26 others); Mon, 17 Nov 2014 11:11:57 -0500 Received: from mail-pd0-f181.google.com ([209.85.192.181]:59781 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750806AbaKQQLz (ORCPT ); Mon, 17 Nov 2014 11:11:55 -0500 Received: by mail-pd0-f181.google.com with SMTP id z10so4155844pdj.40 for ; Mon, 17 Nov 2014 08:11:55 -0800 (PST) X-Received: by 10.68.93.1 with SMTP id cq1mr4561104pbb.145.1416240714894; Mon, 17 Nov 2014 08:11:54 -0800 (PST) Received: from vptest-PC.zte.com.cn ([167.160.116.21]) by mx.google.com with ESMTPSA id xy3sm35436833pbb.38.2014.11.17.08.11.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2014 08:11:54 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH 1/2] sched/deadline: Modify cpudl.free_cpus to reflect rd->span Date: Tue, 18 Nov 2014 00:11:03 +0800 Message-Id: <1416240664-7200-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.48 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 | 19 +++++++++++++++---- kernel/sched/cpudeadline.h | 1 + kernel/sched/deadline.c | 3 --- 4 files changed, 18 insertions(+), 7 deletions(-) mode change 100644 => 100755 kernel/sched/cpudeadline.c mode change 100644 => 100755 kernel/sched/deadline.c 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 old mode 100644 new mode 100755 index 539ca3c..9a69353 --- 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,17 @@ 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 +216,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 +224,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 old mode 100644 new mode 100755 index 5285332..bd83272 --- 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)