From patchwork Thu Jul 3 16:25:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 33052 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f199.google.com (mail-yk0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 87A09203AC for ; Thu, 3 Jul 2014 16:32:41 +0000 (UTC) Received: by mail-yk0-f199.google.com with SMTP id 200sf829720ykr.10 for ; Thu, 03 Jul 2014 09:32:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=2YQAicDSB0lf06qz3UdMnwjE9FixySXBHboXu/NhdP8=; b=gvfESeH3EhrL2GqWUxuW7pbNtkFWpez80CGr3pmoT/Oq4q6D2NXR8gduSIuHUZIJ6e q0bCB3ROSqZMdjE8f+s/jqidaBqK1OvCxESOzLZC7oZxlURjHYcr/T6mhJEbcBcUEeJJ omu8WIkVXu9ep8DGXFbuce27EMQA41q68dYEbSqvhM7A/nbLrw1qEvd1la85iyYqPzaY Cq0vf1scZNX8KGgX6NR/6EnjKAW1QUIdxiOyvr0yyMK47DZInC1qYtUQ9YNgm+urqp2Q UMfMARNCtdqng2Qo/Uj8AWYHkcK3SgoQeR+r7Z67HpqM1CGmvVj4bC+v+YB1mr3hcZ0O xkNg== X-Gm-Message-State: ALoCoQkjIH4GXlkZAToBdRG6nm2wJhlLsTPpXmkfzS/0MJxOuhS0dbhQnQ0LxqZtvMS5SvZheLjY X-Received: by 10.236.223.9 with SMTP id u9mr2432431yhp.2.1404405161379; Thu, 03 Jul 2014 09:32:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.193 with SMTP id q59ls577699qga.91.gmail; Thu, 03 Jul 2014 09:32:41 -0700 (PDT) X-Received: by 10.58.132.136 with SMTP id ou8mr2139839veb.0.1404405161310; Thu, 03 Jul 2014 09:32:41 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id v15si14443488vei.0.2014.07.03.09.32.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:32:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id i13so489965veh.36 for ; Thu, 03 Jul 2014 09:32:41 -0700 (PDT) X-Received: by 10.221.64.80 with SMTP id xh16mr1720222vcb.35.1404405161194; Thu, 03 Jul 2014 09:32:41 -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 tc5csp390799vcb; Thu, 3 Jul 2014 09:32:40 -0700 (PDT) X-Received: by 10.70.56.42 with SMTP id x10mr5141574pdp.74.1404405160405; Thu, 03 Jul 2014 09:32:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha1si33324602pbc.104.2014.07.03.09.32.39; Thu, 03 Jul 2014 09:32:39 -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 S1759481AbaGCQca (ORCPT + 27 others); Thu, 3 Jul 2014 12:32:30 -0400 Received: from service87.mimecast.com ([91.220.42.44]:45062 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759147AbaGCQ0L convert rfc822-to-8bit (ORCPT ); Thu, 3 Jul 2014 12:26:11 -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:09 +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:09 +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 05/23] sched: Add energy procfs interface Date: Thu, 3 Jul 2014 17:25:52 +0100 Message-Id: <1404404770-323-6-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> MIME-Version: 1.0 X-OriginalArrivalTime: 03 Jul 2014 16:26:09.0834 (UTC) FILETIME=[7F8328A0:01CF96DB] X-MC-Unique: 114070317260911701 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.128.177 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 This patch makes the energy data available via procfs. The related files are placed as sub-directory named 'energy' inside the /proc/sys/kernel/sched_domain/cpuX/domainY/groupZ directory for those cpu/domain/group tuples which have energy information. The following example depicts the contents of /proc/sys/kernel/sched_domain/cpu0/domain0/group[01] for a system which has energy information attached to domain level 0. ├── cpu0 │   ├── domain0 │   │   ├── busy_factor │   │   ├── busy_idx │   │   ├── cache_nice_tries │   │   ├── flags │   │   ├── forkexec_idx │   │   ├── group0 │   │   │   └── energy │   │   │   ├── cap_states │   │   │   ├── idle_states │   │   │   ├── nr_cap_states │   │   │   └── nr_idle_states │   │   ├── group1 │   │   │   └── energy │   │   │   ├── cap_states │   │   │   ├── idle_states │   │   │   ├── nr_cap_states │   │   │   └── nr_idle_states │   │   ├── idle_idx │   │   ├── imbalance_pct │   │   ├── max_interval │   │   ├── max_newidle_lb_cost │   │   ├── min_interval │   │   ├── name │   │   ├── newidle_idx │   │   └── wake_idx │   └── domain1 │   ├── busy_factor │   ├── busy_idx │   ├── cache_nice_tries │   ├── flags │   ├── forkexec_idx │   ├── idle_idx │   ├── imbalance_pct │   ├── max_interval │   ├── max_newidle_lb_cost │   ├── min_interval │   ├── name │   ├── newidle_idx │   └── wake_idx The files 'nr_idle_states' and 'nr_cap_states' contain a scalar value whereas 'idle_states' and 'cap_states' contain a vector of (power consumption, wakeup energy for run->sleep->run cycle for this idle state) respectively (compute capacity, power consumption at this compute capacity) tuples. Signed-off-by: Dietmar Eggemann --- kernel/sched/core.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ecece17..7fecc63 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4931,9 +4931,60 @@ set_table_entry(struct ctl_table *entry, } static struct ctl_table * +sd_alloc_ctl_energy_table(struct sched_group_energy *sge) +{ + struct ctl_table *table = sd_alloc_ctl_entry(5); + + if (table == NULL) + return NULL; + + set_table_entry(&table[0], "nr_idle_states", &sge->nr_idle_states, + sizeof(int), 0644, proc_dointvec_minmax, false); + set_table_entry(&table[1], "idle_states", &sge->idle_states[0].power, + sge->nr_idle_states*sizeof(struct idle_state), 0644, + proc_doulongvec_minmax, false); + set_table_entry(&table[2], "nr_cap_states", &sge->nr_cap_states, + sizeof(int), 0644, proc_dointvec_minmax, false); + set_table_entry(&table[3], "cap_states", &sge->cap_states[0].cap, + sge->nr_cap_states*sizeof(struct capacity_state), 0644, + proc_doulongvec_minmax, false); + + return table; +} + +static struct ctl_table * +sd_alloc_ctl_group_table(struct sched_group *sg) +{ + struct ctl_table *table = sd_alloc_ctl_entry(2); + + if (table == NULL) + return NULL; + + table->procname = kstrdup("energy", GFP_KERNEL); + table->mode = 0555; + table->child = sd_alloc_ctl_energy_table(sg->sge); + + return table; +} + +static struct ctl_table * sd_alloc_ctl_domain_table(struct sched_domain *sd) { - struct ctl_table *table = sd_alloc_ctl_entry(14); + struct ctl_table *table; + unsigned int nr_entries = 14; + + int i = 0; + struct sched_group *sg = sd->groups; + + if (sg->sge) { + int nr_sgs = 0; + + do {} while (nr_sgs++, sg = sg->next, sg != sd->groups); + + nr_entries += nr_sgs; + } + + table = sd_alloc_ctl_entry(nr_entries); if (table == NULL) return NULL; @@ -4966,7 +5017,19 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd) sizeof(long), 0644, proc_doulongvec_minmax, false); set_table_entry(&table[12], "name", sd->name, CORENAME_MAX_SIZE, 0444, proc_dostring, false); - /* &table[13] is terminator */ + sg = sd->groups; + if (sg->sge) { + char buf[32]; + struct ctl_table *entry = &table[13]; + + do { + snprintf(buf, 32, "group%d", i); + entry->procname = kstrdup(buf, GFP_KERNEL); + entry->mode = 0555; + entry->child = sd_alloc_ctl_group_table(sg); + } while (entry++, i++, sg = sg->next, sg != sd->groups); + } + /* &table[nr_entries-1] is terminator */ return table; }