Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762857AbYALAFZ (ORCPT ); Fri, 11 Jan 2008 19:05:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759020AbYALAFK (ORCPT ); Fri, 11 Jan 2008 19:05:10 -0500 Received: from smtp3-g19.free.fr ([212.27.42.29]:50536 "EHLO smtp3-g19.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756873AbYALAFI (ORCPT ); Fri, 11 Jan 2008 19:05:08 -0500 Date: Sat, 12 Jan 2008 01:03:53 +0100 From: Guillaume Chazarain To: Ingo Molnar Cc: David Dillow , linux-kernel@vger.kernel.org, linux-btrace@vger.kernel.org, tglx@linutronix.de, Jens Axboe , nigel@suspend2.net Subject: Re: CONFIG_NO_HZ breaks blktrace timestamps Message-ID: <20080112010353.0eeb18bf@inria.fr> In-Reply-To: <20080111233025.57d17f6a@inria.fr> References: <1199918912.8388.13.camel@lap75545.ornl.gov> <1199996752.9159.46.camel@lap75545.ornl.gov> <20080110234438.4826f658@inria.fr> <20080111114132.084036f2@cheypa.inria.fr> <20080111105534.GC1589@elte.hu> <20080111233025.57d17f6a@inria.fr> X-Mailer: Claws Mail 3.2.0 (GTK+ 2.12.3; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2487 Lines: 80 Guillaume Chazarain wrote: > FYI, I'm currently trying to track down where rq->clock started to > overflow with nohz=off, and it seems to be before 2.6.23, so my patches > are not at fault ;-) Or maybe I am dreaming and it was always > overflowing. Investigating ... And the winner is: commit 529c77261bccd9d37f110f58b0753d95beaa9fa2 Author: Ingo Molnar 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 Signed-off-by: Arjan van de Ven 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/