On Mon, Aug 22, 2022 at 09:37:02AM -0500, Scott Cheloha wrote: > On Wed, Aug 17, 2022 at 09:00:12PM +1000, Jonathan Gray wrote: > > On Wed, Aug 17, 2022 at 04:53:20PM +1000, Jonathan Gray wrote: > > > > > > It seems to me it would be cleaner if the decision of what to use for > > > delay could be moved into an md file. > > > > > > Or abstract it by having a numeric weight like timecounters or driver > > > match return numbers. > > > > diff against your previous, does not change lapic_delay > > Sorry for the delay. > > :) > > I was out of town. > > I slept on this and you're right, this is better. > > Couple tweaks: > > - Move the quality numbers into cpu.h and give them names. That way, > the next time Intel, or AMD, or Microsoft or [...] does something > foolish we don't need to rototill all these files to juggle the > quality hierarchy.
While that would allow arch specific differences, removing one would require changing at least three places in the tree. > > - Update both amd64 and i386's lapic.c to use delay_init(). While we > have a lapic_delay() in the tree it should cooperate with everything > else. > > - Include <machine/cpu.h> in any files calling delay_init() where it > isn't already included. > > - Give the variables in delay_init() real names. hmm > > I'm unsure about two small things: > > - Can i386 use hv_delay()? The i386 GENERIC config does not list > hyperv(4) support so my guess is "no" and I have excluded > HV_DELAY_QUALITY from i386's cpu.h. > > - If a Hyper-V guest could choose between hv_delay() and > lapic_delay(), which would be preferable? Right now I > have hv_delay() scored lower than lapic_delay(). Hyper-V generation 1 VMs are bios boot with emulation of the usual devices. 32-bit and 64-bit guests. Hyper-V generation 2 VMs are 64-bit uefi with paravirtualised devices. 64-bit guests only. There is no 8254 in generation 2. No HPET in either generation. hv_delay uses the "Partition Reference Counter MSR" described in https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/timers It seems it is available in both generations and could be used from i386? >From reading that page hv_delay() should be preferred over lapic_delay()