From patchwork Fri May 23 18:16:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 30854 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A786220369 for ; Fri, 23 May 2014 18:20:50 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf25100371iec.8 for ; Fri, 23 May 2014 11:20:50 -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=mQZQ0c5Rny1wNEQW8l0IjVfp940pkMTVQtdZJJGfOFs=; b=R3GibYD+O2g3rV44kwSw8LBQOdyuq3GT7VI4PE/0ZU7WIQfapE7Dmja5ll+Dr/2DLo HK9PjnXPK4GyViQckSncd/V2E2QfDD6GvYbcbEL1WBz5n/1BQe4SPBxVxZscyRQkIhA3 EULocTUOKGaJfBTNneGIlUUuLfP2/UE+o7A8Dsu2RxPELPaXc1TqlxcLNloPQUGyQo4w EmrqQbewoaDcx7zxAgII1TLW5pInQvVkmORSqHaIgLZfBElMQmYoZc9g2aq+/QoNwYCZ 3sqDubHbooYdf0kFBkoeURP9xAHe3F4Dh185gkYaJUnVYRK4pbtmf8X4tQvAPxoTxwhP p0Ng== X-Gm-Message-State: ALoCoQmgxJhIS2nX5uQNBMQqdUZVWLowF32dxJ51mIoF4agerRgoyXGPtdMPONf3+n2MSSvEzrQh X-Received: by 10.42.203.202 with SMTP id fj10mr2658333icb.0.1400869250179; Fri, 23 May 2014 11:20:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.115 with SMTP id e106ls1876161qgd.65.gmail; Fri, 23 May 2014 11:20:50 -0700 (PDT) X-Received: by 10.52.104.7 with SMTP id ga7mr4745333vdb.29.1400869250063; Fri, 23 May 2014 11:20:50 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id yh7si2105328vdc.93.2014.05.23.11.20.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 11:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id hy4so6650107vcb.39 for ; Fri, 23 May 2014 11:20:49 -0700 (PDT) X-Received: by 10.52.139.101 with SMTP id qx5mr4715703vdb.17.1400869249797; Fri, 23 May 2014 11:20:49 -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.220.221.72 with SMTP id ib8csp52506vcb; Fri, 23 May 2014 11:20:49 -0700 (PDT) X-Received: by 10.68.197.195 with SMTP id iw3mr8128802pbc.139.1400869249017; Fri, 23 May 2014 11:20:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc2si4904315pbb.208.2014.05.23.11.20.48; Fri, 23 May 2014 11:20:48 -0700 (PDT) Received-SPF: none (google.com: linux-pm-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 S1752327AbaEWSUr (ORCPT + 12 others); Fri, 23 May 2014 14:20:47 -0400 Received: from service87.mimecast.com ([91.220.42.44]:36020 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751331AbaEWSQw convert rfc822-to-8bit (ORCPT ); Fri, 23 May 2014 14:16:52 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 23 May 2014 19:16:50 +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); Fri, 23 May 2014 19:16:49 +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 Subject: [RFC PATCH 05/16] sched: Add sd energy procfs interface Date: Fri, 23 May 2014 19:16:32 +0100 Message-Id: <1400869003-27769-6-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> References: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> MIME-Version: 1.0 X-OriginalArrivalTime: 23 May 2014 18:16:49.0651 (UTC) FILETIME=[2A371430:01CF76B3] X-MC-Unique: 114052319165000801 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.180 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 values of the sd energy data structure 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 sd energy information. The following example depicts the contents of /proc/sys/kernel/sched_domain/cpu0/domain0/group[01] for a system which has sd energy information attached to domain level 0. ├── cpu0 │   ├── domain0 │   │   ├── busy_factor │   │   ├── busy_idx │   │   ├── cache_nice_tries │   │   ├── flags │   │   ├── forkexec_idx │   │   ├── group0 │   │   │   └── energy │   │   │   ├── cap_states │   │   │   ├── idle_power │   │   │   ├── max_capacity │   │   │   ├── nr_cap_states │   │   │   └── wakeup_energy │   │   ├── group1 │   │   │   └── energy │   │   │   ├── cap_states │   │   │   ├── idle_power │   │   │   ├── max_capacity │   │   │   ├── nr_cap_states │   │   │   └── wakeup_energy │   │   ├── 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 'idle_power', 'max_capacity', 'nr_cap_states' and 'wakeup_energy' contain a scalar value whereas 'cap_states' contains a vector of (compute capacity, power consumption @ this compute capacity) tuples. Signed-off-by: Dietmar Eggemann --- kernel/sched/core.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 785b61d..096fa55 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4837,10 +4837,66 @@ set_table_entry(struct ctl_table *entry, } } +#ifdef CONFIG_SCHED_ENERGY +static struct ctl_table * +sd_alloc_ctl_energy_table(struct sched_group_energy *sge) +{ + struct ctl_table *table = sd_alloc_ctl_entry(6); + + if (table == NULL) + return NULL; + + set_table_entry(&table[0], "max_capacity", &sge->data.max_capacity, + sizeof(long), 0644, proc_doulongvec_minmax, false); + set_table_entry(&table[1], "idle_power", &sge->data.idle_power, + sizeof(int), 0644, proc_dointvec_minmax, false); + set_table_entry(&table[2], "wakeup_energy", &sge->data.wakeup_energy, + sizeof(int), 0644, proc_dointvec_minmax, false); + set_table_entry(&table[3], "nr_cap_states", &sge->data.nr_cap_states, + sizeof(int), 0644, proc_dointvec_minmax, false); + set_table_entry(&table[4], "cap_states", &sge->data.cap_states[0].cap, + sge->data.nr_cap_states*2*sizeof(int), 0644, + proc_dointvec_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; +} +#endif + 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; + +#ifdef CONFIG_SCHED_ENERGY + 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; + } +#endif + + table = sd_alloc_ctl_entry(nr_entries); if (table == NULL) return NULL; @@ -4873,7 +4929,20 @@ 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 */ +#ifdef CONFIG_SCHED_ENERGY + 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); + } +#endif + /* &table[nr_entries-1] is terminator */ return table; }