Re: kern.timecounter.smp_tsc_adjust

看板FB_hackers作者時間11年前 (2014/06/05 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
>In any case, at least one, and maybe two, routines need their >types changed (and maybe the TSC_READ macro as well). Is it OK >to just assume the upper 32 bits are in sync? For whatever it may be worth, the following patch (to change everything to 64 bits) is boot-tested and no longer crashes the system that did crash with the unpatched version. It also successfully synchronized TSCs at least once (Intel based board with the "invariant TSC" bit set, 40 CPUs). Chris x86/tsc: fix SMP TSC adjustment code On SMP systems, if kern.timecounter.smp_tsc is set, the kernel attempts to determine whether the TSCs on the processors are sufficiently in-sync to be used for time counting. If not, and kern.timecounter.smp_tsc_adjust is set, we then attempt to adjust all the TSCs. The adjustment code assumed we kept a full 64-bit value for each TSC, but the data-gathering and comparison code used 32-bit values. As a result, if the timecounters were out of sync, the adjustment code could crash (depending on the number of CPUs). This converts everything to full 64-bit values. diff --git a/x86/x86/tsc.c b/x86/x86/tsc.c index 30b8a30..cf05e94 100644 --- a/x86/x86/tsc.c +++ b/x86/x86/tsc.c @@ -373,11 +373,11 @@ init_TSC(void) static void \ tsc_read_##x(void *arg) \ { \ - uint32_t *tsc = arg; \ + uint64_t *tsc = arg; \ u_int cpu = PCPU_GET(cpuid); \ \ __asm __volatile("cpuid" : : : "eax", "ebx", "ecx", "edx"); \ - tsc[cpu * 3 + x] = rdtsc32(); \ + tsc[cpu * 3 + x] = rdtsc(); \ } TSC_READ(0) TSC_READ(1) @@ -389,8 +389,8 @@ TSC_READ(2) static void comp_smp_tsc(void *arg) { - uint32_t *tsc; - int32_t d1, d2; + uint64_t *tsc; + int64_t d1, d2; u_int cpu = PCPU_GET(cpuid); u_int i, j, size; @@ -454,7 +454,7 @@ adj_smp_tsc(void *arg) static int test_tsc(void) { - uint32_t *data, *tsc; + uint64_t *data, *tsc; u_int i, size, adj; if ((!smp_tsc && !tsc_is_invariant) || vm_guest) _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
文章代碼(AID): #1JZrxVcK (FB_hackers)
文章代碼(AID): #1JZrxVcK (FB_hackers)