Hi, I'm sorry.. I send a wrong diff to the people. The result from giovanni@ and mcmer seems wrong. I suppose stu@ used the correct diff.
giovanni and mcmer, can you test with the correct diff again? I attached the correct diff at last of this mail. I'm sorry again. On Tue, 6 Apr 2021 09:21:40 +0200 Giovanni Bechis <giova...@paclan.it> wrote: > On Mon, Apr 05, 2021 at 07:14:49PM +0900, YASUOKA Masahiko wrote: >> Hi, >> >> > Another issue that I see is that people have not reported, at least > [...] >> > publicly, that this runs fine on their normal OpenBSD machines. >> >> Some dmesgs posted on public lists seems to have the same problem. >> >> https://marc.info/?l=openbsd-bugs&w=2&r=1&s=disabling+user+TSC&q=b >> https://marc.info/?l=openbsd-tech&w=2&r=1&s=disabling+user+TSC&q=b >> https://marc.info/?l=openbsd-ports&w=2&r=1&s=disabling+user+TSC&q=b >> >> For example, >> >> https://marc.info/?l=openbsd-bugs&m=161618496905444&w=2 >> >> |Subject: wg(4) crash >> |From: Stuart Henderson <stu () spacehopper ! org> >> |bios0: vendor Dell Inc. version "2.9.0" date 12/06/2019 >> |bios0: Dell Inc. PowerEdge R620 >> |cpu1: disabling user TSC (skew=135) >> |cpu1: smt 0, core 0, package 1 >> >> https://marc.info/?l=openbsd-ports&m=161306073708427&w=2 >> |Subject: Re: sysutils/nut README APC over USB device chgrp/chmod >> |From: Marcus MERIGHI <mcmer-openbsd () tor ! at> >> |bios0: vendor American Megatrends Inc. version "3.1" date 06/07/2018 >> |cpu11: disabling user TSC (skew=240) >> |cpu11: smt 0, core 3, package 1 >> >> these 2 are real machine and using 2 CPU sockets. >> >> https://marc.info/?l=openbsd-ports&m=161562278114172&w=2 >> |Subject: ruby27 vs Puppet >> |From: Giovanni Bechis <giovanni () paclan ! it> >> |bios0: vendor Phoenix Technologies LTD version "6.00" date 12/12/2018 >> |bios0: VMware, Inc. VMware Virtual Platform >> |cpu1: disabling user TSC (skew=-12705) >> >> VMware. seems the same problem of mine. >> >> I'll ask people to do the same test which cheloha@ write in previous >> mail. >> > Attached my data and dmesg produced by the script on my VMware vm. > > Cheers > Giovanni Index: sys/arch/amd64/amd64/tsc.c =================================================================== RCS file: /var/cvs/openbsd/src/sys/arch/amd64/amd64/tsc.c,v retrieving revision 1.23 diff -u -p -r1.23 tsc.c --- sys/arch/amd64/amd64/tsc.c 23 Feb 2021 04:44:30 -0000 1.23 +++ sys/arch/amd64/amd64/tsc.c 5 Apr 2021 10:28:00 -0000 @@ -311,16 +311,42 @@ tsc_read_bp(struct cpu_info *ci, uint64_ *aptscp = tsc_sync_val; } +#define TSC_SYNC_NTIMES 1000 + +static int tsc_difs[MAXCPUS][TSC_SYNC_NTIMES]; + +void +tsc_debug(void) +{ + int i, cpuid = curcpu()->ci_cpuid; + + for (i = 0; i < TSC_SYNC_NTIMES; i++) { + if (i % 10 == 0) + printf("%5d", tsc_difs[cpuid][i]); + else + printf(" %5d", tsc_difs[cpuid][i]); + if (i % 10 == 9) + printf("\n"); + } + printf("\n"); +} + void tsc_sync_bp(struct cpu_info *ci) { + int i, mindif = INT_MAX, dif; uint64_t bptsc, aptsc; - tsc_read_bp(ci, &bptsc, &aptsc); /* discarded - cache effects */ - tsc_read_bp(ci, &bptsc, &aptsc); + for (i = 0; i < TSC_SYNC_NTIMES; i++) { + tsc_read_bp(ci, &bptsc, &aptsc); + dif = bptsc - aptsc; + if (abs(dif) < abs(mindif)) + mindif = dif; + tsc_difs[ci->ci_cpuid][i] = dif; + } /* Compute final value to adjust for skew. */ - ci->ci_tsc_skew = bptsc - aptsc; + ci->ci_tsc_skew = mindif; } /* @@ -351,8 +377,10 @@ tsc_post_ap(struct cpu_info *ci) void tsc_sync_ap(struct cpu_info *ci) { - tsc_post_ap(ci); - tsc_post_ap(ci); + int i; + + for (i = 0; i < TSC_SYNC_NTIMES; i++) + tsc_post_ap(ci); } void