summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>1999-04-07 02:41:54 +0000
committeralc <alc@FreeBSD.org>1999-04-07 02:41:54 +0000
commit7c9bf17e255d3dab0dd8586726cc51fedda0b184 (patch)
tree12d920a4dae784610781c6fcbca9e0a22dbc7f61 /sys/kern/vfs_bio.c
parent213baed96f222462de1e0f9e6a6f62a87866b0cc (diff)
downloadFreeBSD-src-7c9bf17e255d3dab0dd8586726cc51fedda0b184.zip
FreeBSD-src-7c9bf17e255d3dab0dd8586726cc51fedda0b184.tar.gz
Fix a performance problem with the new getnewbuf() code: in an outofspace
condition ( bufspace > hibufspace ), an inappropriate scan of the empty queue was performed looking for buffer space to free up. Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 3cc6b94..58d463b 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -11,7 +11,7 @@
* 2. Absolutely no warranty of function or purpose is made by the author
* John S. Dyson.
*
- * $Id: vfs_bio.c,v 1.203 1999/03/19 10:17:44 bde Exp $
+ * $Id: vfs_bio.c,v 1.204 1999/04/05 19:38:30 julian Exp $
*/
/*
@@ -1132,6 +1132,29 @@ getnewbuf(struct vnode *vp, daddr_t blkno,
int countawrites = 0;
restart:
+ /*
+ * Calculate whether we are out of buffer space. This state is
+ * recalculated on every restart. If we are out of space, we
+ * have to turn off defragmentation. The outofspace code will
+ * defragment too, but the looping conditionals will be messed up
+ * if both outofspace and defrag are on.
+ */
+
+ outofspace = 0;
+ if (bufspace >= hibufspace) {
+ if ((curproc->p_flag & P_FLSINPROG) == 0 ||
+ bufspace >= maxbufspace
+ ) {
+ outofspace = 1;
+ defrag = 0;
+ }
+ }
+
+ /*
+ * defrag state is semi-persistant. 1 means we are flagged for
+ * defragging. -1 means we actually defragged something.
+ */
+ /* nop */
/*
* Setup for scan. If we do not have enough free buffers,
@@ -1139,6 +1162,9 @@ restart:
*
* If we are in the middle of a flush, we can dip into the
* emergency reserve.
+ *
+ * If we are out of space, we skip trying to scan QUEUE_EMPTY
+ * because those buffers are, well, empty.
*/
if ((curproc->p_flag & P_FLSINPROG) == 0 &&
@@ -1148,7 +1174,9 @@ restart:
nbp = NULL;
} else {
nqindex = QUEUE_EMPTY;
- if ((nbp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY])) == NULL) {
+ if (outofspace ||
+ (nbp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY])) == NULL
+ ) {
nqindex = QUEUE_AGE;
nbp = TAILQ_FIRST(&bufqueues[QUEUE_AGE]);
if (nbp == NULL) {
@@ -1159,30 +1187,6 @@ restart:
}
/*
- * Calculate whether we are out of buffer space. This state is
- * recalculated on every restart. If we are out of space, we
- * have to turn off defragmentation. The outofspace code will
- * defragment too, but the looping conditionals will be messed up
- * if both outofspace and defrag are on.
- */
-
- outofspace = 0;
- if (bufspace >= hibufspace) {
- if ((curproc->p_flag & P_FLSINPROG) == 0 ||
- bufspace >= maxbufspace
- ) {
- outofspace = 1;
- defrag = 0;
- }
- }
-
- /*
- * defrag state is semi-persistant. 1 means we are flagged for
- * defragging. -1 means we actually defragged something.
- */
- /* nop */
-
- /*
* Run scan, possibly freeing data and/or kva mappings on the fly
* depending.
*/
OpenPOWER on IntegriCloud