big footnotes, too.
[unix-history] / usr / src / sys / vm / vm_meter.c
index 86af61c..f064e50 100644 (file)
@@ -1,4 +1,4 @@
-/*     vm_meter.c      4.7     81/04/23        */
+/*     vm_meter.c      4.13    81/08/30        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -28,6 +28,7 @@ int   slowscan = 0;
 int    fastscan = 0;
 int    klin = KLIN;
 int    klseql = KLSEQL;
 int    fastscan = 0;
 int    klin = KLIN;
 int    klseql = KLSEQL;
+int    klsdist = KLSDIST;
 int    kltxt = KLTXT;
 int    klout = KLOUT;
 int    multprog = -1;          /* so we don't count process 2 */
 int    kltxt = KLTXT;
 int    klout = KLOUT;
 int    multprog = -1;          /* so we don't count process 2 */
@@ -41,7 +42,6 @@ double        avenrun[3];             /* load average, of runnable procs */
  */
 setupclock()
 {
  */
 setupclock()
 {
-       int nclust, nkb;
 
        /*
         * Setup thresholds for paging:
 
        /*
         * Setup thresholds for paging:
@@ -54,7 +54,7 @@ setupclock()
         * Strategy of 4/22/81:
         *      lotsfree is 1/4 of memory free.
         *      desfree is 200k bytes, but at most 1/8 of memory
         * Strategy of 4/22/81:
         *      lotsfree is 1/4 of memory free.
         *      desfree is 200k bytes, but at most 1/8 of memory
-        *      minfree is 32k bytes.
+        *      minfree is 64k bytes, but at most 1/2 of desfree
         */
        if (lotsfree == 0)
                lotsfree = LOOPPAGES / 4;
         */
        if (lotsfree == 0)
                lotsfree = LOOPPAGES / 4;
@@ -63,8 +63,11 @@ setupclock()
                if (desfree > LOOPPAGES / 8)
                        desfree = LOOPPAGES / 8;
        }
                if (desfree > LOOPPAGES / 8)
                        desfree = LOOPPAGES / 8;
        }
-       if (minfree == 0)
-               minfree = (32*1024) / NBPG;
+       if (minfree == 0) {
+               minfree = (64*1024) / NBPG;
+               if (minfree > desfree/2)
+                       minfree = desfree / 2;
+       }
 
        /*
         * Maxpgio thresholds how much paging is acceptable.
 
        /*
         * Maxpgio thresholds how much paging is acceptable.
@@ -75,43 +78,27 @@ setupclock()
                maxpgio = (DISKRPM * 2) / 3;
 
        /*
                maxpgio = (DISKRPM * 2) / 3;
 
        /*
-        * Clock to scan using max of 10% of processor time for sampling,
-        *     this estimated to allow maximum of 400 samples per second.
-        * Allow slighly higher angular velocity if 2 or more swap devices,
-        *     allow max of 600 samples per second (but only >= 2m)
-        * Basic scan time for ``fastscan'', the time for a clock rev
-        * with given memory and CLSIZE=2:
-        *      swap ilv        <=1m    2m      3m      4m      6m      8m
-        *      one-way         4s      5s      7s      XXX     XXX     XXX
-        *      two-way         4s      4s      5s      6s      10s     13s
-        * XXXs here are situations we should not be in.
+        * Clock to scan using max of ~~10% of processor time for sampling,
+        *     this estimated to allow maximum of 200 samples per second.
+        * This yields a ``fastscan'' of roughly (with CLSIZE=2):
+        *      <=1m    2m      3m      4m      8m
+        *      5s      10s     15s     20s     40s
         */
         */
