All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Matt Mackall <mpm@selenic.com>
Cc: Dmitry Adamushko <dmitry.adamushko@gmail.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Interesting interaction between lguest and CFS
Date: Fri, 8 Jun 2007 12:18:43 +0200	[thread overview]
Message-ID: <20070608101843.GA2381@elte.hu> (raw)
In-Reply-To: <20070608093429.GA22699@elte.hu>


* Ingo Molnar <mingo@elte.hu> wrote:

> thanks. It shows the anomaly in action:

> So all the time references we have show that (no surprise here) 1 
> second passed between the two samples. But sched_clock() shows a 
> _large_ jump:
> 
>   .clock                 : 125652924079659272
>   .clock                 : 125653018059166371
> 
> also reflected in .clock_max_delta:
> 
>   .clock_max_delta       : 92976502936
> 
> that's a 93 seconds jump (!) in a single 1-second sample. [...]

we also had a similar jump in exec_clock, which suggests that the 
sched_clock() "jump" occured while there was a task running. (i.e. not 
during ACPI-C2/C3) Could you try the patch below? It should catch such 
large jumps. The 'clock_overflows' counter in /proc/sched_debug will 
show whether this new protection triggered on your box.

	Ingo

Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -149,12 +149,12 @@ struct rq {
 
 	u64 clock, prev_clock_raw;
 	s64 clock_max_delta;
-	u64 fair_clock, prev_fair_clock;
-	u64 exec_clock, prev_exec_clock;
+	u64 fair_clock, prev_fair_clock;
+	u64 exec_clock, prev_exec_clock;
 	s64 wait_runtime;
 	unsigned long wait_runtime_overruns, wait_runtime_underruns;
 
-	unsigned int clock_warps;
+	unsigned int clock_warps, clock_overflows;
 	unsigned int clock_unstable_events;
 
 	struct sched_class *load_balance_class;
@@ -245,9 +245,17 @@ static inline unsigned long long __rq_cl
 		clock++;
 		rq->clock_warps++;
 	} else {
-		if (unlikely(delta > rq->clock_max_delta))
-			rq->clock_max_delta = delta;
-		clock += delta;
+		/*
+		 * Catch too large forward jumps too:
+		 */
+		if (delta > 2*TICK_NSEC) {
+			clock++;
+			rq->clock_overflows++;
+		} else {
+			if (unlikely(delta > rq->clock_max_delta))
+				rq->clock_max_delta = delta;
+			clock += delta;
+		}
 	}
 
 	rq->prev_clock_raw = now;
Index: linux/kernel/sched_debug.c
===================================================================
--- linux.orig/kernel/sched_debug.c
+++ linux/kernel/sched_debug.c
@@ -117,13 +119,13 @@ static void print_cpu(struct seq_file *m
 	P(clock);
 	P(prev_clock_raw);
 	P(clock_warps);
+	P(clock_overflows);
 	P(clock_unstable_events);
 	P(clock_max_delta);
-	rq->clock_max_delta = 0;
 	P(fair_clock);
-	P(prev_fair_clock);
+	P(prev_fair_clock);
 	P(exec_clock);
-	P(prev_exec_clock);
+	P(prev_exec_clock);
 	P(wait_runtime);
 	P(wait_runtime_overruns);
 	P(wait_runtime_underruns);

  reply	other threads:[~2007-06-08 10:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-04 17:37 Interesting interaction between lguest and CFS Matt Mackall
2007-06-04 17:54 ` Ingo Molnar
2007-06-04 18:41   ` Matt Mackall
2007-06-05  7:19     ` Ingo Molnar
2007-06-05 14:03       ` Matt Mackall
2007-06-05 15:14         ` Dmitry Adamushko
2007-06-05 15:41           ` Dmitry Adamushko
2007-06-05 19:50             ` Ingo Molnar
2007-06-06 20:23               ` Matt Mackall
2007-06-08  9:34                 ` Ingo Molnar
2007-06-08 10:18                   ` Ingo Molnar [this message]
2007-06-04 18:11 ` Ingo Molnar
2007-06-04 18:42   ` Matt Mackall
2007-06-04 19:12     ` Ingo Molnar
2007-06-04 19:27       ` Matt Mackall
2007-06-04 19:40         ` Ingo Molnar
2007-06-04 19:59           ` Matt Mackall
2007-06-04 20:13             ` Ingo Molnar
2007-06-04 20:20               ` Ingo Molnar
2007-06-04 20:15   ` James Morris
2007-06-04 20:24     ` Ingo Molnar
2007-06-04 22:58 ` Olof Johansson
2007-06-05  1:02   ` Rusty Russell
2007-06-05  1:24     ` Stephen Rothwell
2007-06-05  2:23     ` Olof Johansson
2007-06-05  0:18 ` Rusty Russell
2007-06-05  2:31   ` Rusty Russell
2007-06-05  4:18     ` Matt Mackall
2007-06-05  4:37       ` Rusty Russell
2007-06-05 13:49         ` Matt Mackall
2007-06-05 19:38           ` Ingo Molnar
2007-06-05 10:43       ` Ingo Molnar
2007-06-05 19:08         ` Ingo Molnar
2007-06-06 20:19           ` Matt Mackall
2007-06-05  2:34   ` Matt Mackall
2007-06-05  7:10   ` Ingo Molnar
2007-06-05  9:23 ` Ingo Molnar
2007-06-05 14:06   ` Matt Mackall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070608101843.GA2381@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=dmitry.adamushko@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.