[PATCH] sched: make decaying sched_avg's variables happen on period boundary
From: byungchul . park
Date: Tue Jul 07 2015 - 01:46:06 EST
From: Byungchul Park <byungchul.park@xxxxxxx>
decaying time happens on every period boundary. if it does not reach
the period boundary yet, the partial time needs to be kept so that
the time can be decayed on exactly period boundary at next update.
sa->avg_period is not appropriate for getting partial delta_w because
the value is a decayed average value, with which we cannnot get partial
delta at all which does not reach the period boundary yet.
Signed-off-by: Byungchul Park <byungchul.park@xxxxxxx>
---
include/linux/sched.h | 6 ++++++
kernel/sched/fair.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8aa4a25..2fdea70 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1192,6 +1192,12 @@ struct sched_avg {
* running_avg_sum.
*/
u32 runnable_avg_sum, avg_period, running_avg_sum;
+ /*
+ * decaying time happens on every period boundary. if it does not reach
+ * the period boundary yet, the partial time needs to be kept so that
+ * the time can be decayed on exactly period boundary at next update.
+ */
+ u32 last_delta;
};
#ifdef CONFIG_SCHEDSTATS
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 09456fc..54ca11e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -680,6 +680,7 @@ void init_task_runnable_average(struct task_struct *p)
slice = sched_slice(task_cfs_rq(p), &p->se) >> 10;
p->se.avg.runnable_avg_sum = p->se.avg.running_avg_sum = slice;
p->se.avg.avg_period = slice;
+ p->se.avg.last_delta = 0;
__update_task_entity_contrib(&p->se);
__update_task_entity_utilization(&p->se);
}
@@ -2576,7 +2577,7 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
sa->last_runnable_update = now;
/* delta_w is the amount already accumulated against our next period */
- delta_w = sa->avg_period % 1024;
+ delta_w = sa->last_delta % 1024;
if (delta + delta_w >= 1024) {
/* period roll-over */
decayed = 1;
@@ -2624,6 +2625,7 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
sa->running_avg_sum += delta * scale_freq
>> SCHED_CAPACITY_SHIFT;
sa->avg_period += delta;
+ sa->last_delta = delta;
return decayed;
}
--
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/