Re: CONFIG_NO_HZ breaks blktrace timestamps

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: David Dillow <dillowda@...>, <linux-kernel@...>, <linux-btrace@...>, <tglx@...>, Jens Axboe <jens.axboe@...>, <nigel@...>
Date: Friday, January 11, 2008 - 8:03 pm

Guillaume Chazarain <guichaz@yahoo.fr> wrote:


And the winner is:

commit 529c77261bccd9d37f110f58b0753d95beaa9fa2
Author: Ingo Molnar <mingo@elte.hu>
Date:   Fri Aug 10 23:05:11 2007 +0200

    sched: improve rq-clock overflow logic
    
    improve the rq-clock overflow logic: limit the absolute rq->clock
    delta since the last scheduler tick, instead of limiting the delta
    itself.
    
    tested by Arjan van de Ven - whole laptop was misbehaving due to
    an incorrectly calibrated cpu_khz confusing sched_clock().
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>

diff --git a/kernel/sched.c b/kernel/sched.c
index b0afd8d..6247e4a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -263,6 +263,7 @@ struct rq {
 
 	unsigned int clock_warps, clock_overflows;
 	unsigned int clock_unstable_events;
+	u64 tick_timestamp;
 
 	atomic_t nr_iowait;
 
@@ -341,8 +342,11 @@ static void __update_rq_clock(struct rq *rq)
 		/*
 		 * Catch too large forward jumps too:
 		 */
-		if (unlikely(delta > 2*TICK_NSEC)) {
-			clock++;
+		if (unlikely(clock + delta > rq->tick_timestamp + TICK_NSEC)) {
+			if (clock < rq->tick_timestamp + TICK_NSEC)
+				clock = rq->tick_timestamp + TICK_NSEC;
+			else
+				clock++;
 			rq->clock_overflows++;
 		} else {
 			if (unlikely(delta > rq->clock_max_delta))
@@ -3308,9 +3312,16 @@ void scheduler_tick(void)
 	int cpu = smp_processor_id();
 	struct rq *rq = cpu_rq(cpu);
 	struct task_struct *curr = rq->curr;
+	u64 next_tick = rq->tick_timestamp + TICK_NSEC;
 
 	spin_lock(&rq->lock);
 	__update_rq_clock(rq);
+	/*
+	 * Let rq->clock advance by at least TICK_NSEC:
+	 */
+	if (unlikely(rq->clock < next_tick))
+		rq->clock = next_tick;
+	rq->tick_timestamp = rq->clock;
 	update_cpu_load(rq);
 	if (curr != rq->idle) /* FIXME: needed? */
 		curr->sched_class->task_tick(rq, curr);


Seems like I originally was not the only one seeing 2 jiffies jumps ;-)
I'll adapt my patches.

-- 
Guillaume
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
CONFIG_NO_HZ breaks blktrace timestamps, David Dillow, (Wed Jan 9, 6:48 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, David Dillow, (Thu Jan 10, 4:25 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:34 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, David Dillow, (Fri Jan 11, 11:43 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Guillaume Chazarain, (Thu Jan 10, 6:44 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Guillaume Chazarain, (Fri Jan 11, 6:41 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 6:55 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Guillaume Chazarain, (Fri Jan 11, 6:30 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Guillaume Chazarain, (Fri Jan 11, 8:03 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, David Dillow, (Thu Jan 10, 11:04 pm)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:44 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:51 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Jens Axboe, (Fri Jan 11, 5:07 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:32 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:23 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:29 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Jens Axboe, (Fri Jan 11, 5:34 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Jens Axboe, (Fri Jan 11, 5:25 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Ingo Molnar, (Fri Jan 11, 5:42 am)
Re: CONFIG_NO_HZ breaks blktrace timestamps, Jens Axboe, (Fri Jan 11, 5:56 am)
[patch] block: fix blktrace timestamps, Ingo Molnar, (Fri Jan 11, 6:29 am)
Re: [patch] block: fix blktrace timestamps, David Dillow, (Fri Jan 11, 11:36 am)
Re: [patch] block: fix blktrace timestamps, Ingo Molnar, (Fri Jan 11, 12:44 pm)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Fri Jan 11, 1:26 pm)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Fri Jan 11, 8:28 am)
Re: [patch] block: fix blktrace timestamps, Ingo Molnar, (Fri Jan 11, 9:21 am)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Fri Jan 11, 1:18 pm)
Re: [patch] block: fix blktrace timestamps, Ingo Molnar, (Mon Jan 14, 3:51 am)
Re: [patch] block: fix blktrace timestamps, Christoph Hellwig, (Mon Jan 14, 4:39 am)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Mon Jan 14, 4:42 am)
Re: [patch] block: fix blktrace timestamps, Ingo Molnar, (Mon Jan 14, 3:59 am)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Mon Jan 14, 4:10 am)
Re: [patch] block: fix blktrace timestamps, Jens Axboe, (Fri Jan 11, 8:42 am)
Re: [patch] block: fix blktrace timestamps, Guillaume Chazarain, (Fri Jan 11, 6:47 am)
Re: [patch] block: fix blktrace timestamps, Ingo Molnar, (Fri Jan 11, 6:50 am)