From: byungchul.park@lge.com
To: mingo@kernel.org, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, pjt@google.com,
Byungchul Park <byungchul.park@lge.com>
Subject: [PATCH] sched: make decaying sched_avg's variables happen on period boundary
Date: Tue, 7 Jul 2015 14:42:56 +0900 [thread overview]
Message-ID: <1436247776-30946-1-git-send-email-byungchul.park@lge.com> (raw)
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
next reply other threads:[~2015-07-07 5:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 5:42 byungchul.park [this message]
2015-07-07 22:54 ` Peter Zijlstra
2015-07-08 0:22 ` Byungchul Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436247776-30946-1-git-send-email-byungchul.park@lge.com \
--to=byungchul.park@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®