[RFC PATCH 05/16] sched: Add sd energy procfs interface
From: Morten Rasmussen
Date: Fri May 23 2014 - 14:21:14 EST
From: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
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 <dietmar.eggemann@xxxxxxx>
---
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;
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/