* [RFC] sched: update rq clock when only get preempt
@ 2013-12-30 3:14 Lei Wen
2013-12-30 4:08 ` Mike Galbraith
0 siblings, 1 reply; 3+ messages in thread
From: Lei Wen @ 2013-12-30 3:14 UTC (permalink / raw)
To: linux-kernel, Peter Zijlstra, Ingo Molnar, leiwen
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@marvell.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC] sched: update rq clock when only get preempt
2013-12-30 3:14 [RFC] sched: update rq clock when only get preempt Lei Wen
@ 2013-12-30 4:08 ` Mike Galbraith
2013-12-30 4:56 ` Lei Wen
0 siblings, 1 reply; 3+ messages in thread
From: Mike Galbraith @ 2013-12-30 4:08 UTC (permalink / raw)
To: Lei Wen; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, leiwen
On Mon, 2013-12-30 at 11:14 +0800, Lei Wen wrote:
> 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.
> @@ -2555,6 +2556,8 @@ need_resched:
> idle_balance(cpu, rq);
>
> put_prev_task(rq, prev);
> + if (update)
> + update_rq_clock(rq);
If prev remained enqueued, the clock was updated by put_prev_task().
-Mike
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] sched: update rq clock when only get preempt
2013-12-30 4:08 ` Mike Galbraith
@ 2013-12-30 4:56 ` Lei Wen
0 siblings, 0 replies; 3+ messages in thread
From: Lei Wen @ 2013-12-30 4:56 UTC (permalink / raw)
To: Mike Galbraith; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, leiwen
Hi Mike,
On Mon, Dec 30, 2013 at 12:08 PM, Mike Galbraith <bitbucket@online.de> wrote:
> On Mon, 2013-12-30 at 11:14 +0800, Lei Wen wrote:
>> 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.
>
>> @@ -2555,6 +2556,8 @@ need_resched:
>> idle_balance(cpu, rq);
>>
>> put_prev_task(rq, prev);
>> + if (update)
>> + update_rq_clock(rq);
>
> If prev remained enqueued, the clock was updated by put_prev_task().
It indeed like that, sorry for the noise...
Thanks,
Lei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-30 4:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-30 3:14 [RFC] sched: update rq clock when only get preempt Lei Wen
2013-12-30 4:08 ` Mike Galbraith
2013-12-30 4:56 ` Lei Wen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.