Index: branches/freebsd10/src/sys/kern/subr_disk.c =================================================================== diff -u -N -r2284 -r2698 --- branches/freebsd10/src/sys/kern/subr_disk.c (.../subr_disk.c) (revision 2284) +++ branches/freebsd10/src/sys/kern/subr_disk.c (.../subr_disk.c) (revision 2698) @@ -21,8 +21,13 @@ #include #include #include +#include #include +static int bioq_batchsize = 128; +SYSCTL_INT(_debug, OID_AUTO, bioq_batchsize, CTLFLAG_RW, + &bioq_batchsize, 0, "BIOQ batch size"); + /*- * Disk error is the preface to plaintive error messages * about failing disk transfers. It prints messages of the form @@ -150,6 +155,8 @@ TAILQ_INIT(&head->queue); head->last_offset = 0; head->insert_point = NULL; + head->total = 0; + head->batched = 0; } void @@ -163,6 +170,7 @@ head->insert_point = NULL; TAILQ_REMOVE(&head->queue, bp, bio_queue); + head->total--; } void @@ -181,13 +189,16 @@ if (head->insert_point == NULL) head->last_offset = bp->bio_offset; TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); + head->total++; } void bioq_insert_tail(struct bio_queue_head *head, struct bio *bp) { TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue); + head->total++; + head->batched = 0; head->insert_point = bp; head->last_offset = bp->bio_offset; } @@ -246,6 +257,11 @@ return; } + if (bioq_batchsize > 0 && head->batched > bioq_batchsize) { + bioq_insert_tail(head, bp); + return; + } + prev = NULL; key = bioq_bio_key(head, bp); cur = TAILQ_FIRST(&head->queue); @@ -264,4 +280,7 @@ TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); else TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue); + + head->total++; + head->batched++; } Index: branches/freebsd10/src/sys/sys/bio.h =================================================================== diff -u -N -r2284 -r2698 --- branches/freebsd10/src/sys/sys/bio.h (.../bio.h) (revision 2284) +++ branches/freebsd10/src/sys/sys/bio.h (.../bio.h) (revision 2698) @@ -129,6 +129,8 @@ TAILQ_HEAD(bio_queue, bio) queue; off_t last_offset; struct bio *insert_point; + int total; + int batched; }; extern struct vm_map *bio_transient_map;