Skip to contentSkip to conversation

blk-mq: misc changes

PATCH In review Ming Lei 2 participants 7 messages Apr 19, 2014 – Apr 22, 2014 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover blk-mq: misc changes

Hi,

Three of them are fixes, another one is cleanup.

V1:
- line break(2/4)
- use explicit cast(3/4)

Thanks,
--
Ming Lei

author
#1 lore raw

PATCH 1/4 blk-mq: free hctx->ctx_map when init failed

Avoid memory leak in the failure path.

---
 block/blk-mq.c |    1 +
 1 file changed, 1 insertion(+)
block/blk-mq.c +1 -0
index ee225cc..5fbbb22 100644
@@ -1289,6 +1289,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q,
 
 		blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier);
 		kfree(hctx->ctxs);
+		kfree(hctx->ctx_map);
 	}
 
 	return 1;
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/4 blk-mq: fix allocation of set->tags

In reply to Ming Lei

type of set->tags is struct blk_mq_tags **.

---
 block/blk-mq.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-mq.c +2 -1
index 5fbbb22..c277797 100644
@@ -1537,7 +1537,8 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
 		return -EINVAL;
 
 
-	set->tags = kmalloc_node(set->nr_hw_queues * sizeof(struct blk_mq_tags),
+	set->tags = kmalloc_node(set->nr_hw_queues *
+				 sizeof(struct blk_mq_tags *),
 				 GFP_KERNEL, set->numa_node);
 	if (!set->tags)
 		goto out;
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/4 blk-mq: user (1 << order) to implement order_to_size()

In reply to Ming Lei
Cc Jörg-Volker Peetz <[email protected]>
Cc Max Filippov <[email protected]>
---
 block/blk-mq.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
block/blk-mq.c +1 -6
index c277797..3a560a4 100644
@@ -1130,12 +1130,7 @@ static void blk_mq_free_rq_map(struct blk_mq_tag_set *set,
 
 static size_t order_to_size(unsigned int order)
 {
-	size_t ret = PAGE_SIZE;
-
-	while (order--)
-		ret *= 2;
-
-	return ret;
+	return (size_t)PAGE_SIZE << order;
 }
 
 static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/4 blk-mq: initialize req->q in allocation

In reply to Ming Lei

The patch basically reverts the patch of(blk-mq:
initialize request on allocation) in Jens's tree(already in -next), and only initialize req->q in allocation for two reasons:

- presumed cache hotness on completion
- blk_rq_tagged(rq) depends on reset of req->mq_ctx

---
 block/blk-mq.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-mq.c +3 -1
index 3a560a4..c26b3be 100644
@@ -82,7 +82,6 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
 	tag = blk_mq_get_tag(hctx->tags, gfp, reserved);
 	if (tag != BLK_MQ_TAG_FAIL) {
 		rq = hctx->tags->rqs[tag];
-		blk_rq_init(hctx->queue, rq);
 		rq->tag = tag;
 
 		return rq;
@@ -187,6 +186,7 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
 	if (blk_queue_io_stat(q))
 		rw_flags |= REQ_IO_STAT;
 
+	rq->q = q;
 	rq->mq_ctx = ctx;
 	rq->cmd_flags = rw_flags;
 	rq->start_time = jiffies;
@@ -258,6 +258,7 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx,
 	const int tag = rq->tag;
 	struct request_queue *q = rq->q;
 
+	blk_rq_init(hctx->queue, rq);
 	blk_mq_put_tag(hctx->tags, tag);
 	blk_mq_queue_exit(q);
 }
@@ -1194,6 +1195,7 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
 		left -= to_do * rq_size;
 		for (j = 0; j < to_do; j++) {
 			tags->rqs[i] = p;
+			blk_rq_init(NULL, tags->rqs[i]);
 			if (set->ops->init_request) {
 				if (set->ops->init_request(set->driver_data,
 						tags->rqs[i], hctx_idx, i,
Signature · 1 line
1.7.9.5
maintainer
#5 lore raw
In reply to Ming Lei
Quoted 7 lines · Ming Lei

Hi,

Three of them are fixes, another one is cleanup.

V1:
- line break(2/4)
- use explicit cast(3/4)

I believe this is v2, but I guess your first posting was v0 :-) Applied for testing for 3.16, thanks.

Signature · 1 line
Jens Axboe
author
#6 lore raw
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Ming Lei

Hi,

Three of them are fixes, another one is cleanup.

Quoted 7 lines
Quoted 3 lines

V1:
- line break(2/4)
- use explicit cast(3/4)

I believe this is v2, but I guess your first posting was v0 :-) Applied for testing for 3.16, thanks.

Yeah, it is the C programming style, :-)

Thanks,

Signature · 1 line
Ming Lei