-       if (fastscan == 0) {
-               nclust = LOOPPAGES / CLSIZE;
-               nkb = (LOOPPAGES * NBPG) / 1024;
-               if (nswdev == 1 && physmem*NBPG > 2*1024*(1024-16))
-                       printf("WARNING: should run interleaved swap with >= 2Mb\n");
-               if (nswdev == 1 || nkb < 2*1024)
-                       fastscan = nclust / 400;
-               else {
-                       maxpgio = (maxpgio * 3) / 2;
-                       fastscan = nclust / 600;
-               }
-       }
-       if (fastscan < 4)
-               fastscan = 4;
-       if (fastscan > maxslp)
-               fastscan = maxslp;
+       if (nswdev == 1 && physmem*NBPG > 2*1024*(1024-16))
+               printf("WARNING: should run interleaved swap with >= 2Mb\n");
+       if (fastscan == 0)
+               fastscan = (LOOPPAGES/CLSIZE) / 200;
+       if (fastscan < 5)
+               fastscan = 5;
+       if (nswdev == 2)
+               maxpgio = (maxpgio * 3) / 2;
 
        /*
 
        /*
-        * Set slow scan time to 1/3 the fast scan time but at most
-        * maxslp (a macroscopic slow).
+        * Set slow scan time to 1/2 the fast scan time.
         */
        if (slowscan == 0)
         */
        if (slowscan == 0)
-               slowscan = 3 * fastscan;
-       if (slowscan > maxslp)
-               slowscan = maxslp;
-#if defined(BERT) || defined(ERNIE)
+               slowscan = 2 * fastscan;
+#ifdef notdef
        printf("slowscan %d, fastscan %d, maxpgio %d\n",
            slowscan, fastscan, maxpgio);
        printf("lotsfree %d, desfree %d, minfree %d\n",
        printf("slowscan %d, fastscan %d, maxpgio %d\n",
            slowscan, fastscan, maxpgio);
        printf("lotsfree %d, desfree %d, minfree %d\n",
@@ -166,17 +153,13 @@ sched()
        register struct bigp *bp, *nbp;
        int biggot, gives;
 
        register struct bigp *bp, *nbp;
        int biggot, gives;
 
-       /*
-        * Check if paging rate is too high, or average of
-        * free list very low and if so, adjust multiprogramming
-        * load by swapping someone out.
-        */
 loop:
        wantin = 0;
        deservin = 0;
        sleeper = 0;
        p = 0;
        /*
 loop:
        wantin = 0;
        deservin = 0;
        sleeper = 0;
        p = 0;
        /*
+        * See if paging system is overloaded; if so swap someone out.
         * Conditions for hard outswap are:
         *      if need kernel map (mix it up).
         * or
         * Conditions for hard outswap are:
         *      if need kernel map (mix it up).
         * or
@@ -185,7 +168,7 @@ loop:
         * and  3. the short (5-second) and longer (30-second) average
         *         memory is less than desirable.
         */
         * and  3. the short (5-second) and longer (30-second) average
         *         memory is less than desirable.
         */
-       if (kmapwnt || (avenrun[0] >= 2 && max(avefree, avefree30) < desfree &&
+       if (kmapwnt || (avenrun[0] >= 2 && imax(avefree, avefree30) < desfree &&
            (rate.v_pgin + rate.v_pgout > maxpgio || avefree < minfree))) {
                desperate = 1;
                goto hardswap;
            (rate.v_pgin + rate.v_pgout > maxpgio || avefree < minfree))) {
                desperate = 1;
                goto hardswap;
@@ -358,7 +341,7 @@ hardswap:
                        gives = p->p_rssize;
                        if (p->p_textp)
                                gives += p->p_textp->x_rssize / p->p_textp->x_ccount;
                        gives = p->p_rssize;
                        if (p->p_textp)
                                gives += p->p_textp->x_rssize / p->p_textp->x_ccount;
-                       gives = min(gives, lotsfree);
+                       gives = imin(gives, lotsfree);
                        deficit += gives;
                } else
                        gives = 0;      /* someone else taketh away */
                        deficit += gives;
                } else
                        gives = 0;      /* someone else taketh away */