[RFC] sched: update rq clock when only get preempt
From: Lei Wen
Date: Sun Dec 29 2013 - 22:14:16 EST
Since we would update rq clock at task enqueue/dequeue, or schedule
tick. If we don't update the rq clock when our previous task get
preempted, our new started task would get a relative stale rq clock
which is updated during the previous task enqueue, or the last schedule
clock update.
If we want more precise account for the task start and duration time,
we'd better ensure rq clock get updated when it begin to run.
Best regards,
Lei
Signed-off-by: Lei Wen <leiwen@xxxxxxxxxxx>
---
kernel/sched/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a88f4a4..50e91b6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2503,7 +2503,7 @@ static void __sched __schedule(void)
struct task_struct *prev, *next;
unsigned long *switch_count;
struct rq *rq;
- int cpu;
+ int cpu, update = 1;
need_resched:
preempt_disable();
@@ -2530,6 +2530,7 @@ need_resched:
if (unlikely(signal_pending_state(prev->state, prev))) {
prev->state = TASK_RUNNING;
} else {
+ update = 0;
deactivate_task(rq, prev, DEQUEUE_SLEEP);
prev->on_rq = 0;
@@ -2555,6 +2556,8 @@ need_resched:
idle_balance(cpu, rq);
put_prev_task(rq, prev);
+ if (update)
+ update_rq_clock(rq);
next = pick_next_task(rq);
clear_tsk_need_resched(prev);
clear_preempt_need_resched();
--
1.8.3.2
--
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/