Skip to contentSkip to conversation

nvme-tcp: initialize the mq_map to NULL

PATCH In review Chaitanya Kulkarni 4 participants 6 messages Jan 9, 2025 – Jan 11, 2025 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nvme-tcp: initialize the mq_map to NULL

Initialize the local variable mq_map to NULL to remove the kernel test robot warning.

drivers/nvme/host/tcp.c:1594:13: warning: variable 'mq_map' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Fixes bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers")
---
 drivers/nvme/host/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/tcp.c +1 -1
index 544d6aa00cc3..d6a40b7dba73 100644
@@ -1578,7 +1578,7 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue)
 	struct nvme_tcp_ctrl *ctrl = queue->ctrl;
 	struct blk_mq_tag_set *set = &ctrl->tag_set;
 	int qid = nvme_tcp_queue_id(queue) - 1;
-	unsigned int *mq_map;
+	unsigned int *mq_map = NULL;
 	int cpu, n = 0, min_queues = INT_MAX, io_cpu;
 
 	if (wq_unbound)
Signature · 1 line
2.40.0
#1 lore raw

PATCH 2/2 nvme-tcp: remove unused variable

The variable n declared in nvme_tcp_set_queue_io_cpu() was used in the original calculation when tcp target was created.

With addtion of commit bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu
spreading for multiple controllers") now all the calculation is based
on io_cpu and mq_map local variable is n is not, resulting in the
kernel test robot warning :-
drivers/nvme/host/tcp.c:1583:18: warning: variable 'n' set but not used [-Wunused-but-set-variable]

Remove the local variable and respective calculations.

Fixes bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers")
---
 drivers/nvme/host/tcp.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/nvme/host/tcp.c +5 -9
index d6a40b7dba73..e9ff6babc540 100644
@@ -1579,22 +1579,18 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue)
 	struct blk_mq_tag_set *set = &ctrl->tag_set;
 	int qid = nvme_tcp_queue_id(queue) - 1;
 	unsigned int *mq_map = NULL;
-	int cpu, n = 0, min_queues = INT_MAX, io_cpu;
+	int cpu, min_queues = INT_MAX, io_cpu;
 
 	if (wq_unbound)
 		goto out;
 
-	if (nvme_tcp_default_queue(queue)) {
+	if (nvme_tcp_default_queue(queue))
 		mq_map = set->map[HCTX_TYPE_DEFAULT].mq_map;
-		n = qid;
-	} else if (nvme_tcp_read_queue(queue)) {
+	else if (nvme_tcp_read_queue(queue))
 		mq_map = set->map[HCTX_TYPE_READ].mq_map;
-		n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT];
-	} else if (nvme_tcp_poll_queue(queue)) {
+	else if (nvme_tcp_poll_queue(queue))
 		mq_map = set->map[HCTX_TYPE_POLL].mq_map;
-		n = qid - ctrl->io_queues[HCTX_TYPE_DEFAULT] -
-				ctrl->io_queues[HCTX_TYPE_READ];
-	}
+
 	if (WARN_ON(!mq_map))
 		goto out;
 
Signature · 1 line
2.40.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] nvme-tcp: remove unused variable

Quoted 6 lines · Chaitanya Kulkarni

The variable n declared in nvme_tcp_set_queue_io_cpu() was used in the original calculation when tcp target was created.

With addtion of commit bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers") now all the calculation is based on io_cpu and mq_map local variable is n is not, resulting in the

Maybe typo: 's/"local variable is n is not,"/", and local variable n is not used,"/g' Otherwise looks good, please feel free to add:

Reviewed-by on v1 1/2
#3 lore raw
In reply to Chaitanya Kulkarni
Quoted 19 lines · Chaitanya Kulkarni

Initialize the local variable mq_map to NULL to remove the kernel test robot warning.

drivers/nvme/host/tcp.c:1594:13: warning: variable 'mq_map' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Fixes bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers")
---
 drivers/nvme/host/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/tcp.c +0 -0
index 544d6aa00cc3..d6a40b7dba73 100644

drivers/nvme/host/tcp.c static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue) · line 1584

Quoted 8 lines
drivers/nvme/host/tcp.c +1 -1
@@ -1578,7 +1578,7 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue)
 	struct nvme_tcp_ctrl *ctrl = queue->ctrl;
 	struct blk_mq_tag_set *set = &ctrl->tag_set;
 	int qid = nvme_tcp_queue_id(queue) - 1;
-	unsigned int *mq_map;
+	unsigned int *mq_map = NULL;
 	int cpu, n = 0, min_queues = INT_MAX, io_cpu;
 
 	if (wq_unbound)

Looks good.

maintainer
#4 lore raw
In reply to Chaitanya Kulkarni
Quoted 10 lines · Chaitanya Kulkarni

Initialize the local variable mq_map to NULL to remove the kernel test robot warning.

drivers/nvme/host/tcp.c:1594:13: warning: variable 'mq_map' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Fixes bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers")

We should probably just fold both this and the next one to the original patch.

maintainer
#5 lore raw
Quoted 10 lines · Sagi Grimberg
Quoted 6 lines · Chaitanya Kulkarni

Initialize the local variable mq_map to NULL to remove the kernel test robot warning.

drivers/nvme/host/tcp.c:1594:13: warning: variable 'mq_map' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Quoted 7 lines
Quoted 4 lines
Fixes bd0f5c103101 ("nvme-tcp: Fix I/O queue cpu spreading for multiple controllers")

We should probably just fold both this and the next one to the original patch.

Sure, folded in with an updated commit message to reflect Chaitanya's changes.