[RFC PATCH v2 2/5] sched: calculate statistics for current loadbalance domain

From: Vaidyanathan Srinivasan
Date: Thu Oct 09 2008 - 08:05:57 EST


Add data structures and function to collect per sched domain
statistics required for load balance decision.

Signed-off-by: Vaidyanathan Srinivasan <svaidy@xxxxxxxxxxxxxxxxxx>
---

kernel/sched.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index ab77937..cfd83d9 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3178,6 +3178,57 @@ int get_group_loads(struct sched_group *group, int this_cpu,
return need_balance;
}

+/* Struct to hold sched domain level loads */
+
+struct sd_loads {
+ struct sched_domain *sd;
+ unsigned long load; /* Total decay load */
+ unsigned long cpu_power; /* Total cpu_power */
+ unsigned long max_load; /* load of busiest group */
+ unsigned long load_per_cpu; /* Decay load per cpu in this sd
+ * (load/cpu_power)
+ */
+ struct group_loads local; /* this_cpu's group,
+ * need to pull from busiest
+ */
+ struct group_loads busiest; /* Candidate group to pull */
+ /* sched_mc power_save balance groups */
+ struct group_loads min_load_group; /* Group that is least loaded and
+ * can fit the tasks into the
+ * leader group
+ */
+ struct group_loads power_save_leader_group; /* Group that is almost
+ * full but can still pull
+ * tasks from
+ * min_load_group
+ */
+};
+
+/* Function to aggregate per group loads to sched domain loads */
+
+void update_sd_loads(struct sd_loads *sdl, struct group_loads *gl)
+{
+ int group_capacity = gl->group->__cpu_power / SCHED_LOAD_SCALE;
+ sdl->max_load = 0;
+
+ if (gl->local_group)
+ sdl->local = *gl;
+ else {
+ sdl->load += gl->load;
+ sdl->cpu_power += gl->group->__cpu_power;
+
+
+ /* Find the busiest */
+ if (gl->load > sdl->max_load &&
+ (gl->nr_running > group_capacity ||
+ gl->group_imbalance)) {
+
+ sdl->max_load = gl->load;
+ sdl->busiest = *gl;
+ }
+ }
+}
+
/*
* find_busiest_group finds and returns the busiest CPU group within the
* domain. It calculates and returns the amount of weighted load which

--
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/