diff mbox

blk-mq: only alloc hctx point as many as nr_hw_queues

Message ID 20170713161020.GA10325@bogon.didichuxing.com (mailing list archive)
State New, archived
Headers show

Commit Message

weiping zhang July 13, 2017, 4:10 p.m. UTC
one hw queue only has one hctx, reduce it's number same as nr_hw_queues.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 block/blk-mq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jens Axboe July 13, 2017, 4:14 p.m. UTC | #1
On 07/13/2017 10:10 AM, weiping zhang wrote:
> one hw queue only has one hctx, reduce it's number same as nr_hw_queues.

What happens if a device registers with eg 4 hw queues, then later
calls blk_mq_update_nr_hw_queues()?
weiping zhang July 13, 2017, 4:30 p.m. UTC | #2
On Thu, Jul 13, 2017 at 10:14:31AM -0600, Jens Axboe wrote:
> On 07/13/2017 10:10 AM, weiping zhang wrote:
> > one hw queue only has one hctx, reduce it's number same as nr_hw_queues.
> 
> What happens if a device registers with eg 4 hw queues, then later
> calls blk_mq_update_nr_hw_queues()?
> 

your means, 10 cpu, and  device has 10 hw queues, but  only register 4,
and then update it to 10, no place store new hctx. Am i understanding
right ? if yes, could you tell me why driver do that ? thanks.

--
weiping
Jens Axboe July 13, 2017, 4:38 p.m. UTC | #3
On 07/13/2017 10:30 AM, weiping zhang wrote:
> On Thu, Jul 13, 2017 at 10:14:31AM -0600, Jens Axboe wrote:
>> On 07/13/2017 10:10 AM, weiping zhang wrote:
>>> one hw queue only has one hctx, reduce it's number same as nr_hw_queues.
>>
>> What happens if a device registers with eg 4 hw queues, then later
>> calls blk_mq_update_nr_hw_queues()?
>>
> 
> your means, 10 cpu, and  device has 10 hw queues, but  only register 4,
> and then update it to 10, no place store new hctx. Am i understanding
> right ? if yes, could you tell me why driver do that ? thanks.

It doesn't matter why the driver would do that, the fact is that this is
a feature we support and it's a part of the API. NBD uses it, for
instance. Your patch breaks it, for saving a bit of memory. So I will
not include it.
diff mbox

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 05dfa3f..8c98f59 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2320,8 +2320,8 @@  struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
 	/* init q->mq_kobj and sw queues' kobjects */
 	blk_mq_sysfs_init(q);
 
-	q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)),
-						GFP_KERNEL, set->numa_node);
+	q->queue_hw_ctx = kzalloc_node(set->nr_hw_queues *
+			sizeof(*(q->queue_hw_ctx)),GFP_KERNEL, set->numa_node);
 	if (!q->queue_hw_ctx)
 		goto err_percpu;