diff options
author | mckusick <mckusick@FreeBSD.org> | 2001-12-14 05:50:44 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2001-12-14 05:50:44 +0000 |
commit | d3b383005d81dc439c329c685a134957e3c0b5f7 (patch) | |
tree | f5ed75c19ebd930bd74e0e630f5a2db47e7dfc5b | |
parent | 2ab37ca0c56a7fa288cc9a8797d49d5f2999834b (diff) | |
download | FreeBSD-src-d3b383005d81dc439c329c685a134957e3c0b5f7.zip FreeBSD-src-d3b383005d81dc439c329c685a134957e3c0b5f7.tar.gz |
Add disk I/O scheduling for positively niced processes.
When a positively niced process requests a disk I/O, make
it wait for its nice value of ticks before scheduling its
I/O request if there are any other processes with I/O
requests in the disk queue. For all the gory details, see
the ``Running fsck in the Background'' paper in the Usenix
BSDCon 2002 Conference Proceedings, pages 55-64.
-rw-r--r-- | sys/kern/subr_disklabel.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c index 1dc0ece..2924c55 100644 --- a/sys/kern/subr_disklabel.c +++ b/sys/kern/subr_disklabel.c @@ -44,12 +44,25 @@ #include <sys/bio.h> #include <sys/buf.h> #include <sys/conf.h> +#include <sys/kernel.h> #include <sys/disklabel.h> #include <sys/diskslice.h> #include <sys/syslog.h> #include <machine/atomic.h> /* + * Mutex to use when delaying niced I/O bound processes in bioqdisksort(). + */ +static struct mtx dksort_mtx; +static void +dksort_init(void) +{ + + mtx_init(&dksort_mtx, "dksort", MTX_DEF); +} +SYSINIT(dksort, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dksort_init, NULL) + +/* * Seek sort for disks. * * The buf_queue keep two queues, sorted in ascending block order. The first @@ -72,7 +85,19 @@ bioqdisksort(bioq, bp) struct bio *bq; struct bio *bn; struct bio *be; + struct thread *td = curthread; + if (td && td->td_ksegrp->kg_nice > 0) { + TAILQ_FOREACH(bn, &bioq->queue, bio_queue) + if (BIOTOBUF(bn)->b_vp != BIOTOBUF(bn)->b_vp) + break; + if (bn != NULL) { + mtx_lock(&dksort_mtx); + msleep((caddr_t)&dksort_mtx, &dksort_mtx, + PPAUSE | PCATCH | PDROP, "ioslow", + td->td_ksegrp->kg_nice); + } + } if (!atomic_cmpset_int(&bioq->busy, 0, 1)) panic("Recursing in bioqdisksort()"); be = TAILQ_LAST(&bioq->queue, bio_queue); |