mirror of
https://github.com/opnsense/src.git
synced 2026-05-25 02:35:01 -04:00
time(3): Declare the minimum and maximum hz values supported.
Reviewed by: kib@ and imp@
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D37072
(cherry picked from commit ee29897fc3)
This commit is contained in:
parent
eb9766b37c
commit
98be2ec6df
2 changed files with 18 additions and 0 deletions
|
|
@ -115,6 +115,10 @@ u_long sgrowsiz; /* amount to grow stack */
|
|||
|
||||
SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0,
|
||||
"Number of clock ticks per second");
|
||||
SYSCTL_INT(_kern, OID_AUTO, hz_max, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, HZ_MAXIMUM,
|
||||
"Maximum hz value supported");
|
||||
SYSCTL_INT(_kern, OID_AUTO, hz_min, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, HZ_MINIMUM,
|
||||
"Minimum hz value supported");
|
||||
SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0,
|
||||
"Number of buffers in the buffer cache");
|
||||
SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0,
|
||||
|
|
@ -177,6 +181,13 @@ init_param1(void)
|
|||
TUNABLE_INT_FETCH("kern.hz", &hz);
|
||||
if (hz == -1)
|
||||
hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ;
|
||||
|
||||
/* range check the "hz" value */
|
||||
if (__predict_false(hz < HZ_MINIMUM))
|
||||
hz = HZ_MINIMUM;
|
||||
else if (__predict_false(hz > HZ_MAXIMUM))
|
||||
hz = HZ_MAXIMUM;
|
||||
|
||||
tick = 1000000 / hz;
|
||||
tick_sbt = SBT_1S / hz;
|
||||
tick_bt = sbttobt(tick_sbt);
|
||||
|
|
|
|||
|
|
@ -583,6 +583,13 @@ void timevaladd(struct timeval *t1, const struct timeval *t2);
|
|||
void timevalsub(struct timeval *t1, const struct timeval *t2);
|
||||
int tvtohz(struct timeval *tv);
|
||||
|
||||
/*
|
||||
* The following HZ limits allow the tvtohz() function
|
||||
* to only use integer computations.
|
||||
*/
|
||||
#define HZ_MAXIMUM (INT_MAX / (1000000 >> 6)) /* 137kHz */
|
||||
#define HZ_MINIMUM 8 /* hz */
|
||||
|
||||
#define TC_DEFAULTPERC 5
|
||||
|
||||
#define BT2FREQ(bt) \
|
||||
|
|
|
|||
Loading…
Reference in a new issue