From patchwork Thu Jul 3 16:25:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 33041 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D44F5203AC for ; Thu, 3 Jul 2014 16:27:46 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id tr6sf2147983ieb.3 for ; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=I1owes0uUtQY4aGiS1Uv5b45nfF8X0P9Lv1Elk8jgME=; b=bDAkT4nV0oE/Hn91S2+HGNeKe9uvqWrF6cQVc3jlsZBNQ4oOjfsSy/WqK06y8QOjNI 42d2HSQFgm2wnC2XeRVUqwWk5IedTPOHcU5ZEHwAffySMUFBemIZi40ObAOphc0BzFRH RozkuxRp5gh1Bg7yQPiucAKPDm7um71F1w7BoA+Iiml3nVN7MwdFMci2dAptKp5cI0sy dCsQAjSspxlegIRpceMcU1Hf8banJJ2shycFHqJ7ueAsXNG9lDu7lFFsNpE9pA2utZKR hQksFkQMuTEUaMOG47n9/d67FQolNPIrnfQ0Q2pI8Zogu4zhquHWgb8PG9mwdJJrz+Kq DQFA== X-Gm-Message-State: ALoCoQlJ9diEEhnnGB4Dc0ZO1a2hnbWh6R/LwYgVIg2pwPWPz+2F4hsrcOUlGaCIVHhwMd+2wonF X-Received: by 10.50.170.162 with SMTP id an2mr26108428igc.4.1404404866384; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.179 with SMTP id m48ls555325qga.84.gmail; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) X-Received: by 10.52.123.232 with SMTP id md8mr4099656vdb.10.1404404866282; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id xn7si14409952vcb.105.2014.07.03.09.27.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:27:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so458466vcb.40 for ; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) X-Received: by 10.220.68.140 with SMTP id v12mr4802932vci.13.1404404866158; Thu, 03 Jul 2014 09:27:46 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp390410vcb; Thu, 3 Jul 2014 09:27:45 -0700 (PDT) X-Received: by 10.70.130.12 with SMTP id oa12mr5068397pdb.123.1404404864513; Thu, 03 Jul 2014 09:27:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ho4si33280366pbc.180.2014.07.03.09.27.43; Thu, 03 Jul 2014 09:27:43 -0700 (PDT) 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 S1759036AbaGCQ1c (ORCPT + 27 others); Thu, 3 Jul 2014 12:27:32 -0400 Received: from service87.mimecast.com ([91.220.42.44]:49596 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755678AbaGCQ13 (ORCPT ); Thu, 3 Jul 2014 12:27:29 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 03 Jul 2014 17:26:13 +0100 Received: from e103034-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Jul 2014 17:26:11 +0100 From: Morten Rasmussen To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, mingo@kernel.org Cc: rjw@rjwysocki.net, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, preeti@linux.vnet.ibm.com, Dietmar.Eggemann@arm.com, pjt@google.com Subject: [RFCv2 PATCH 07/23] sched: Introduce system-wide sched_energy Date: Thu, 3 Jul 2014 17:25:54 +0100 Message-Id: <1404404770-323-8-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> References: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 03 Jul 2014 16:26:11.0694 (UTC) FILETIME=[809EF8E0:01CF96DB] X-MC-Unique: 114070317261301101 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: morten.rasmussen@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 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: , From: Dietmar Eggemann The energy aware algorithm needs system wide energy information on certain platforms (e.g. a one socket SMP system). Unfortunately, there is no sched_group that covers all cpus in the system, so there is no place to attach a system wide sched_group_energy data structure. In such a system, the energy data is only attached to the sched groups for the individual cpus in the sched domain (sd) MC level. This patch adds a _hack_ to provide system-wide energy data via the sched_domain_topology_level table for such a system. The problem is that the sched_domain_topology_level table is not an interface to provide system-wide data but we want to keep the configuration of all energy related data in one place. The sched_domain_energy_f of the last entry (the one which is initialized with {NULL, }) of the sched_domain_topology_level table is set to cpu_sys_energy(). Since the sched_domain_mask_f of this entry stays NULL it is still not considered for the existing scheduler set-up code (see for_each_sd_topology()). A second call to init_sched_energy() with an sd pointer argument set to NULL initializes the system-wide energy structure sse. There is no system-wide power management on the example platform (ARM TC2) which could potentially interact with the scheduler so struct sched_group_energy *sse stays NULL. Signed-off-by: Dietmar Eggemann --- arch/arm/kernel/topology.c | 7 ++++++- kernel/sched/core.c | 34 ++++++++++++++++++++++++++++++---- kernel/sched/sched.h | 2 ++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index a7d5a6e..70915b1 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -386,6 +386,11 @@ static inline const struct sched_group_energy *cpu_core_energy(int cpu) &energy_core_a15; } +static inline const struct sched_group_energy *cpu_sys_energy(int cpu) +{ + return NULL; +} + static inline const int cpu_corepower_flags(void) { return SD_SHARE_PKG_RESOURCES | SD_SHARE_POWERDOMAIN; @@ -396,7 +401,7 @@ static struct sched_domain_topology_level arm_topology[] = { { cpu_coregroup_mask, cpu_corepower_flags, cpu_core_energy, SD_INIT_NAME(MC) }, #endif { cpu_cpu_mask, 0, cpu_cluster_energy, SD_INIT_NAME(DIE) }, - { NULL, }, + { NULL, 0, cpu_sys_energy}, }; /* diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7fecc63..2d7544a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5954,20 +5954,44 @@ static void init_sched_groups_capacity(int cpu, struct sched_domain *sd) atomic_set(&sg->sgc->nr_busy_cpus, sg->group_weight); } +/* System-wide energy information. */ +struct sched_group_energy *sse; + static void init_sched_energy(int cpu, struct sched_domain *sd, struct sched_domain_topology_level *tl) { - struct sched_group *sg = sd->groups; - struct sched_group_energy *energy = sg->sge; + struct sched_group *sg = sd ? sd->groups : NULL; + struct sched_group_energy *energy = sd ? sg->sge : sse; sched_domain_energy_f fn = tl->energy; - struct cpumask *mask = sched_group_cpus(sg); + const struct cpumask *mask = sd ? sched_group_cpus(sg) : + cpu_cpu_mask(cpu); - if (!fn || !fn(cpu)) + if (!fn || !fn(cpu) || (!sd && energy)) return; if (cpumask_weight(mask) > 1) check_sched_energy_data(cpu, fn, mask); + if (!sd) { + energy = sse = kzalloc(sizeof(struct sched_group_energy) + + fn(cpu)->nr_idle_states* + sizeof(struct idle_state) + + fn(cpu)->nr_cap_states* + sizeof(struct capacity_state), + GFP_KERNEL); + BUG_ON(!energy); + + energy->idle_states = (struct idle_state *) + ((void *)&energy->cap_states + + sizeof(energy->cap_states)); + + energy->cap_states = (struct capacity_state *) + ((void *)&energy->cap_states + + sizeof(energy->cap_states) + + fn(cpu)->nr_idle_states* + sizeof(struct idle_state)); + } + energy->nr_idle_states = fn(cpu)->nr_idle_states; memcpy(energy->idle_states, fn(cpu)->idle_states, energy->nr_idle_states*sizeof(struct idle_state)); @@ -6655,6 +6679,8 @@ static int build_sched_domains(const struct cpumask *cpu_map, claim_allocations(i, sd); init_sched_groups_capacity(i, sd); } + + init_sched_energy(i, NULL, tl); } /* Attach the domains */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1a5f1ee..c971359 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -747,6 +747,8 @@ struct sched_group_capacity { unsigned long cpumask[0]; /* iteration mask */ }; +extern struct sched_group_energy *sse; + struct sched_group { struct sched_group *next; /* Must be a circular list */ atomic_t ref;