diff mbox series

block: update hctx map when use multiple maps

Message ID 20200617061830.GA15100@192.168.3.9 (mailing list archive)
State New, archived
Headers show
Series block: update hctx map when use multiple maps | expand

Commit Message

Weiping Zhang June 17, 2020, 6:18 a.m. UTC
There is an issue when tune the number for read and write queues,
if the total queue count was not changed. The hctx->type cannot
be updated, since __blk_mq_update_nr_hw_queues will return directly
if the total queue count has not been changed.

Reproduce:

dmesg | grep "default/read/poll"
[    2.607459] nvme nvme0: 48/0/0 default/read/poll queues
cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
     48 default

tune the write queues to 24:
echo 24 > /sys/module/nvme/parameters/write_queues
echo 1 > /sys/block/nvme0n1/device/reset_controller

dmesg | grep "default/read/poll"
[  433.547235] nvme nvme0: 24/24/0 default/read/poll queues

cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
     48 default

The driver's hardware queue mapping is not same as block layer.

Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com>
---
 block/blk-mq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ming Lei June 18, 2020, 2:49 a.m. UTC | #1
On Wed, Jun 17, 2020 at 02:18:37PM +0800, Weiping Zhang wrote:
> There is an issue when tune the number for read and write queues,
> if the total queue count was not changed. The hctx->type cannot
> be updated, since __blk_mq_update_nr_hw_queues will return directly
> if the total queue count has not been changed.
> 
> Reproduce:
> 
> dmesg | grep "default/read/poll"
> [    2.607459] nvme nvme0: 48/0/0 default/read/poll queues
> cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
>      48 default
> 
> tune the write queues to 24:
> echo 24 > /sys/module/nvme/parameters/write_queues
> echo 1 > /sys/block/nvme0n1/device/reset_controller
> 
> dmesg | grep "default/read/poll"
> [  433.547235] nvme nvme0: 24/24/0 default/read/poll queues
> 
> cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
>      48 default
> 
> The driver's hardware queue mapping is not same as block layer.
> 
> Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com>
> ---
>  block/blk-mq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 4f57d27bfa73..a9aa6d1e44cf 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -3479,7 +3479,9 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
>  
>  	if (set->nr_maps == 1 && nr_hw_queues > nr_cpu_ids)
>  		nr_hw_queues = nr_cpu_ids;
> -	if (nr_hw_queues < 1 || nr_hw_queues == set->nr_hw_queues)
> +	if (nr_hw_queues < 1)
> +		return;
> +	if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues)
>  		return;
>  
>  	list_for_each_entry(q, &set->tag_list, tag_set_list)
> -- 
> 2.18.2
> 

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Jens Axboe June 18, 2020, 3:33 a.m. UTC | #2
On 6/17/20 12:18 AM, Weiping Zhang wrote:
> There is an issue when tune the number for read and write queues,
> if the total queue count was not changed. The hctx->type cannot
> be updated, since __blk_mq_update_nr_hw_queues will return directly
> if the total queue count has not been changed.
> 
> Reproduce:
> 
> dmesg | grep "default/read/poll"
> [    2.607459] nvme nvme0: 48/0/0 default/read/poll queues
> cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
>      48 default
> 
> tune the write queues to 24:
> echo 24 > /sys/module/nvme/parameters/write_queues
> echo 1 > /sys/block/nvme0n1/device/reset_controller
> 
> dmesg | grep "default/read/poll"
> [  433.547235] nvme nvme0: 24/24/0 default/read/poll queues
> 
> cat /sys/kernel/debug/block/nvme0n1/hctx*/type | sort | uniq -c
>      48 default
> 
> The driver's hardware queue mapping is not same as block layer.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4f57d27bfa73..a9aa6d1e44cf 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3479,7 +3479,9 @@  static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 
 	if (set->nr_maps == 1 && nr_hw_queues > nr_cpu_ids)
 		nr_hw_queues = nr_cpu_ids;
-	if (nr_hw_queues < 1 || nr_hw_queues == set->nr_hw_queues)
+	if (nr_hw_queues < 1)
+		return;
+	if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues)
 		return;
 
 	list_for_each_entry(q, &set->tag_list, tag_set_list)