From patchwork Tue Jun 12 12:02:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 9220 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 C556A23E56 for ; Tue, 12 Jun 2012 12:02:41 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 79D0CA18259 for ; Tue, 12 Jun 2012 12:02:41 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3629180yhp.11 for ; Tue, 12 Jun 2012 05:02: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=bOnklFDRrHn/aqVD099ifwG2cfuBwXW0boheX/iLxPs=; b=cmLtwrhuWyUgHKBjwJDxUlYieSAxJO33EG/+HaJVkTudndKbhTETEyFBOsadVixnT2 loB/C/N9qTxa7+HFCF4MAk+EQ8N5DT0XREjYCQA+AVUcskR1KP9hByEuOnbwEKk0MmVG S/XhW6mlDfgxGs+LE4Oz2xVH+lmz6sfzxx9CVAMdRwZLA0Wldz1ndiufwjLoDEWMavIN fBgH43amorG2K2aC6l5RafRPIM17AHpNvi2Mpl8CfZPRvNygsKwI5TgkqkOlmRuO2GjL 6tGiZ2NIeOP+WHOfXGt9UMgnLLlJgvxL3nccA7QD8eBmsJ3LaYGWuSWsmVB27WD1Ohkm 3dZA== Received: by 10.50.87.227 with SMTP id bb3mr7839613igb.57.1339502560570; Tue, 12 Jun 2012 05:02: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 v20csp162810ibb; Tue, 12 Jun 2012 05:02:39 -0700 (PDT) Received: by 10.180.93.99 with SMTP id ct3mr28491047wib.13.1339502559199; Tue, 12 Jun 2012 05:02:39 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id n3si4040277wix.5.2012.06.12.05.02.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 05:02:39 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by were53 with SMTP id e53so3811583wer.37 for ; Tue, 12 Jun 2012 05:02:38 -0700 (PDT) Received: by 10.180.85.129 with SMTP id h1mr28469130wiz.2.1339502558491; Tue, 12 Jun 2012 05:02:38 -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 gb9sm5060217wib.8.2012.06.12.05.02.35 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 05:02:36 -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, peterz@infradead.org, grant.likely@secretlab.ca, rob.herring@calxeda.com, Vincent Guittot Subject: [RFC 1/4] ARM: topology: Add arch_scale_freq_power function Date: Tue, 12 Jun 2012 14:02:01 +0200 Message-Id: <1339502524-10265-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1339502524-10265-1-git-send-email-vincent.guittot@linaro.org> References: <1339502524-10265-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQlgqu9lsHxtD+q+DN9ELziNU2KuuGW14XLdN1iOlN9+KR1CJn6ge8cT/inaKUXzT1fYOH5B Add infrastructure to be able to modify the cpu_power of each core Signed-off-by: Vincent Guittot --- arch/arm/include/asm/topology.h | 2 ++ arch/arm/kernel/topology.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h index 58b8b84..78e4c85 100644 --- a/arch/arm/include/asm/topology.h +++ b/arch/arm/include/asm/topology.h @@ -27,11 +27,13 @@ void init_cpu_topology(void); void store_cpu_topology(unsigned int cpuid); const struct cpumask *cpu_coregroup_mask(int cpu); +void set_power_scale(unsigned int cpu, unsigned long power); #else static inline void init_cpu_topology(void) { } static inline void store_cpu_topology(unsigned int cpuid) { } +static inline void set_power_scale(unsigned int cpu, unsigned long power) { } #endif #include diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 8200dea..00301a7 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -22,6 +22,35 @@ #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 for load balance. A per cpu structure is + * preferred because each cpu is mainly using its own cpu_power even it's not + * always true because of nohz_idle_balance + */ +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); +} + +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 +70,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 +166,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 +175,8 @@ void init_cpu_topology(void) cpu_topo->socket_id = -1; cpumask_clear(&cpu_topo->core_sibling); cpumask_clear(&cpu_topo->thread_sibling); + + per_cpu(cpu_scale, cpu) = SCHED_POWER_SCALE; } smp_wmb(); }