From patchwork Mon Jul 9 09:27:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 9893 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CA3B223E1B for ; Mon, 9 Jul 2012 09:27:41 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 80E30A180D2 for ; Mon, 9 Jul 2012 09:27:41 +0000 (UTC) Received: by yenq6 with SMTP id q6so10533056yen.11 for ; Mon, 09 Jul 2012 02:27:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=b6XqYuta7yN1f9ALg365fDT/cV2UdMt9X5sB20VEK3k=; b=DjxzXfeIY2g4u5YszZSEcu1wgKkbndmk0hadjXi2Ex4I/MvVMyzmJDTn0krpPn0wQ9 ubsejy14344kaXTn5LgEyhaFOhIMFhZPOkZjc8aekjlQNvQ+qsBuLWI8QSR9i7ZTcSRA I58E+c59FrScOgweJxRDi07nZ6XVyIeJe8+sKZ2rhQv1YtS8KYYi/+xysfxGS5SFH3Zl ZXMYb/brQSNIz630qqv+4yC5BU20rXWp/J979VDZWtRIUboSWwUjWSv9muc8rKQJeHrH ewwRHzMVGeRINsl3sH0Pi9vHSH++1u5ck2HiA7jaUBpp6RUHqhVc3W5/UtdoW4KJmbUU 2JgQ== Received: by 10.50.40.193 with SMTP id z1mr7990961igk.0.1341826060793; Mon, 09 Jul 2012 02:27:40 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp33293ibb; Mon, 9 Jul 2012 02:27:40 -0700 (PDT) Received: by 10.180.14.34 with SMTP id m2mr27871417wic.22.1341826059597; Mon, 09 Jul 2012 02:27:39 -0700 (PDT) Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by mx.google.com with ESMTPS id x76si37079405weq.72.2012.07.09.02.27.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 02:27:39 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by wgbds11 with SMTP id ds11so2470971wgb.1 for ; Mon, 09 Jul 2012 02:27:39 -0700 (PDT) Received: by 10.180.105.163 with SMTP id gn3mr27975689wib.2.1341826059040; Mon, 09 Jul 2012 02:27:39 -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 ESMTPS id j6sm33557246wiy.4.2012.07.09.02.27.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 02:27:38 -0700 (PDT) From: Vincent Guittot To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, devicetree-discuss@lists.ozlabs.org Cc: linux@arm.linux.org.uk, a.p.zijlstra@chello.nl, grant.likely@secretlab.ca, rob.herring@calxeda.com, yong.zhang0@gmail.com, namhyung@kernel.org, jean.pihet@newoldbits.com, Vincent Guittot Subject: [PATCH v4 1/5] ARM: topology: Add arch_scale_freq_power function Date: Mon, 9 Jul 2012 11:27:02 +0200 Message-Id: <1341826026-6504-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341826026-6504-1-git-send-email-vincent.guittot@linaro.org> References: <1341826026-6504-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQk9HVJ9JnFJqyWcfSgSBLd8r/lKhwM297rayR+4aT8FGFxajf3MZR/Sye6/NoFKhT37N34y Add infrastructure to be able to modify the cpu_power of each core Signed-off-by: Vincent Guittot Reviewed-by: Namhyung Kim --- arch/arm/kernel/topology.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 8200dea..51f23b3 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -22,6 +22,37 @@ #include #include +/* + * cpu power scale management + */ + +/* + * cpu power table + * This per cpu data structure describes the relative capacity of each core. + * On a heteregenous system, cores don't have the same computation capacity + * and we reflect that difference in the cpu_power field so the scheduler can + * take this difference into account during load balance. A per cpu structure + * is preferred because each CPU updates its own cpu_power field during the + * load balance except for idle cores. One idle core is selected to run the + * rebalance_domains for all idle cores and the cpu_power can be updated + * during this sequence. + */ +static DEFINE_PER_CPU(unsigned long, cpu_scale); + +unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu) +{ + return per_cpu(cpu_scale, cpu); +} + +static void set_power_scale(unsigned int cpu, unsigned long power) +{ + per_cpu(cpu_scale, cpu) = power; +} + +/* + * cpu topology management + */ + #define MPIDR_SMP_BITMASK (0x3 << 30) #define MPIDR_SMP_VALUE (0x2 << 30) @@ -41,6 +72,9 @@ #define MPIDR_LEVEL2_MASK 0xFF #define MPIDR_LEVEL2_SHIFT 16 +/* + * cpu topology table + */ struct cputopo_arm cpu_topology[NR_CPUS]; const struct cpumask *cpu_coregroup_mask(int cpu) @@ -134,7 +168,7 @@ void init_cpu_topology(void) { unsigned int cpu; - /* init core mask */ + /* init core mask and power*/ for_each_possible_cpu(cpu) { struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]); @@ -143,6 +177,8 @@ void init_cpu_topology(void) cpu_topo->socket_id = -1; cpumask_clear(&cpu_topo->core_sibling); cpumask_clear(&cpu_topo->thread_sibling); + + set_power_scale(cpu, SCHED_POWER_SCALE); } smp_wmb(); }