From patchwork Fri Oct 18 11:52:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 21115 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 64CB3246F1 for ; Fri, 18 Oct 2013 11:53:48 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md4sf5640847pbc.4 for ; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=h3aC3/Y3OwCe5lyZAHimNNpcMcG9/dXSlAKQHB/m1+s=; b=WfZ5YrUOnAEOflGbWE31TAhR1Yv4dPFbSHVJlLwBY+1k6uTxvwiomHzHySE7zPZFMw lqHYwgsyzvnDul+hD2Mzm0jFvRcZnJoQoOeBYhHYtwvhdoNUCcO/pa57R1lcda8lA/Dq cmq1my3TZ9hgZiEnW0GV03M0lLnEIhhoXuyaqI/HqcpjNk9TdRjtUiP/oV67YMeFLRk6 JcBNAV3J7/5VQSM7HuevYtlVq8Uf2boYTasx8xe9qDU6lik8UGerGLEfL2C7YHonD2i3 UCsgFaU7YP6l8B4xbwqwMwnR8YAE4zKFmSK4J2St6mmw5M+oiWC5vV0gA6O+NkhXYilX tPbA== X-Received: by 10.66.220.163 with SMTP id px3mr1265099pac.38.1382097226444; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls1307372qeo.28.gmail; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) X-Received: by 10.220.11.7 with SMTP id r7mr1760636vcr.12.1382097226281; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id fx4si233409vdc.52.2013.10.18.04.53.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id w8so1146809vbj.28 for ; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) X-Gm-Message-State: ALoCoQk0Rjvmw7/3cX74dfNsuJIOEJfv3JHkH+HdVKsZxChnV99Bq4SziJIIjXMmS19Ss5CgZm6P X-Received: by 10.58.217.130 with SMTP id oy2mr47535vec.24.1382097226161; Fri, 18 Oct 2013 04:53:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp29475vcz; Fri, 18 Oct 2013 04:53:45 -0700 (PDT) X-Received: by 10.180.10.136 with SMTP id i8mr2132018wib.46.1382097225023; Fri, 18 Oct 2013 04:53:45 -0700 (PDT) Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by mx.google.com with ESMTPS id ax1si416259wjc.107.2013.10.18.04.53.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:45 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.172 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.172; Received: by mail-we0-f172.google.com with SMTP id q58so3660465wes.31 for ; Fri, 18 Oct 2013 04:53:44 -0700 (PDT) X-Received: by 10.194.110.138 with SMTP id ia10mr2271294wjb.3.1382097224382; Fri, 18 Oct 2013 04:53:44 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id lr3sm25000673wic.5.2013.10.18.04.53.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 04:53:43 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, pjt@google.com, Morten.Rasmussen@arm.com, cmetcalf@tilera.com, tony.luck@intel.com, alex.shi@intel.com, preeti@linux.vnet.ibm.com, linaro-kernel@lists.linaro.org Cc: rjw@sisk.pl, paulmck@linux.vnet.ibm.com, corbet@lwn.net, tglx@linutronix.de, len.brown@intel.com, arjan@linux.intel.com, amit.kucheria@linaro.org, l.majewski@samsung.com, Vincent Guittot Subject: [RFC][PATCH v5 01/14] sched: add a new arch_sd_local_flags for sched_domain init Date: Fri, 18 Oct 2013 13:52:15 +0200 Message-Id: <1382097147-30088-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> References: <1382097147-30088-1-git-send-email-vincent.guittot@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The function arch_sd_local_flags is used to set flags in sched_domains according to the platform architecture. A new flag SD_SHARE_POWERDOMAIN is also created to reflect whether groups of CPUs in a sched_domain level can or not reach different power state. As an example, the flag should be cleared at CPU level if groups of cores can be power gated independently. This information is used to decide if it's worth packing some tasks in a group of CPUs in order to power gate the other groups instead of spreading the tasks. The default behavior of the scheduler is to spread tasks across CPUs and groups of CPUs so the flag is set into all sched_domains. The cpu parameter of arch_sd_local_flags can be used by architecture to fine tune the scheduler domain flags. As an example SD_SHARE_POWERDOMAIN flag can be set differently for groups of CPUs according to DT information Signed-off-by: Vincent Guittot --- arch/ia64/include/asm/topology.h | 3 ++- arch/tile/include/asm/topology.h | 3 ++- include/linux/sched.h | 1 + include/linux/topology.h | 11 ++++++++--- kernel/sched/core.c | 10 ++++++++-- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/arch/ia64/include/asm/topology.h b/arch/ia64/include/asm/topology.h index a2496e4..4844896 100644 --- a/arch/ia64/include/asm/topology.h +++ b/arch/ia64/include/asm/topology.h @@ -46,7 +46,7 @@ void build_cpu_to_node_map(void); -#define SD_CPU_INIT (struct sched_domain) { \ +#define SD_CPU_INIT(cpu) (struct sched_domain) { \ .parent = NULL, \ .child = NULL, \ .groups = NULL, \ @@ -65,6 +65,7 @@ void build_cpu_to_node_map(void); | SD_BALANCE_EXEC \ | SD_BALANCE_FORK \ | SD_WAKE_AFFINE, \ + | arch_sd_local_flags(0, cpu)\ .last_balance = jiffies, \ .balance_interval = 1, \ .nr_balance_failed = 0, \ diff --git a/arch/tile/include/asm/topology.h b/arch/tile/include/asm/topology.h index d15c0d8..6f7a97d 100644 --- a/arch/tile/include/asm/topology.h +++ b/arch/tile/include/asm/topology.h @@ -51,7 +51,7 @@ static inline const struct cpumask *cpumask_of_node(int node) */ /* sched_domains SD_CPU_INIT for TILE architecture */ -#define SD_CPU_INIT (struct sched_domain) { \ +#define SD_CPU_INIT(cpu) (struct sched_domain) { \ .min_interval = 4, \ .max_interval = 128, \ .busy_factor = 64, \ @@ -71,6 +71,7 @@ static inline const struct cpumask *cpumask_of_node(int node) | 0*SD_WAKE_AFFINE \ | 0*SD_SHARE_CPUPOWER \ | 0*SD_SHARE_PKG_RESOURCES \ + | arch_sd_local_flags(0, cpu) \ | 0*SD_SERIALIZE \ , \ .last_balance = jiffies, \ diff --git a/include/linux/sched.h b/include/linux/sched.h index 6682da3..2004cdb 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -763,6 +763,7 @@ enum cpu_idle_type { #define SD_BALANCE_WAKE 0x0010 /* Balance on wakeup */ #define SD_WAKE_AFFINE 0x0020 /* Wake task to waking CPU */ #define SD_SHARE_CPUPOWER 0x0080 /* Domain members share cpu power */ +#define SD_SHARE_POWERDOMAIN 0x0100 /* Domain members share power domain */ #define SD_SHARE_PKG_RESOURCES 0x0200 /* Domain members share cpu pkg resources */ #define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */ #define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ diff --git a/include/linux/topology.h b/include/linux/topology.h index d3cf0d6..f3cd3c2 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -85,7 +85,7 @@ int arch_update_cpu_topology(void); #define ARCH_HAS_SCHED_WAKE_IDLE /* Common values for SMT siblings */ #ifndef SD_SIBLING_INIT -#define SD_SIBLING_INIT (struct sched_domain) { \ +#define SD_SIBLING_INIT(cpu) (struct sched_domain) { \ .min_interval = 1, \ .max_interval = 2, \ .busy_factor = 64, \ @@ -99,6 +99,8 @@ int arch_update_cpu_topology(void); | 1*SD_WAKE_AFFINE \ | 1*SD_SHARE_CPUPOWER \ | 1*SD_SHARE_PKG_RESOURCES \ + | arch_sd_local_flags(SD_SHARE_CPUPOWER|\ + SD_SHARE_PKG_RESOURCES, cpu) \ | 0*SD_SERIALIZE \ | 0*SD_PREFER_SIBLING \ | arch_sd_sibling_asym_packing() \ @@ -113,7 +115,7 @@ int arch_update_cpu_topology(void); #ifdef CONFIG_SCHED_MC /* Common values for MC siblings. for now mostly derived from SD_CPU_INIT */ #ifndef SD_MC_INIT -#define SD_MC_INIT (struct sched_domain) { \ +#define SD_MC_INIT(cpu) (struct sched_domain) { \ .min_interval = 1, \ .max_interval = 4, \ .busy_factor = 64, \ @@ -131,6 +133,8 @@ int arch_update_cpu_topology(void); | 1*SD_WAKE_AFFINE \ | 0*SD_SHARE_CPUPOWER \ | 1*SD_SHARE_PKG_RESOURCES \ + | arch_sd_local_flags( \ + SD_SHARE_PKG_RESOURCES, cpu) \ | 0*SD_SERIALIZE \ , \ .last_balance = jiffies, \ @@ -141,7 +145,7 @@ int arch_update_cpu_topology(void); /* Common values for CPUs */ #ifndef SD_CPU_INIT -#define SD_CPU_INIT (struct sched_domain) { \ +#define SD_CPU_INIT(cpu) (struct sched_domain) { \ .min_interval = 1, \ .max_interval = 4, \ .busy_factor = 64, \ @@ -161,6 +165,7 @@ int arch_update_cpu_topology(void); | 1*SD_WAKE_AFFINE \ | 0*SD_SHARE_CPUPOWER \ | 0*SD_SHARE_PKG_RESOURCES \ + | arch_sd_local_flags(0, cpu) \ | 0*SD_SERIALIZE \ | 1*SD_PREFER_SIBLING \ , \ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5ac63c9..735e964 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5460,6 +5460,11 @@ int __weak arch_sd_sibling_asym_packing(void) return 0*SD_ASYM_PACKING; } +int __weak arch_sd_local_flags(int level, int cpu) +{ + return 1*SD_SHARE_POWERDOMAIN; +} + /* * Initializers for schedule domains * Non-inlined to reduce accumulated stack pressure in build_sched_domains() @@ -5473,10 +5478,10 @@ int __weak arch_sd_sibling_asym_packing(void) #define SD_INIT_FUNC(type) \ static noinline struct sched_domain * \ -sd_init_##type(struct sched_domain_topology_level *tl, int cpu) \ +sd_init_##type(struct sched_domain_topology_level *tl, int cpu) \ { \ struct sched_domain *sd = *per_cpu_ptr(tl->data.sd, cpu); \ - *sd = SD_##type##_INIT; \ + *sd = SD_##type##_INIT(cpu); \ SD_INIT_NAME(sd, type); \ sd->private = &tl->data; \ return sd; \ @@ -5652,6 +5657,7 @@ sd_numa_init(struct sched_domain_topology_level *tl, int cpu) | 0*SD_WAKE_AFFINE | 0*SD_SHARE_CPUPOWER | 0*SD_SHARE_PKG_RESOURCES + | 1*SD_SHARE_POWERDOMAIN | 1*SD_SERIALIZE | 0*SD_PREFER_SIBLING | sd_local_flags(level)