From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: [PATCH] sched_clock: fix NOHZ interaction Date: Mon, 01 Sep 2008 16:58:08 +0200 Message-ID: <1220281088.8426.63.camel@twins> References: <48BABC19.1060509@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Ingo Molnar , linux-kernel , KVM list , Thomas Gleixner To: Avi Kivity Return-path: Received: from viefep18-int.chello.at ([213.46.255.22]:6764 "EHLO viefep18-int.chello.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbYIAO6u (ORCPT ); Mon, 1 Sep 2008 10:58:50 -0400 In-Reply-To: <48BABC19.1060509@qumranet.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi, the below fixes it for me.. --- Subject: sched_clock: fix NOHZ interaction From: Peter Zijlstra Date: Mon Sep 01 16:44:23 CEST 2008 If HLT stops the TSC, we'll fail to account idle time, thereby inflating the actual process times. Fix this by re-calibrating the clock against GTOD when leaving nohz mode. Signed-off-by: Peter Zijlstra --- kernel/time/tick-sched.c | 3 +++ 1 file changed, 3 insertions(+) Index: linux-2.6/kernel/time/tick-sched.c =================================================================== --- linux-2.6.orig/kernel/time/tick-sched.c +++ linux-2.6/kernel/time/tick-sched.c @@ -162,6 +162,8 @@ void tick_nohz_stop_idle(int cpu) ts->idle_lastupdate = now; ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); ts->idle_active = 0; + + sched_clock_idle_wakeup_event(0); } } @@ -177,6 +179,7 @@ static ktime_t tick_nohz_start_idle(stru } ts->idle_entrytime = now; ts->idle_active = 1; + sched_clock_idle_sleep_event(); return now; }