Now that we have delay_init(), use it in all the places where we
currently set delay_func by hand.
lapic_delay() is great: 3000. hv_delay() is needed before we set up
lapic_delay() on Hyper-V guests: 4000. tsc_delay() is better than
lapic_delay() and (probably?) hv_delay(): 5000.
We may bump hv_delay's quality value up over that of tsc_delay() in a
future patch. It's a little ambiguous whether hv_delay() causes a VM
exit.
Idea and patch from jsg@. With tons of input, research and advice
from jsg@.
Link: https://marc.info/?l=openbsd-tech&m=166053729104923&w=2
ok mlarkin@ jsg@
-/* $OpenBSD: lapic.c,v 1.60 2022/08/15 04:17:50 daniel Exp $ */
+/* $OpenBSD: lapic.c,v 1.61 2022/08/25 17:38:16 cheloha Exp $ */
/* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
* Now that the timer's calibrated, use the apic timer routines
* for all our timing needs..
*/
- if (delay_func == i8254_delay)
- delay_func = lapic_delay;
+ delay_init(lapic_delay, 3000);
initclock_func = lapic_initclocks;
}
}
-/* $OpenBSD: tsc.c,v 1.25 2022/08/12 02:20:36 cheloha Exp $ */
+/* $OpenBSD: tsc.c,v 1.26 2022/08/25 17:38:16 cheloha Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* Copyright (c) 2016,2017 Reyk Floeter <reyk@openbsd.org>
tsc_frequency = tsc_freq_cpuid(ci);
if (tsc_frequency > 0)
- delay_func = tsc_delay;
+ delay_init(tsc_delay, 5000);
}
static inline int
-/* $OpenBSD: lapic.c,v 1.49 2022/08/15 04:17:50 daniel Exp $ */
+/* $OpenBSD: lapic.c,v 1.50 2022/08/25 17:38:16 cheloha Exp $ */
/* $NetBSD: lapic.c,v 1.1.2.8 2000/02/23 06:10:50 sommerfeld Exp $ */
/*-
* Now that the timer's calibrated, use the apic timer routines
* for all our timing needs..
*/
- delay_func = lapic_delay;
+ delay_init(lapic_delay, 3000);
initclock_func = lapic_initclocks;
}
}
-/* $OpenBSD: pvbus.c,v 1.24 2021/11/05 11:38:29 mpi Exp $ */
+/* $OpenBSD: pvbus.c,v 1.25 2022/08/25 17:38:16 cheloha Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
HYPERV_VERSION_EBX_MINOR_S;
#if NHYPERV > 0
- if (hv->hv_features & CPUID_HV_MSR_TIME_REFCNT &&
- delay_func == i8254_delay)
- delay_func = hv_delay;
+ if (hv->hv_features & CPUID_HV_MSR_TIME_REFCNT)
+ delay_init(hv_delay, 4000);
#endif
}