summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Bjørling <mb@silverwolf.dk>2012-08-15 08:27:58 +0200
committerJens Axboe <axboe@kernel.dk>2012-10-04 11:04:37 +0200
commit038c9e84601e99094c575b967f2502d135a5b0ba (patch)
treecc54ba54a585c10a0eb12204c3554f906a8297b4
parentc60177dd3fcc3d850c6e578ab7e8cd91a5473029 (diff)
multiqueue: change max queue depth from 256 to 2048
To prevent extensive use of wait-queue for benchmarking the null blk driver, we raise the value to 2048 for allowing at least 80 processes each with a queue depth of 32 to summit IOs. As request structures are allocated up front, we additionally do a graceful backscaling for queue depth if memory is not possible because of fragmentation. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-mq.c23
-rw-r--r--include/linux/blk-mq.h2
2 files changed, 22 insertions, 3 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 437405468499..640e25a86a32 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -599,14 +599,33 @@ EXPORT_SYMBOL(blk_mq_free_single_hw_queue);
static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx)
{
- unsigned int num_maps;
+ unsigned int num_maps, cur_qd;
int i;
- hctx->rqs = kmalloc_node(hctx->queue_depth * sizeof(struct request),
+ /*
+ * We try to allocate all request structures up front. For highly fragmented memory
+ * this might not be possible and as a result, we lower the queue depth size and
+ * try again.
+ */
+ cur_qd = hctx->queue_depth;
+ while (cur_qd > 0) {
+ hctx->rqs = kmalloc_node(hctx->queue_depth * sizeof(struct request),
GFP_KERNEL, hctx->numa_node);
+ if (hctx->rqs)
+ break;
+
+ cur_qd >>= 1;
+ }
+
if (!hctx->rqs)
return -ENOMEM;
+ if (hctx->queue_depth != cur_qd) {
+ hctx->queue_depth = cur_qd;
+ printk(KERN_WARNING "%s: queue depth set to %u because of low memory.\n",
+ __func__, cur_qd);
+ }
+
num_maps = ALIGN(hctx->queue_depth, BITS_PER_LONG) / BITS_PER_LONG;
hctx->rq_map = kzalloc_node(num_maps * sizeof(unsigned long),
GFP_KERNEL, hctx->numa_node);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index a5a7d454065e..8aa84a58d8d9 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -85,7 +85,7 @@ enum {
BLK_MQ_F_SHOULD_IPI = 1 << 2,
BLK_MQ_F_SHOULD_LOCK = 1 << 3, /* lock on queue_rq invocation */
- BLK_MQ_MAX_DEPTH = 256,
+ BLK_MQ_MAX_DEPTH = 2048,
};
struct request_queue *blk_mq_init_queue(struct blk_mq_reg *, spinlock_t *);