diff for duplicates of <480918B0.2070800@windriver.com> diff --git a/a/1.txt b/N1/1.txt index 1326808..6fa7a9e 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -42,95 +42,3 @@ 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 diff --git a/a/content_digest b/N1/content_digest index 260037e..586e851 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -60,98 +60,6 @@ "loops through the single step test as it is it can definitely catch\n" "things :-)\n" "\n" - "Jason.\n" - "\n" - "\n" - ">From 84556fe84dd975161e70b782d7d7cc7bd080c06a Mon Sep 17 00:00:00 2001\n" - "From: Ingo Molnar <mingo@elte.hu>\n" - "Date: Thu, 28 Feb 2008 21:00:21 +0100\n" - "Subject: [PATCH 0883/1078] sched: make cpu_clock() globally synchronous\n" - "\n" - "Alexey Zaytsev reported (and bisected) that the introduction of\n" - "cpu_clock() in printk made the timestamps jump back and forth.\n" - "\n" - "Make cpu_clock() more reliable while still keeping it fast when it's\n" - "called frequently.\n" - "\n" - "Signed-off-by: Ingo Molnar <mingo@elte.hu>\n" - "---\n" - " kernel/sched.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---\n" - " 1 files changed, 49 insertions(+), 3 deletions(-)\n" - "\n" - "diff --git a/kernel/sched.c b/kernel/sched.c\n" - "index 8dcdec6..7377222 100644\n" - "--- a/kernel/sched.c\n" - "+++ b/kernel/sched.c\n" - "@@ -632,11 +632,39 @@ int sysctl_sched_rt_runtime = 950000;\n" - " */\n" - " #define RUNTIME_INF ((u64)~0ULL)\n" - " \n" - "+static const unsigned long long time_sync_thresh = 100000;\n" - "+\n" - "+static DEFINE_PER_CPU(unsigned long long, time_offset);\n" - "+static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);\n" - "+\n" - " /*\n" - "- * For kernel-internal use: high-speed (but slightly incorrect) per-cpu\n" - "- * clock constructed from sched_clock():\n" - "+ * Global lock which we take every now and then to synchronize\n" - "+ * the CPUs time. This method is not warp-safe, but it's good\n" - "+ * enough to synchronize slowly diverging time sources and thus\n" - "+ * it's good enough for tracing:\n" - " */\n" - "-unsigned long long cpu_clock(int cpu)\n" - "+static DEFINE_SPINLOCK(time_sync_lock);\n" - "+static unsigned long long prev_global_time;\n" - "+\n" - "+static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)\n" - "+{\n" - "+ unsigned long flags;\n" - "+\n" - "+ spin_lock_irqsave(&time_sync_lock, flags);\n" - "+\n" - "+ if (time < prev_global_time) {\n" - "+ per_cpu(time_offset, cpu) += prev_global_time - time;\n" - "+ time = prev_global_time;\n" - "+ } else {\n" - "+ prev_global_time = time;\n" - "+ }\n" - "+\n" - "+ spin_unlock_irqrestore(&time_sync_lock, flags);\n" - "+\n" - "+ return time;\n" - "+}\n" - "+\n" - "+static unsigned long long __cpu_clock(int cpu)\n" - " {\n" - " unsigned long long now;\n" - " unsigned long flags;\n" - "@@ -657,6 +685,24 @@ unsigned long long cpu_clock(int cpu)\n" - " \n" - " return now;\n" - " }\n" - "+\n" - "+/*\n" - "+ * For kernel-internal use: high-speed (but slightly incorrect) per-cpu\n" - "+ * clock constructed from sched_clock():\n" - "+ */\n" - "+unsigned long long cpu_clock(int cpu)\n" - "+{\n" - "+ unsigned long long prev_cpu_time, time, delta_time;\n" - "+\n" - "+ prev_cpu_time = per_cpu(prev_cpu_time, cpu);\n" - "+ time = __cpu_clock(cpu) + per_cpu(time_offset, cpu);\n" - "+ delta_time = time-prev_cpu_time;\n" - "+\n" - "+ if (unlikely(delta_time > time_sync_thresh))\n" - "+ time = __sync_cpu_clock(time, cpu);\n" - "+\n" - "+ return time;\n" - "+}\n" - " EXPORT_SYMBOL_GPL(cpu_clock);\n" - " \n" - " #ifndef prepare_arch_switch\n" - "-- \n" - 1.5.5 + Jason. -2cab94c1bc9e8d31daae70b3a3416aab29c20d4b72b0a61e0197c8cff72ec4d2 +434b96653ce919b79011ac6fdd33c7460b67d1c9d2372f2262482b246f8365b9
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.