[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] When both stolen and blocked are rounded down, it is possible for the



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID de5d2b9a9cfb2a01d6abe22ff51ae8b47c1d8865
# Parent  a77cf8fdc307c9f248e9cfffa77745e827a2a923
When both stolen and blocked are rounded down, it is possible for the
final increment of the cpu local processed_system_time to move the cpu
local system time ahead a bit further than expected - but still proper
wrt. wall clock time.

This gives problems on a next timer interrupt, when stolen and blocked
both get rounded up and end up incrementing the per cpu
processed_system_time too far.

These simple checks make sure that the cpu local processed_system_time
never gets advanced too far.  Not advancing the variable now should be
fine, since we'll increment it at the next timer tick...

This patch has made the "time went backwards" error messages go away
completely.

Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r a77cf8fdc307 -r de5d2b9a9cfb 
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c  Tue Mar 14 14:45:00 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c  Tue Mar 14 15:00:16 2006
@@ -645,7 +645,7 @@
             unlikely(delta_cpu < -(s64)permitted_clock_jitter))
            && printk_ratelimit()) {
                printk("Timer ISR/%d: Time went backwards: "
-                      "delta=%lld cpu_delta=%lld shadow=%lld "
+                      "delta=%lld delta_cpu=%lld shadow=%lld "
                       "off=%lld processed=%lld cpu_processed=%lld\n",
                       cpu, delta, delta_cpu, shadow->system_timestamp,
                       (s64)get_nsec_offset(shadow),
@@ -675,8 +675,10 @@
         * HACK: Passing NULL to account_steal_time()
         * ensures that the ticks are accounted as stolen.
         */
-       if (stolen > 0) {
+       if ((stolen > 0) && (delta_cpu > 0)) {
                delta_cpu -= stolen;
+               if (unlikely(delta_cpu < 0))
+                       stolen += delta_cpu; /* clamp local-time progress */
                do_div(stolen, NS_PER_TICK);
                per_cpu(processed_stolen_time, cpu) += stolen * NS_PER_TICK;
                per_cpu(processed_system_time, cpu) += stolen * NS_PER_TICK;
@@ -688,8 +690,10 @@
         * HACK: Passing idle_task to account_steal_time()
         * ensures that the ticks are accounted as idle/wait.
         */
-       if (blocked > 0) {
+       if ((blocked > 0) && (delta_cpu > 0)) {
                delta_cpu -= blocked;
+               if (unlikely(delta_cpu < 0))
+                       blocked += delta_cpu; /* clamp local-time progress */
                do_div(blocked, NS_PER_TICK);
                per_cpu(processed_blocked_time, cpu) += blocked * NS_PER_TICK;
                per_cpu(processed_system_time, cpu)  += blocked * NS_PER_TICK;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.