Page MenuHomeFreeBSD

hyperv: Implement "enlightened" time counter, which is rdtsc based.
ClosedPublic

Authored by sepherosa_gmail.com on Dec 12 2016, 8:30 AM.
Tags
None
Referenced Files
F81970368: D8763.diff
Sat, Dec 14, 5:34 PM
Unknown Object (File)
Feb 22 2024, 7:04 PM
Unknown Object (File)
Jan 9 2024, 4:33 AM
Unknown Object (File)
Jan 9 2024, 4:33 AM
Unknown Object (File)
Jan 9 2024, 4:33 AM
Unknown Object (File)
Jan 9 2024, 4:33 AM
Unknown Object (File)
Jan 9 2024, 4:33 AM
Unknown Object (File)
Jan 9 2024, 4:32 AM
Subscribers
None

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sepherosa_gmail.com retitled this revision from to hyperv: Implement "enlightened" time counter, which is rdtsc based..
sepherosa_gmail.com updated this object.
sepherosa_gmail.com edited the test plan for this revision. (Show Details)

Fallback to other timecounter's tc_get_timecount is not a good idea.

sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
82 ↗(On Diff #22839)

Don't you need volatile read of tsc_seq there ?

96 ↗(On Diff #22839)

... and there ? Also, I believe that you want to tsc_scale and tsc_ofs reads to occur not earlier than tsc_seq read occured. x86 is strongly ordered WRT reads, but compiler is not. It seems that you want tsc_seq in the while () condition to occur using atomic_load_acq(), and you need atomic_thread_fence_acq() barrier before this re-read.

sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
82 ↗(On Diff #22839)

tsc_seq is volatile qualified, so I think the read here is volatile.

96 ↗(On Diff #22839)

I considered about adding explicit compiler_membar though. As about the atomic_..._acq functions, IIRC, some said atomic_..._acq normally should be paired w/ the atomic_..._rel, while obviously the atomic_..._rel is on the hypervisor side. Do you think it's fine to use atomic_..._acq w/o atomic_..._rel? I am absolutely fine w/ using the atomic_..._acq.

Add compiler fence through atomic_*_acq, suggested by kib

kib edited edge metadata.

Looks good for me, as far as I do not know/understand the HV interface proper.

sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
82 ↗(On Diff #22839)

Ok.

96 ↗(On Diff #22839)

It was me who made that note, among others. Point is, if implementation of atomic(9) changes, this should be reconsidered. I am fine with the use of __compiler_membar() if you prefer that.

Note that right now memory model details of hyperv_tsc_timecount() are identical to that of libc/kernel binuptime() function.

This revision is now accepted and ready to land.Dec 13 2016, 11:19 AM
This revision was automatically updated to reflect the committed changes.