Skip to contentSkip to conversation

roughly synchronize calibration calls to reduce skew

PATCH New Dan Magenheimer 1 participant 2 messages Jul 27, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 roughly synchronize calibration calls to reduce skew

This patch (based from 18139) roughly synchronizes calls to local_time_calibration() across multiple processors by setting each next timer to a "round epoch". This results in reduced skew; both max and average skew are reduced by between a factor of 2 and 3. Note that timers still fire at slightly different times because the next "round epoch" is still relative to local stime which still has some inter-processor skew.

Making local_time_calibration() precisely concurrent across processors is a possible next step but since each processor still has to get the platform timer -- an operation that is locked and takes several (and sometimes tens of) microseconds, concurrency will take some more cleverness.

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

xen/arch/x86/time.c +4 -3
diff -r a7642acd9caf xen/arch/x86/time.c
@@ -35,7 +35,8 @@ static char opt_clocksource[10];
 static char opt_clocksource[10];
 string_param("clocksource", opt_clocksource);
 
-#define EPOCH MILLISECS(1000)
+#define EPOCH (1ULL<<30)
+#define NEXT_ROUNDED_EPOCH(now)  (((now) + (EPOCH+(EPOCH/2))) & ~(EPOCH-1))
 
 unsigned long cpu_khz;  /* CPU clock frequency in kHz. */
 DEFINE_SPINLOCK(rtc_lock);
@@ -1021,7 +1022,7 @@ static void local_time_calibration(void 
     update_vcpu_system_time(current);
 
  out:
-    set_timer(&t->calibration_timer, NOW() + EPOCH);
+    set_timer(&t->calibration_timer, NEXT_ROUNDED_EPOCH(curr_local_stime));
 
     if ( smp_processor_id() == 0 )
         platform_time_calibration();
@@ -1050,7 +1051,7 @@ void init_percpu_time(void)
  out:
     init_timer(&t->calibration_timer, local_time_calibration,
                NULL, smp_processor_id());
-    set_timer(&t->calibration_timer, NOW() + EPOCH);
+    set_timer(&t->calibration_timer, NEXT_ROUNDED_EPOCH(NOW()));
 }
 
 /* Late init function (after all CPUs are booted). */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

PATCH 1/1 add more useful clock output for "xm debug-key t"

This patch collects additional useful clock skew output which is printk'd, for example, by "xm debug-key t".

Since this information assists in the decision whether to select the new clocksource=tsc and softtsc boot options, it would be nice to have this in 3.3.

By repeating "xm debug-key t; xm dmesg | tail -N" in dom0 (e.g. with the "watch" command), useful skew info about the machine can be collected, which will be very helpful for diagnosing customer problems on misbehaving machines.

Patch details:
1) Min and max readings from the current sample are useless so get rid of those but retain the current maxdif (stime skew).
2) Remember max of skew, sum of skews, and a count
so average skew can be displayed.
3) Also record info for cycles (tsc on x86, itc on ia64).
4) Add a hook for arch-dependent info. Only used for clocksource on x86 now, but other info will be added later.

(Note, not compiled on ia64... its possible a header file will need to be include'd somewhere.)

xen/arch/ia64/xen/xentime.c +4 -0
diff -r a7642acd9caf xen/arch/ia64/xen/xentime.c
@@ -261,3 +261,7 @@ void get_wallclock(uint64_t *sec, uint64
     *nsec = nano % NSEC_PER_SEC;
     *now = n;
 }
+
+void arch_dump_time_info(void)
+{
+}
xen/arch/x86/time.c +6 -0
diff -r a7642acd9caf xen/arch/x86/time.c
@@ -1248,6 +1248,12 @@ struct tm wallclock_time(void)
     return gmtime(seconds);
 }
 
+void arch_dump_time_info(void)
+{
+    printk("clocksource is %s\n",plt_src.name);
+    /* add other useful clock-related output here */
+}
+
 /*
  * Local variables:
  * mode: C
xen/common/keyhandler.c +40 -14

92 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel