内核/排程/ fair.c
static inline void __update_task_entity_contrib(struct sched_entity *se)
{
u32 contrib;
/* avoid overflowing a 32-bit type w/ SCHED_LOAD_SCALE */
contrib = se->avg.runnable_avg_sum * scale_load_down(se->load.weight);
contrib /= (se->avg.runnable_avg_period + 1);
se->avg.load_avg_contrib = scale_load(contrib);
trace_sched_task_load_contrib(task_of(se), se->avg.load_avg_contrib);
contrib = se->avg.runnable_avg_sum * scale_load_down(NICE_0_LOAD);
contrib /= (se->avg.runnable_avg_period + 1);
.....
此代码计算以下等式。
runnable_avg_sum
load_avg_contrib = ----------------------------- * weight
runnable_avg_period + 1
和
runnable_avg_sum
load_avg_ratio = ----------------------------- * NICE_0_LOAD
runnable_avg_period + 1
我们为什么要在这个等式中使用runnable_avg_period + 1
?
为什么我们不能使用runnable_avg_period
?