On Mon, Jul 31, 2017 at 09:48 +0800, Adam Steen wrote:
> Ted Unangst  wrote:
> > we don't currently export this info, but we could add some sysctls. there's
> > some cpufeatures stuff there, but generally stuff isn't exported until
> > somebody finds a use for it... it shouldn't be too hard to add something to
> > amd64/machdep.c sysctl if you're interested.
> 
> I am interested, as i need the info, i will look into it and hopefully
> come back with a patch.

This is a bad idea because TSC as the time source is only usable
by OpenBSD on Skylake and Kaby Lake CPUs since they encode the TSC
frequency in the CPUID. All older CPUs have their TSCs measured
against the PIT. Currently the measurement done by the kernel isn't
very precise and if TSC is selected as a timecounter, the machine
would be gaining time on a pace that cannot be corrected by our NTP
daemon. (IIRC, about an hour a day on my Haswell running with NTP).

To be able to use TSC as a timecounter source on OpenBSD or Solo5
you'd have to improve the in-kernel measurement of the TSC frequency
first. I've tried to perform 10 measurements and take an average and
it does improve accuracy, however I believe we need to poach another
bit from Linux and re-calibrate TSC via HPET:

 
http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L409

I think this is the most sane thing we can do. Here's a complete
procedure that Linux kernel undertakes:

 
http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L751

Regards,
Mike

Reply via email to