At Tue, 18 Jun 2024 16:36:27 -0700, "Greg A. Woods" <woods%planix.ca@localhost> wrote: Subject: Re: timekeeping regression? > > > [ 83329.4245423] xen raw systime + tsc delta went backwards: 82591317579681 > 82591299251748 > [ 83329.4245423] raw_systime_ns=82590641756625 > [ 83329.4245423] tsc_timestamp=233578790859082 > [ 83329.4245423] tsc=233580649104491 > [ 83329.4245423] tsc_to_system_mul=3039340271 > [ 83329.4245423] tsc_shift=-1 > [ 83329.4245423] delta_tsc=1858245409 > [ 83329.4245423] delta_ns=657495123 > > .... > > I thought this might be because there's no way (that I know) to set the > tsc_mode for dom0, but given that the tsc_to_system_mul shown in the > debug printf is about what it should be to round down to 1GHz on this > machine then it seems RDTSC must be being emulated. I think I may have got that backwards. My sleep-deprived brain isn't doing well with numbers of that magnitude. The delta_tsc shown above is in fact a factor of 2.83 greater than delta_ns, and the CPUs on this machine are running at 2.83 GHz. So RDTSC for dom0 is NATIVE (NOT emulated)! Have I got that right now? That would better explain why the dom0 vCPUs have to be pinned (at least on older CPUs without TSC_INVARIANT). It also explains why a dom0 is able to keep perfect time (when pinned), even though it is using the same supposed "xen_system_time" timecounter as a domU which (eventually) can't keep time, I think "xen_system_time" in a dom0 is really just TSC time, but for domU it's from the emulated RDTSC running at 1 GHz, and for dom0 it's real CPU time! If I'm right then the setting of tc_frequency for xen_timecounter was bit of a misdirection for me (but it shouldn't matter as the value returned by xen_get_timecount() is always in matching units of nanoseconds anyway). It was just confusing me terribly as I was assuming dom0 was getting the same RDTSC emulation! Maybe though dom0 shouldn't use "xen_system_time", but rather just directly use TSC (or whatever other hardware clock might be better, as without TSC_INVARIANT the TSC timecounter gets quality=-100). I think that would simplify xen_clock.c and make kern.timecounter look show what's really being used. -- Greg A. Woods <gwoods%acm.org@localhost> Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost> Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgpmmZbXoEthX.pgp
Description: OpenPGP Digital Signature