freebsd-nq/sys
Bruce Evans f0ebe4973f Scheduler fixes equivalent to the ones logged in the following NetBSD
commit to kern_synch.c:

  ----------------------------
  revision 1.55
  date: 1999/02/23 02:56:03;  author: ross;  state: Exp;  lines: +39 -10
  Scheduler bug fixes and reorganization
  * fix the ancient nice(1) bug, where nice +20 processes incorrectly
    steal 10 - 20% of the CPU, (or even more depending on load average)
  * provide a new schedclk() mechanism at a new clock at schedhz, so high
    platform hz values don't cause nice +0 processes to look like they are
    niced
  * change the algorithm slightly, and reorganize the code a lot
  * fix percent-CPU calculation bugs, and eliminate some no-op code

  === nice bug === Correctly divide the scheduler queues between niced and
  compute-bound processes. The current nice weight of two (sort of, see
  `algorithm change' below) neatly divides the USRPRI queues in half; this
  should have been used to clip p_estcpu, instead of UCHAR_MAX.  Besides
  being the wrong amount, clipping an unsigned char to UCHAR_MAX is a no-op,
  and it was done after decay_cpu() which can only _reduce_ the value.  It
  has to be kept <= NICE_WEIGHT * PRIO_MAX - PPQ or processes can
  scheduler-penalize themselves onto the same queue as nice +20 processes.
  (Or even a higher one.)

  === New schedclk() mechansism === Some platforms should be cutting down
  stathz before hitting the scheduler, since the scheduler algorithm only
  works right in the vicinity of 64 Hz. Rather than prescale hz, then scale
  back and forth by 4 every time p_estcpu is touched (each occurance an
  abstraction violation), use p_estcpu without scaling and require schedhz
  to be generated directly at the right frequency. Use a default stathz (well,
  actually, profhz) / 4, so nothing changes unless a platform defines schedhz
  and a new clock.  Define these for alpha, where hz==1024, and nice was
  totally broke.

  === Algorithm change === The nice value used to be added to the
  exponentially-decayed scheduler history value p_estcpu, in _addition_ to
  be incorporated directly (with greater wieght) into the priority calculation.
  At first glance, it appears to be a pointless increase of 1/8 the nice
  effect (pri = p_estcpu/4 + nice*2), but it's actually at least 3x that
  because it will ramp up linearly but be decayed only exponentially, thus
  converging to an additional .75 nice for a loadaverage of one. I killed
  this, it makes the behavior hard to control, almost impossible to analyze,
  and the effect (~~nothing at for the first second, then somewhat increased
  niceness after three seconds or more, depending on load average) pointless.

  === Other bugs === hz -> profhz in the p_pctcpu = f(p_cpticks) calcuation.
  Collect scheduler functionality. Try to put each abstraction in just one
  place.
  ----------------------------

The details are a little different in FreeBSD:

=== nice bug ===   Fixing this is the main point of this commit.  We use
essentially the same clipping rule as NetBSD (our limit on p_estcpu
differs by a scale factor).  However, clipping at all is fundamentally
bad.  It gives free CPU the hoggiest hogs once they reach the limit, and
reaching the limit is normal for long-running hogs.  This will be fixed
later.

=== New schedclk() mechanism ===  We don't use the NetBSD schedclk()
(now schedclock()) mechanism.  We require (real)stathz to be about 128
and scale by an extra factor of 2 compared with NetBSD's statclock().
We scale p_estcpu instead of scaling the clock.  This is more accurate
and flexible.

=== Algorithm change ===  Same change.

=== Other bugs ===  The p_pctcpu bug was fixed long ago.  We don't try as
hard to abstract functionality yet.

Related changes: the new limit on p_estcpu must be exported to kern_exit.c
for clipping in wait1().

Agreed with by:		dufault
1999-11-28 12:12:13 +00:00
..
alpha Sort PCI SCSI controlers. 1999-11-28 00:59:03 +00:00
amd64 Sort PCI SCSI controlers. 1999-11-28 00:59:03 +00:00
boot Make the prompt look like on OpenBoot. 1999-11-27 21:44:47 +00:00
cam Don't clear the SA_FLAG_TAPE_LOCKED prior to calling 1999-11-21 20:23:58 +00:00
coda s/p_cred->pc_ucred/p_ucred/g 1999-11-21 12:38:21 +00:00
compat Implement linux_ustat. 1999-11-27 16:55:14 +00:00
compile
conf /sys adjustments to add the `sym' controler driver. 1999-11-28 00:48:15 +00:00
contrib Convert various pieces of code to use vn_isdisk() rather than checking 1999-11-22 10:33:55 +00:00
ddb
dev - Fail VT switching when the controlling program, such as the 1999-11-28 07:44:11 +00:00
fs Remove abuse of struct nameidata. 1999-11-27 17:46:04 +00:00
geom Convert various pieces of code to use vn_isdisk() rather than checking 1999-11-22 10:33:55 +00:00
gnu struct mountlist and struct mount.mnt_list have no business being 1999-11-20 10:00:46 +00:00
i4b
i386 Sort PCI SCSI controlers. 1999-11-28 00:59:03 +00:00
isa Allow a DMA channel of 0. This gets the on-board mss audio device working 1999-11-22 14:30:41 +00:00
isofs/cd9660
kern Scheduler fixes equivalent to the ones logged in the following NetBSD 1999-11-28 12:12:13 +00:00
libkern Change the prototype of the strto* routines to make the second 1999-11-24 01:03:08 +00:00
miscfs Add a sysctl to control if argv is disclosed to the world: 1999-11-26 08:27:16 +00:00
modules This fell out of a previous commit: create the opt_md.h and opt_mfs.h 1999-11-26 21:01:03 +00:00
msdosfs struct mountlist and struct mount.mnt_list have no business being 1999-11-20 10:00:46 +00:00
net Expand the field width for subtypes. We had already overflowed it 1999-11-24 02:40:12 +00:00
netatalk
netatm Fix a warning (unused variable RCSid) 1999-11-18 08:18:13 +00:00
netgraph Change the prototype of the strto* routines to make the second 1999-11-24 01:03:08 +00:00
netinet RTFREE the correct route entry in dummynet_io(). The previous 1999-11-26 13:37:09 +00:00
netinet6 Removed IPSEC and IPV6FIREWALL because they are not ready yet. 1999-11-23 05:42:36 +00:00
netipx
netkey KAME netinet6 basic part(no IPsec,no V6 Multicast Forwarding, no UDP/TCP 1999-11-22 02:45:11 +00:00
netnatm
netncp
netns
nfs Remap the error EEXISTS => 0 *before* using error to determine if we should 1999-11-27 18:14:41 +00:00
nfsclient Remap the error EEXISTS => 0 *before* using error to determine if we should 1999-11-27 18:14:41 +00:00
nfsserver nm_srtt and nm_sdrtt are arrays[4]. Remove explicit initialization 1999-11-22 04:50:09 +00:00
ntfs
nwfs Remove abuse of struct nameidata. 1999-11-27 17:46:04 +00:00
pc98 Sync with sys/dev/syscons/syscons.c revision 1.327. 1999-11-28 08:57:22 +00:00
pccard s/Brige/Bridge/. 1999-11-21 00:53:23 +00:00
pci Add 3 more parts of the VIA 82C686. 1999-11-24 21:07:29 +00:00
posix4
powerpc Use %ll instead of %q as gcc moans bitterly about it. 1999-11-22 15:23:58 +00:00
rpc
svr4 General clean-up of socket.h and associated sources to synchronise up 1999-11-24 20:49:04 +00:00
sys Moved scheduling-related code to kern_synch.c so that it is easier to fix 1999-11-27 12:32:27 +00:00
tools Add usbdevs and friends. 1999-11-18 18:02:44 +00:00
ufs Retire MFS_ROOT and MFS_ROOT_SIZE options from the MFS implementation. 1999-11-26 20:08:44 +00:00
vm Remove nonsensical vm_map_{clear,set}_recursive() calls 1999-11-25 20:21:52 +00:00
Makefile