* [PATCH] sched: make decaying sched_avg's variables happen on period boundary
@ 2015-07-07 5:42 byungchul.park
2015-07-07 22:54 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: byungchul.park @ 2015-07-07 5:42 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, pjt, Byungchul Park
From: Byungchul Park <byungchul.park@lge.com>
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@lge.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: make decaying sched_avg's variables happen on period boundary
2015-07-07 5:42 [PATCH] sched: make decaying sched_avg's variables happen on period boundary byungchul.park
@ 2015-07-07 22:54 ` Peter Zijlstra
2015-07-08 0:22 ` Byungchul Park
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2015-07-07 22:54 UTC (permalink / raw)
To: byungchul.park; +Cc: mingo, linux-kernel, pjt
On Tue, Jul 07, 2015 at 02:42:56PM +0900, byungchul.park@lge.com wrote:
> From: Byungchul Park <byungchul.park@lge.com>
>
> 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.
lkml.kernel.org/r/1435018085-7004-1-git-send-email-yuyang.du@intel.com
There is a comprehensive rewrite of all this under consideration.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: make decaying sched_avg's variables happen on period boundary
2015-07-07 22:54 ` Peter Zijlstra
@ 2015-07-08 0:22 ` Byungchul Park
0 siblings, 0 replies; 3+ messages in thread
From: Byungchul Park @ 2015-07-08 0:22 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: mingo, linux-kernel, pjt
On Wed, Jul 08, 2015 at 12:54:30AM +0200, Peter Zijlstra wrote:
> On Tue, Jul 07, 2015 at 02:42:56PM +0900, byungchul.park@lge.com wrote:
> > From: Byungchul Park <byungchul.park@lge.com>
> >
> > 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.
>
> lkml.kernel.org/r/1435018085-7004-1-git-send-email-yuyang.du@intel.com
>
> There is a comprehensive rewrite of all this under consideration.
thank you, peter :)
i will check it.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-08 0:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07 5:42 [PATCH] sched: make decaying sched_avg's variables happen on period boundary byungchul.park
2015-07-07 22:54 ` Peter Zijlstra
2015-07-08 0:22 ` Byungchul Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox