aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Turner <pjt@google.com>2012-10-04 07:18:30 -0400
committerIngo Molnar <mingo@kernel.org>2012-10-24 04:27:24 -0400
commitc566e8e9e44b72b53091da20e2dedefc730f2ee2 (patch)
tree3e86db8843021c36b41362063183d1135fda63db
parentaff3e498844441fa71c5ee1bbc470e1dff9548d9 (diff)
sched: Aggregate total task_group load
Maintain a global running sum of the average load seen on each cfs_rq belonging to each task group so that it may be used in calculating an appropriate shares:weight distribution. Signed-off-by: Paul Turner <pjt@google.com> Reviewed-by: Ben Segall <bsegall@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120823141506.792901086@google.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--kernel/sched/debug.c4
-rw-r--r--kernel/sched/fair.c22
-rw-r--r--kernel/sched/sched.h4
3 files changed, 30 insertions, 0 deletions
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 2d2e2b3c1bef..290892361a09 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -230,6 +230,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
230 cfs_rq->runnable_load_avg); 230 cfs_rq->runnable_load_avg);
231 SEQ_printf(m, " .%-30s: %lld\n", "blocked_load_avg", 231 SEQ_printf(m, " .%-30s: %lld\n", "blocked_load_avg",
232 cfs_rq->blocked_load_avg); 232 cfs_rq->blocked_load_avg);
233 SEQ_printf(m, " .%-30s: %ld\n", "tg_load_avg",
234 atomic64_read(&cfs_rq->tg->load_avg));
235 SEQ_printf(m, " .%-30s: %lld\n", "tg_load_contrib",
236 cfs_rq->tg_load_contrib);
233#endif 237#endif
234 238
235 print_cfs_group_stats(m, cpu, cfs_rq->tg); 239 print_cfs_group_stats(m, cpu, cfs_rq->tg);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 74dc29ba1ad1..db788222f198 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1102,6 +1102,26 @@ static inline u64 __synchronize_entity_decay(struct sched_entity *se)
1102 return decays; 1102 return decays;
1103} 1103}
1104 1104
1105#ifdef CONFIG_FAIR_GROUP_SCHED
1106static inline void __update_cfs_rq_tg_load_contrib(struct cfs_rq *cfs_rq,
1107 int force_update)
1108{
1109 struct task_group *tg = cfs_rq->tg;
1110 s64 tg_contrib;
1111
1112 tg_contrib = cfs_rq->runnable_load_avg + cfs_rq->blocked_load_avg;
1113 tg_contrib -= cfs_rq->tg_load_contrib;
1114
1115 if (force_update || abs64(tg_contrib) > cfs_rq->tg_load_contrib / 8) {
1116 atomic64_add(tg_contrib, &tg->load_avg);
1117 cfs_rq->tg_load_contrib += tg_contrib;
1118 }
1119}
1120#else
1121static inline void __update_cfs_rq_tg_load_contrib(struct cfs_rq *cfs_rq,
1122 int force_update) {}
1123#endif
1124
1105/* Compute the current contribution to load_avg by se, return any delta */ 1125/* Compute the current contribution to load_avg by se, return any delta */
1106static long __update_entity_load_avg_contrib(struct sched_entity *se) 1126static long __update_entity_load_avg_contrib(struct sched_entity *se)
1107{ 1127{
@@ -1172,6 +1192,8 @@ static void update_cfs_rq_blocked_load(struct cfs_rq *cfs_rq, int force_update)
1172 atomic64_add(decays, &cfs_rq->decay_counter); 1192 atomic64_add(decays, &cfs_rq->decay_counter);
1173 cfs_rq->last_decay = now; 1193 cfs_rq->last_decay = now;
1174 } 1194 }
1195
1196 __update_cfs_rq_tg_load_contrib(cfs_rq, force_update);
1175} 1197}
1176 1198
1177static inline void update_rq_runnable_avg(struct rq *rq, int runnable) 1199static inline void update_rq_runnable_avg(struct rq *rq, int runnable)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 30236ab4edc0..924a99094888 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -112,6 +112,7 @@ struct task_group {
112 unsigned long shares; 112 unsigned long shares;
113 113
114 atomic_t load_weight; 114 atomic_t load_weight;
115 atomic64_t load_avg;
115#endif 116#endif
116 117
117#ifdef CONFIG_RT_GROUP_SCHED 118#ifdef CONFIG_RT_GROUP_SCHED
@@ -232,6 +233,9 @@ struct cfs_rq {
232 u64 runnable_load_avg, blocked_load_avg; 233 u64 runnable_load_avg, blocked_load_avg;
233 atomic64_t decay_counter, removed_load; 234 atomic64_t decay_counter, removed_load;
234 u64 last_decay; 235 u64 last_decay;
236#ifdef CONFIG_FAIR_GROUP_SCHED
237 u64 tg_load_contrib;
238#endif
235#endif 239#endif
236#ifdef CONFIG_FAIR_GROUP_SCHED 240#ifdef CONFIG_FAIR_GROUP_SCHED
237 struct rq *rq; /* cpu runqueue to which this cfs_rq is attached */ 241 struct rq *rq; /* cpu runqueue to which this cfs_rq is attached */