diff options
author | Paul Turner <pjt@google.com> | 2012-10-04 07:18:29 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-10-24 04:27:18 -0400 |
commit | 9d85f21c94f7f7a84d0ba686c58aa6d9da58fdbb (patch) | |
tree | bec53516fbe39007b12250423b7a09e7b62184c3 /include | |
parent | 0e9e3e306c7e472bdcffa34c4c4584301eda03b3 (diff) |
sched: Track the runnable average on a per-task entity basis
Instead of tracking averaging the load parented by a cfs_rq, we can track
entity load directly. With the load for a given cfs_rq then being the sum
of its children.
To do this we represent the historical contribution to runnable average
within each trailing 1024us of execution as the coefficients of a
geometric series.
We can express this for a given task t as:
runnable_sum(t) = \Sum u_i * y^i, runnable_avg_period(t) = \Sum 1024 * y^i
load(t) = weight_t * runnable_sum(t) / runnable_avg_period(t)
Where: u_i is the usage in the last i`th 1024us period (approximately 1ms)
~ms and y is chosen such that y^k = 1/2. We currently choose k to be 32 which
roughly translates to about a sched period.
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.372695337@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/sched.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0dd42a02df2e..418fc6d8a4da 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1095,6 +1095,16 @@ struct load_weight { | |||
1095 | unsigned long weight, inv_weight; | 1095 | unsigned long weight, inv_weight; |
1096 | }; | 1096 | }; |
1097 | 1097 | ||
1098 | struct sched_avg { | ||
1099 | /* | ||
1100 | * These sums represent an infinite geometric series and so are bound | ||
1101 | * above by 1024/(1-y). Thus we only need a u32 to store them for for all | ||
1102 | * choices of y < 1-2^(-32)*1024. | ||
1103 | */ | ||
1104 | u32 runnable_avg_sum, runnable_avg_period; | ||
1105 | u64 last_runnable_update; | ||
1106 | }; | ||
1107 | |||
1098 | #ifdef CONFIG_SCHEDSTATS | 1108 | #ifdef CONFIG_SCHEDSTATS |
1099 | struct sched_statistics { | 1109 | struct sched_statistics { |
1100 | u64 wait_start; | 1110 | u64 wait_start; |
@@ -1155,6 +1165,9 @@ struct sched_entity { | |||
1155 | /* rq "owned" by this entity/group: */ | 1165 | /* rq "owned" by this entity/group: */ |
1156 | struct cfs_rq *my_q; | 1166 | struct cfs_rq *my_q; |
1157 | #endif | 1167 | #endif |
1168 | #ifdef CONFIG_SMP | ||
1169 | struct sched_avg avg; | ||
1170 | #endif | ||
1158 | }; | 1171 | }; |
1159 | 1172 | ||
1160 | struct sched_rt_entity { | 1173 | struct sched_rt_entity { |