Re: 2.6.25-mm1: not looking good

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jason Wessel
Date: Friday, April 18, 2008 - 2:54 pm

Ingo Molnar wrote:

So I pulled your tree and I would agree there was a problem.  But it
seems unrelated to kgdb.  I bisected the tree because it worked starting
with the kgdb-light merge. 

It fails once with the patch below, but it is not clear as to why other
than the lock must have something to do with it.

I'll submit a patch to the kgdb test suite to increase the amount of
loops through the single step test as it is it can definitely catch
things :-)

Jason.


From 84556fe84dd975161e70b782d7d7cc7bd080c06a Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Thu, 28 Feb 2008 21:00:21 +0100
Subject: [PATCH 0883/1078] sched: make cpu_clock() globally synchronous

Alexey Zaytsev reported (and bisected) that the introduction of
cpu_clock() in printk made the timestamps jump back and forth.

Make cpu_clock() more reliable while still keeping it fast when it's
called frequently.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 8dcdec6..7377222 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -632,11 +632,39 @@ int sysctl_sched_rt_runtime = 950000;
  */
 #define RUNTIME_INF    ((u64)~0ULL)
 
+static const unsigned long long time_sync_thresh = 100000;
+
+static DEFINE_PER_CPU(unsigned long long, time_offset);
+static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);
+
 /*
- * For kernel-internal use: high-speed (but slightly incorrect) per-cpu
- * clock constructed from sched_clock():
+ * Global lock which we take every now and then to synchronize
+ * the CPUs time. This method is not warp-safe, but it's good
+ * enough to synchronize slowly diverging time sources and thus
+ * it's good enough for tracing:
  */
-unsigned long long cpu_clock(int cpu)
+static DEFINE_SPINLOCK(time_sync_lock);
+static unsigned long long prev_global_time;
+
+static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)
+{
+    unsigned long flags;
+
+    spin_lock_irqsave(&time_sync_lock, flags);
+
+    if (time < prev_global_time) {
+        per_cpu(time_offset, cpu) += prev_global_time - time;
+        time = prev_global_time;
+    } else {
+        prev_global_time = time;
+    }
+
+    spin_unlock_irqrestore(&time_sync_lock, flags);
+
+    return time;
+}
+
+static unsigned long long __cpu_clock(int cpu)
 {
     unsigned long long now;
     unsigned long flags;
@@ -657,6 +685,24 @@ unsigned long long cpu_clock(int cpu)
 
     return now;
 }
+
+/*
+ * For kernel-internal use: high-speed (but slightly incorrect) per-cpu
+ * clock constructed from sched_clock():
+ */
+unsigned long long cpu_clock(int cpu)
+{
+    unsigned long long prev_cpu_time, time, delta_time;
+
+    prev_cpu_time = per_cpu(prev_cpu_time, cpu);
+    time = __cpu_clock(cpu) + per_cpu(time_offset, cpu);
+    delta_time = time-prev_cpu_time;
+
+    if (unlikely(delta_time > time_sync_thresh))
+        time = __sync_cpu_clock(time, cpu);
+
+    return time;
+}
 EXPORT_SYMBOL_GPL(cpu_clock);
 
 #ifndef prepare_arch_switch
-- 
1.5.5


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

Messages in current thread:
2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 4:03 pm)
Re: 2.6.25-mm1: not looking good, Greg KH, (Thu Apr 17, 4:24 pm)
Re: 2.6.25-mm1: not looking good, Dan Williams, (Thu Apr 17, 4:24 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 4:40 pm)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Thu Apr 17, 4:55 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 5:04 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 5:14 pm)
Re: 2.6.25-mm1: not looking good, Kay Sievers, (Thu Apr 17, 5:48 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 6:12 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 6:35 pm)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Thu Apr 17, 8:05 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 9:07 pm)
Re: 2.6.25-mm1: not looking good, Arjan van de Ven, (Thu Apr 17, 10:49 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 11:10 pm)
Re: 2.6.25-mm1: not looking good, Pekka Enberg, (Thu Apr 17, 11:40 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 11:56 pm)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 12:09 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 12:19 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 12:24 am)
Re: 2.6.25-mm1: not looking good, Pekka Enberg, (Fri Apr 18, 12:25 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 12:28 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 12:37 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 12:50 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 12:53 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 12:57 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 2:22 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 2:28 am)
Re: 2.6.25-mm1: not looking good, Pavel Machek, (Fri Apr 18, 2:42 am)
Re: 2.6.25-mm1: not looking good, James Morris, (Fri Apr 18, 3:32 am)
Re: 2.6.25-mm1: not looking good, Pavel Machek, (Fri Apr 18, 4:07 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 4:46 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 5:18 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 5:34 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 5:41 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 6:02 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 6:22 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 6:27 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 7:47 am)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Fri Apr 18, 7:55 am)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Fri Apr 18, 7:57 am)
Re: 2.6.25-mm1: not looking good, Alan Stern, (Fri Apr 18, 8:22 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 9:02 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 2:54 pm)
2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Mon Apr 28, 9:42 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Andrew Morton, (Mon Apr 28, 9:59 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Bartlomiej Zolnierki ..., (Mon Apr 28, 11:44 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 2:39 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 2:43 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 8:49 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 9:58 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Bartlomiej Zolnierki ..., (Tue Apr 29, 2:37 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Wed Apr 30, 4:16 am)