summaryrefslogtreecommitdiff
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
authorJoonwoo Park <joonwoop@codeaurora.org>2015-11-24 14:33:26 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:02:41 -0700
commit0498f793e89151acf85e237f64c8207bf9905bea (patch)
tree86916306bcb907ae8b8dd984bbb75ffaa000c16f /kernel/time/tick-sched.c
parentd2d5734feca085b4886476ac5f3d6da7ec40ca8e (diff)
sched: use ktime instead of sched_clock for load tracking
At present, HMP scheduler uses sched_clock to setup window boundary to be aligned with timer interrupt to ensure timer interrupt fires after window rollover. However this alignment won't last long since the timer interrupt rearms next timer based on time measured by ktime which isn't coupled with sched_clock. Convert sched_clock to ktime to avoid wallclock discrepancy between scheduler and timer so that we can ensure scheduler's window boundary is always aligned with timer. CRs-fixed: 933330 Change-Id: I4108819a4382f725b3ce6075eb46aab0cf670b7e [joonwoop@codeaurora.org: fixed minor conflict in include/linux/tick.h and kernel/sched/core.c. omitted fixes for kernel/sched/qhmp_core.c] Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index c1f3aca1a01d..89dcc6cafa07 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -46,32 +46,15 @@ static DEFINE_PER_CPU(struct tick_sched, tick_cpu_sched);
*/
static ktime_t last_jiffies_update;
-/*
- * Conversion from ktime to sched_clock is error prone. Use this
- * as a safetly margin when calculating the sched_clock value at
- * a particular jiffy as last_jiffies_update uses ktime.
- */
-#define SCHED_CLOCK_MARGIN 100000
-
-static u64 ns_since_jiffy(void)
-{
- ktime_t delta;
-
- delta = ktime_sub(ktime_get(), last_jiffies_update);
-
- return ktime_to_ns(delta);
-}
-
-u64 jiffy_to_sched_clock(u64 *now, u64 *jiffy_sched_clock)
+u64 jiffy_to_ktime_ns(u64 *now, u64 *jiffy_ktime_ns)
{
u64 cur_jiffies;
unsigned long seq;
do {
seq = read_seqbegin(&jiffies_lock);
- *now = sched_clock();
- *jiffy_sched_clock = *now -
- (ns_since_jiffy() + SCHED_CLOCK_MARGIN);
+ *now = ktime_get_ns();
+ *jiffy_ktime_ns = ktime_to_ns(last_jiffies_update);
cur_jiffies = get_jiffies_64();
} while (read_seqretry(&jiffies_lock, seq));