Skip to content

Commit

Permalink
null_blk: mem garbage on NUMA systems during init
Browse files Browse the repository at this point in the history
For NUMA systems, initializing the blk-mq layer and using per node hctx.
We initialize submit queues to 1, while blk-mq nr_hw_queues is
initialized to the number of NUMA nodes.

This makes the null_init_hctx function overwrite memory outside of what
it allocated.  In my case it lead to writing garbage into struct
request_queue's mq_map.

Signed-off-by: Matias Bjorling <[email protected]>
Cc: Jens Axboe <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
MatiasBjorling authored and torvalds committed Dec 15, 2013
1 parent e4158f1 commit 57053d8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/block/null_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,23 +495,23 @@ static int null_add_dev(void)

spin_lock_init(&nullb->lock);

if (queue_mode == NULL_Q_MQ && use_per_node_hctx)
submit_queues = nr_online_nodes;

if (setup_queues(nullb))
goto err;

if (queue_mode == NULL_Q_MQ) {
null_mq_reg.numa_node = home_node;
null_mq_reg.queue_depth = hw_queue_depth;
null_mq_reg.nr_hw_queues = submit_queues;

if (use_per_node_hctx) {
null_mq_reg.ops->alloc_hctx = null_alloc_hctx;
null_mq_reg.ops->free_hctx = null_free_hctx;

null_mq_reg.nr_hw_queues = nr_online_nodes;
} else {
null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue;
null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue;

null_mq_reg.nr_hw_queues = submit_queues;
}

nullb->q = blk_mq_init_queue(&null_mq_reg, nullb);
Expand Down

0 comments on commit 57053d8

Please sign in to comment.