summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2012-08-11 20:24:39 +0000
committermav <mav@FreeBSD.org>2012-08-11 20:24:39 +0000
commit60e552193c6254b62636fc4532d50854f1ec0739 (patch)
tree570482f009d2f33ef6dac759439eb9a4755b1f6b /sys/kern/sched_4bsd.c
parentc88a41061f74c31f13da5dd0358685499d8dbb06 (diff)
downloadFreeBSD-src-60e552193c6254b62636fc4532d50854f1ec0739.zip
FreeBSD-src-60e552193c6254b62636fc4532d50854f1ec0739.tar.gz
Some more minor tunings inspired by bde@.
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 4d10011..f7fd347 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -193,12 +193,13 @@ sysctl_kern_quantum(SYSCTL_HANDLER_ARGS)
period = 1000000 / realstathz;
new_val = period * sched_slice;
error = sysctl_handle_int(oidp, &new_val, 0, req);
- if (error != 0 || req->newptr == NULL)
+ if (error != 0 || req->newptr == NULL)
return (error);
if (new_val <= 0)
return (EINVAL);
- sched_slice = max(1, (new_val + period / 2) / period);
- hogticks = max(1, 2 * hz * sched_slice / realstathz);
+ sched_slice = imax(1, (new_val + period / 2) / period);
+ hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) /
+ realstathz);
return (0);
}
@@ -208,9 +209,9 @@ SYSCTL_STRING(_kern_sched, OID_AUTO, name, CTLFLAG_RD, "4BSD", 0,
"Scheduler name");
SYSCTL_PROC(_kern_sched, OID_AUTO, quantum, CTLTYPE_INT | CTLFLAG_RW,
NULL, 0, sysctl_kern_quantum, "I",
- "Length of time granted to timeshare threads in microseconds");
+ "Quantum for timeshare threads in microseconds");
SYSCTL_INT(_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0,
- "Length of time granted to timeshare threads in stathz ticks");
+ "Quantum for timeshare threads in stathz ticks");
#ifdef SMP
/* Enable forwarding of wakeups to all other cpus */
static SYSCTL_NODE(_kern_sched, OID_AUTO, ipiwakeup, CTLFLAG_RD, NULL,
@@ -665,7 +666,8 @@ sched_initticks(void *dummy)
realstathz = stathz ? stathz : hz;
sched_slice = realstathz / 10; /* ~100ms */
- hogticks = max(1, 2 * hz * sched_slice / realstathz);
+ hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) /
+ realstathz);
}
/* External interfaces start here */
@@ -704,7 +706,7 @@ sched_rr_interval(void)
{
/* Convert sched_slice from stathz to hz. */
- return (max(1, (sched_slice * hz + realstathz / 2) / realstathz));
+ return (imax(1, (sched_slice * hz + realstathz / 2) / realstathz));
}
/*
OpenPOWER on IntegriCloud