Page MenuHomeFreeBSD

D37072.diff
No OneTemporary

D37072.diff

diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -111,6 +111,10 @@
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,
@@ -173,6 +177,13 @@
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);
diff --git a/sys/sys/time.h b/sys/sys/time.h
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -583,6 +583,13 @@
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) \

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 1:31 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14708156
Default Alt Text
D37072.diff (1 KB)

Event Timeline