X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/943685687a914f34bb028d07fefeff4a802b6d5b..b08d03f0fba8e509556e1be556eaa3192c9aaefc:/usr/src/sys/vm/vm_meter.c diff --git a/usr/src/sys/vm/vm_meter.c b/usr/src/sys/vm/vm_meter.c index eb24f6e4c2..9924dff677 100644 --- a/usr/src/sys/vm/vm_meter.c +++ b/usr/src/sys/vm/vm_meter.c @@ -1,4 +1,10 @@ -/* vm_meter.c 6.3 84/08/29 */ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)vm_meter.c 7.4 (Berkeley) %G% + */ #include "param.h" #include "systm.h" @@ -11,6 +17,8 @@ #include "cmap.h" #include "kernel.h" + + int maxslp = MAXSLP; int saferss = SAFERSS; @@ -36,68 +44,6 @@ int multprog = -1; /* so we don't count process 2 */ double avenrun[3]; /* load average, of runnable procs */ -/* - * Setup the paging constants for the clock algorithm. - * Called after the system is initialized and the amount of memory - * and number of paging devices is known. - * - * Threshold constants are defined in ../machine/vmparam.h. - */ -setupclock() -{ - - /* - * Setup thresholds for paging: - * lotsfree is threshold where paging daemon turns on - * desfree is amount of memory desired free. if less - * than this for extended period, do swapping - * minfree is minimal amount of free memory which is - * tolerable. - */ - if (lotsfree == 0) - lotsfree = LOOPPAGES / LOTSFREEFRACT; - if (desfree == 0) { - desfree = DESFREE / NBPG; - if (desfree > LOOPPAGES / DESFREEFRACT) - desfree = LOOPPAGES / DESFREEFRACT; - } - if (minfree == 0) { - minfree = MINFREE / NBPG; - if (minfree > desfree / MINFREEFRACT) - minfree = desfree / MINFREEFRACT; - } - /* - * Maxpgio thresholds how much paging is acceptable. - * This figures that 2/3 busy on an arm is all that is - * tolerable for paging. We assume one operation per disk rev. - */ - if (maxpgio == 0) - maxpgio = (DISKRPM * 2) / 3; - - /* - * 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 (nswdev == 1 && physmem*NBPG > LOTSOFMEM*1024*(1024-16)) - printf("WARNING: should run interleaved swap with >= %dMb\n", - LOTSOFMEM); - 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/2 the fast scan time. - */ - if (slowscan == 0) - slowscan = 2 * fastscan; -} - /* * The main loop of the scheduling (swapping) process. * @@ -199,26 +145,20 @@ loop: /* * Kick out deadwood. */ - (void) spl6(); rp->p_flag &= ~SLOAD; - if (rp->p_stat == SRUN) - remrq(rp); - (void) spl0(); (void) swapout(rp, rp->p_dsize, rp->p_ssize); - goto loop; } continue; } /* - * No one wants in, so nothing to do. + * If something came ready after we checked it, + * wantin will be set. Otherwise, + * no one wants in, so nothing to do. */ if (outpri == -20000) { - (void) spl6(); - if (wantin) { - wantin = 0; - sleep((caddr_t)&lbolt, PSWP); - } else { + (void) splhigh(); + if (wantin == 0) { runout++; sleep((caddr_t)&runout, PSWP); } @@ -318,7 +258,7 @@ hardswap: * we kick the poor luser out. */ if (sleeper || desperate && p || deservin && inpri > maxslp) { - (void) spl6(); + (void) splhigh(); p->p_flag &= ~SLOAD; if (p->p_stat == SRUN) remrq(p); @@ -338,13 +278,14 @@ hardswap: gives = 0; /* someone else taketh away */ if (swapout(p, p->p_dsize, p->p_ssize) == 0) deficit -= imin(gives, deficit); - goto loop; + else + goto loop; } /* * Want to swap someone in, but can't * so wait on runin. */ - (void) spl6(); + (void) splhigh(); runin++; sleep((caddr_t)&runin, PSWP); (void) spl0(); @@ -384,8 +325,6 @@ vmmeter() } } -#define RATETOSCHEDPAGING 4 /* hz that is */ - /* * Schedule rate for paging. * Rate is linear interpolation between @@ -393,18 +332,15 @@ vmmeter() */ schedpaging() { - register int vavail, scanrate; + register int vavail; nscan = desscan = 0; vavail = freemem - deficit; if (vavail < 0) vavail = 0; if (freemem < lotsfree) { - scanrate = - (slowscan * vavail + fastscan * (lotsfree - vavail)) / - nz(lotsfree); - desscan = ((LOOPPAGES / CLSIZE) / nz(scanrate)) / - RATETOSCHEDPAGING; + desscan = (slowscan * vavail + fastscan * (lotsfree - vavail)) / + nz(lotsfree) / RATETOSCHEDPAGING; wakeup((caddr_t)&proc[2]); } timeout(schedpaging, (caddr_t)0, hz / RATETOSCHEDPAGING); @@ -455,13 +391,15 @@ next: if (p->p_flag & SSYS) continue; if (p->p_stat) { - total.t_vm += p->p_dsize + p->p_ssize; - total.t_rm += p->p_rssize; + if (p->p_stat != SZOMB) { + total.t_vm += p->p_dsize + p->p_ssize; + total.t_rm += p->p_rssize; + } switch (p->p_stat) { case SSLEEP: case SSTOP: - if (p->p_pri <= PZERO) + if (p->p_pri <= PZERO && p->p_stat == SSLEEP) nrun++; if (p->p_flag & SPAGE) total.t_pw++;