> From: Paul Irofti <p...@irofti.net> > Date: Sat, 11 Jul 2020 13:32:22 +0300 > > Hi, > > Getting lots of messages about people loving the new timekeep > functionality, which I am very happy about, but also some that have the > skew too large for it to be enabled. > > I plan on sending a diff next week to improve the situation via RDTSCP > on the machines that have it. Which is basically all modern machines. > > The plan is to have an auxiliary value returned by RDTSCP which > identifies the CPU we got the info from so that we can look-up its > associated skew in a table saved at init inside the timekeep structure:
I think that is the wrong approach. Instead we should synchronize the TSC counters themselves. There are special MSRs you can write the offset into IIRC. That seems to be what FreeBSD does. > static inline u_int > rdtscp(void) > { > uint32_t hi, lo, aux; > asm volatile("rdtscp" : "=a"(lo), "=d"(hi), "=c" (aux) : : ); > skew = get_cpu_skew(aux); > return ((uint64_t)lo)|(((uint64_t)hi)<<32) + skew; > } > > Have a nice weekend, > Paul > >