summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_swap.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-01-09 16:06:02 +0000
committerdg <dg@FreeBSD.org>1995-01-09 16:06:02 +0000
commit1707d41102ca7d645ec2db9e442a27857337d7e9 (patch)
treeafd2f1c13b93c3fff08b58c44153df0d13479824 /sys/vm/vm_swap.c
parent08ff911ba0fc8f893be057ca25d8b941f6d0f276 (diff)
downloadFreeBSD-src-1707d41102ca7d645ec2db9e442a27857337d7e9.zip
FreeBSD-src-1707d41102ca7d645ec2db9e442a27857337d7e9.tar.gz
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It represents the culmination of over 6 months of R&D. The majority of the merged VM/cache work is by John Dyson. The following highlights the most significant changes. Additionally, there are (mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to support the new VM/buffer scheme. vfs_bio.c: Significant rewrite of most of vfs_bio to support the merged VM buffer cache scheme. The scheme is almost fully compatible with the old filesystem interface. Significant improvement in the number of opportunities for write clustering. vfs_cluster.c, vfs_subr.c Upgrade and performance enhancements in vfs layer code to support merged VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff. vm_object.c: Yet more improvements in the collapse code. Elimination of some windows that can cause list corruption. vm_pageout.c: Fixed it, it really works better now. Somehow in 2.0, some "enhancements" broke the code. This code has been reworked from the ground-up. vm_fault.c, vm_page.c, pmap.c, vm_object.c Support for small-block filesystems with merged VM/buffer cache scheme. pmap.c vm_map.c Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of kernel PTs. vm_glue.c Much simpler and more effective swapping code. No more gratuitous swapping. proc.h Fixed the problem that the p_lock flag was not being cleared on a fork. swap_pager.c, vnode_pager.c Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the code doesn't need it anymore. machdep.c Changes to better support the parameter values for the merged VM/buffer cache scheme. machdep.c, kern_exec.c, vm_glue.c Implemented a seperate submap for temporary exec string space and another one to contain process upages. This eliminates all map fragmentation problems that previously existed. ffs_inode.c, ufs_inode.c, ufs_readwrite.c Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on busy buffers. Submitted by: John Dyson and David Greenman
Diffstat (limited to 'sys/vm/vm_swap.c')
-rw-r--r--sys/vm/vm_swap.c95
1 files changed, 49 insertions, 46 deletions
diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c
index be750b1..3f59f2e 100644
--- a/sys/vm/vm_swap.c
+++ b/sys/vm/vm_swap.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
- * $Id: vm_swap.c,v 1.11 1994/10/22 17:53:35 phk Exp $
+ * $Id: vm_swap.c,v 1.12 1994/11/22 08:47:20 davidg Exp $
*/
#include <sys/param.h>
@@ -51,15 +51,18 @@
* Indirect driver for multi-controller paging.
*/
-int nswap, nswdev;
-int vm_swap_size;
+int nswap, nswdev;
+int vm_swap_size;
+
#ifdef SEQSWAP
-int niswdev; /* number of interleaved swap devices */
-int niswap; /* size of interleaved swap area */
+int niswdev; /* number of interleaved swap devices */
+int niswap; /* size of interleaved swap area */
+
#endif
int bswneeded;
vm_offset_t swapbkva; /* swap buffers kva */
+
/*
* Set up swap devices.
* Initialize linked list of free swap
@@ -75,12 +78,12 @@ swapinit()
int error;
/*
- * Count swap devices, and adjust total swap space available.
- * Some of the space will not be countable until later (dynamically
+ * Count swap devices, and adjust total swap space available. Some of
+ * the space will not be countable until later (dynamically
* configurable devices) and some of the counted space will not be
* available until a swapon() system call is issued, both usually
* happen when the system goes multi-user.
- *
+ *
* If using NFS for swap, swdevt[0] will already be bdevvp'd. XXX
*/
#ifdef SEQSWAP
@@ -104,7 +107,7 @@ swapinit()
/*
* The remainder must be sequential
*/
- for ( ; swp->sw_dev != NODEV; swp++) {
+ for (; swp->sw_dev != NODEV; swp++) {
if ((swp->sw_flags & SW_SEQUENTIAL) == 0)
panic("binit: mis-ordered swap devices");
nswdev++;
@@ -136,13 +139,13 @@ swapinit()
panic("swapvp");
#endif
/*
- * If there is no swap configured, tell the user. We don't automatically
- * activate any swapspaces in the kernel; the user must explicitly use
- * swapon to enable swaping on a device.
+ * If there is no swap configured, tell the user. We don't
+ * automatically activate any swapspaces in the kernel; the user must
+ * explicitly use swapon to enable swaping on a device.
*/
if (nswap == 0)
printf("WARNING: no swap space found\n");
- for (swp = swdevt; ;swp++) {
+ for (swp = swdevt;; swp++) {
if (swp->sw_dev == NODEV) {
if (swp->sw_vp == NULL)
break;
@@ -151,8 +154,8 @@ swapinit()
error = swfree(p, swp - swdevt);
if (error) {
printf(
- "Couldn't enable swapspace %d, error = %d",
- swp-swdevt,error);
+ "Couldn't enable swapspace %d, error = %d",
+ swp - swdevt, error);
}
}
}
@@ -168,10 +171,9 @@ swstrategy(bp)
#ifdef GENERIC
/*
- * A mini-root gets copied into the front of the swap
- * and we run over top of the swap area just long
- * enough for us to do a mkfs and restor of the real
- * root (sure beats rewriting standalone restor).
+ * A mini-root gets copied into the front of the swap and we run over
+ * top of the swap area just long enough for us to do a mkfs and
+ * restor of the real root (sure beats rewriting standalone restor).
*/
#define MINIROOTSIZE 4096
if (rootdev == dumpdev)
@@ -189,7 +191,7 @@ swstrategy(bp)
if (bp->b_blkno < niswap) {
if (niswdev > 1) {
off = bp->b_blkno % dmmax;
- if (off+sz > dmmax) {
+ if (off + sz > dmmax) {
bp->b_error = EINVAL;
bp->b_flags |= B_ERROR;
biodone(bp);
@@ -198,7 +200,7 @@ swstrategy(bp)
seg = bp->b_blkno / dmmax;
index = seg % niswdev;
seg /= niswdev;
- bp->b_blkno = seg*dmmax + off;
+ bp->b_blkno = seg * dmmax + off;
} else
index = 0;
} else {
@@ -206,16 +208,16 @@ swstrategy(bp)
bp->b_blkno -= niswap;
for (index = niswdev, swp = &swdevt[niswdev];
- swp->sw_dev != NODEV;
- swp++, index++) {
+ swp->sw_dev != NODEV;
+ swp++, index++) {
if (bp->b_blkno < swp->sw_nblks)
break;
bp->b_blkno -= swp->sw_nblks;
}
if (swp->sw_dev == NODEV ||
- bp->b_blkno+sz > swp->sw_nblks) {
+ bp->b_blkno + sz > swp->sw_nblks) {
bp->b_error = swp->sw_dev == NODEV ?
- ENODEV : EINVAL;
+ ENODEV : EINVAL;
bp->b_flags |= B_ERROR;
biodone(bp);
return;
@@ -223,7 +225,7 @@ swstrategy(bp)
}
#else
off = bp->b_blkno % dmmax;
- if (off+sz > dmmax) {
+ if (off + sz > dmmax) {
bp->b_error = EINVAL;
bp->b_flags |= B_ERROR;
biodone(bp);
@@ -232,7 +234,7 @@ swstrategy(bp)
seg = bp->b_blkno / dmmax;
index = seg % nswdev;
seg /= nswdev;
- bp->b_blkno = seg*dmmax + off;
+ bp->b_blkno = seg * dmmax + off;
#endif
} else
index = 0;
@@ -252,13 +254,13 @@ swstrategy(bp)
vp->v_numoutput--;
if ((vp->v_flag & VBWAIT) && vp->v_numoutput <= 0) {
vp->v_flag &= ~VBWAIT;
- wakeup((caddr_t)&vp->v_numoutput);
+ wakeup((caddr_t) & vp->v_numoutput);
}
}
sp->sw_vp->v_numoutput++;
}
if (bp->b_vp != NULL)
- brelvp(bp);
+ pbrelvp(bp);
bp->b_vp = sp->sw_vp;
VOP_STRATEGY(bp);
}
@@ -269,8 +271,9 @@ swstrategy(bp)
* if already swapping on this device.
*/
struct swapon_args {
- char *name;
+ char *name;
};
+
/* ARGSUSED */
int
swapon(p, uap, retval)
@@ -296,7 +299,7 @@ swapon(p, uap, retval)
vrele(vp);
return (ENOTBLK);
}
- dev = (dev_t)vp->v_rdev;
+ dev = (dev_t) vp->v_rdev;
if (major(dev) >= nblkdev) {
vrele(vp);
return (ENXIO);
@@ -318,11 +321,11 @@ swapon(p, uap, retval)
#ifdef SEQSWAP
/*
* If we have reached a non-freed sequential device without
- * finding what we are looking for, it is an error.
- * That is because all interleaved devices must come first
- * and sequential devices must be freed in order.
+ * finding what we are looking for, it is an error. That is
+ * because all interleaved devices must come first and
+ * sequential devices must be freed in order.
*/
- if ((sp->sw_flags & (SW_SEQUENTIAL|SW_FREED)) == SW_SEQUENTIAL)
+ if ((sp->sw_flags & (SW_SEQUENTIAL | SW_FREED)) == SW_SEQUENTIAL)
break;
#endif
}
@@ -351,22 +354,22 @@ swfree(p, index)
sp = &swdevt[index];
vp = sp->sw_vp;
- error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p);
+ error = VOP_OPEN(vp, FREAD | FWRITE, p->p_ucred, p);
if (error)
return (error);
sp->sw_flags |= SW_FREED;
nblks = sp->sw_nblks;
/*
- * Some devices may not exist til after boot time.
- * If so, their nblk count will be 0.
+ * Some devices may not exist til after boot time. If so, their nblk
+ * count will be 0.
*/
if (nblks <= 0) {
int perdev;
dev_t dev = sp->sw_dev;
if (bdevsw[major(dev)].d_psize == 0 ||
- (nblks = (*bdevsw[major(dev)].d_psize)(dev)) == -1) {
- (void) VOP_CLOSE(vp, FREAD|FWRITE, p->p_ucred, p);
+ (nblks = (*bdevsw[major(dev)].d_psize) (dev)) == -1) {
+ (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p);
sp->sw_flags &= ~SW_FREED;
return (ENXIO);
}
@@ -388,7 +391,7 @@ swfree(p, index)
sp->sw_nblks = nblks;
}
if (nblks == 0) {
- (void) VOP_CLOSE(vp, FREAD|FWRITE, p->p_ucred, p);
+ (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p);
sp->sw_flags &= ~SW_FREED;
return (0); /* XXX error? */
}
@@ -399,26 +402,26 @@ swfree(p, index)
blk = niswap;
for (swp = &swdevt[niswdev]; swp != sp; swp++)
blk += swp->sw_nblks;
- rlist_free(&swaplist, blk, blk + nblks - 1);
+ rlist_free(&swaplist, blk, blk + nblks - 1);
vm_swap_size += nblks;
return (0);
}
#endif
for (dvbase = dmmax; dvbase < nblks; dvbase += dmmax) {
blk = nblks - dvbase;
-
+
#ifdef SEQSWAP
- if ((vsbase = index*dmmax + dvbase*niswdev) >= niswap)
+ if ((vsbase = index * dmmax + dvbase * niswdev) >= niswap)
panic("swfree");
#else
- if ((vsbase = index*dmmax + dvbase*nswdev) >= nswap)
+ if ((vsbase = index * dmmax + dvbase * nswdev) >= nswap)
panic("swfree");
#endif
if (blk > dmmax)
blk = dmmax;
/* XXX -- we need to exclude the first cluster as above */
/* but for now, this will work fine... */
- rlist_free(&swaplist, vsbase, vsbase + blk - 1);
+ rlist_free(&swaplist, vsbase, vsbase + blk - 1);
vm_swap_size += blk;
}
return (0);
OpenPOWER on IntegriCloud