linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next 0/4] blk-mq: misc changes
@ 2014-04-17 15:49 Ming Lei
  2014-04-17 15:49 ` [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed Ming Lei
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Ming Lei @ 2014-04-17 15:49 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Christoph Hellwig

Hi,

Three are fixes, and another one is cleanup.

Thanks,
--
Ming Lei


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed
  2014-04-17 15:49 [PATCH next 0/4] blk-mq: misc changes Ming Lei
@ 2014-04-17 15:49 ` Ming Lei
  2014-04-18 14:21   ` Christoph Hellwig
  2014-04-17 15:49 ` [PATCH next 2/4] blk-mq: fix allocation of set->tags Ming Lei
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-04-17 15:49 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Christoph Hellwig, Ming Lei

Avoid memory leak in the failure path.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 block/blk-mq.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ee225cc..5fbbb22 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH next 2/4] blk-mq: fix allocation of set->tags
  2014-04-17 15:49 [PATCH next 0/4] blk-mq: misc changes Ming Lei
  2014-04-17 15:49 ` [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed Ming Lei
@ 2014-04-17 15:49 ` Ming Lei
  2014-04-18 14:22   ` Christoph Hellwig
  2014-04-17 15:49 ` [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size() Ming Lei
  2014-04-17 15:49 ` [PATCH next 4/4] blk-mq: initialize req->q in allocation Ming Lei
  3 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-04-17 15:49 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Christoph Hellwig, Ming Lei

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

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 block/blk-mq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5fbbb22..baff2d0 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1537,7 +1537,7 @@ 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;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-17 15:49 [PATCH next 0/4] blk-mq: misc changes Ming Lei
  2014-04-17 15:49 ` [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed Ming Lei
  2014-04-17 15:49 ` [PATCH next 2/4] blk-mq: fix allocation of set->tags Ming Lei
@ 2014-04-17 15:49 ` Ming Lei
  2014-04-17 19:03   ` Jörg-Volker Peetz
  2014-04-17 15:49 ` [PATCH next 4/4] blk-mq: initialize req->q in allocation Ming Lei
  3 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-04-17 15:49 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Christoph Hellwig, Ming Lei

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 block/blk-mq.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index baff2d0..1eff3d9 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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 (1 << order) * PAGE_SIZE;
 }
 
 static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH next 4/4] blk-mq: initialize req->q in allocation
  2014-04-17 15:49 [PATCH next 0/4] blk-mq: misc changes Ming Lei
                   ` (2 preceding siblings ...)
  2014-04-17 15:49 ` [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size() Ming Lei
@ 2014-04-17 15:49 ` Ming Lei
  3 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2014-04-17 15:49 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Christoph Hellwig, 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

Signed-off-by: Ming Lei <tom.leiming@gmail.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 1eff3d9..b7a51ed 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-17 15:49 ` [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size() Ming Lei
@ 2014-04-17 19:03   ` Jörg-Volker Peetz
  2014-04-17 19:13     ` Max Filippov
  2014-04-18 15:47     ` Ming Lei
  0 siblings, 2 replies; 13+ messages in thread
From: Jörg-Volker Peetz @ 2014-04-17 19:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Christoph Hellwig

Ming Lei wrote, on 04/17/2014 17:49:
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
>  block/blk-mq.c |    7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index baff2d0..1eff3d9 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -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 (1 << order) * PAGE_SIZE;

Shouldn't this be

        return ((size_t)1 << order) * PAGE_SIZE;

?
>  }
>  
>  static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
> 

Regards,
jvp.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-17 19:03   ` Jörg-Volker Peetz
@ 2014-04-17 19:13     ` Max Filippov
  2014-04-18 15:47     ` Ming Lei
  1 sibling, 0 replies; 13+ messages in thread
From: Max Filippov @ 2014-04-17 19:13 UTC (permalink / raw)
  To: Jörg-Volker Peetz; +Cc: LKML, Christoph Hellwig

On Thu, Apr 17, 2014 at 11:03 PM, Jörg-Volker Peetz <jvpeetz@web.de> wrote:
> Ming Lei wrote, on 04/17/2014 17:49:
>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>> ---
>>  block/blk-mq.c |    7 +------
>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index baff2d0..1eff3d9 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -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 (1 << order) * PAGE_SIZE;
>
> Shouldn't this be
>
>         return ((size_t)1 << order) * PAGE_SIZE;
>
> ?

Maybe even

return (size_t)PAGE_SIZE << order;

?

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed
  2014-04-17 15:49 ` [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed Ming Lei
@ 2014-04-18 14:21   ` Christoph Hellwig
  0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2014-04-18 14:21 UTC (permalink / raw)
  To: Ming Lei; +Cc: Jens Axboe, linux-kernel, Christoph Hellwig

On Thu, Apr 17, 2014 at 11:49:35PM +0800, Ming Lei wrote:
> Avoid memory leak in the failure path.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 2/4] blk-mq: fix allocation of set->tags
  2014-04-17 15:49 ` [PATCH next 2/4] blk-mq: fix allocation of set->tags Ming Lei
@ 2014-04-18 14:22   ` Christoph Hellwig
  0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2014-04-18 14:22 UTC (permalink / raw)
  To: Ming Lei; +Cc: Jens Axboe, linux-kernel, Christoph Hellwig

On Thu, Apr 17, 2014 at 11:49:36PM +0800, Ming Lei wrote:
> type of set->tags is struct blk_mq_tags **.
> 
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>

Looks good, but you're now overflowing 80 character per line and need a line
break.

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-17 19:03   ` Jörg-Volker Peetz
  2014-04-17 19:13     ` Max Filippov
@ 2014-04-18 15:47     ` Ming Lei
  2014-04-18 19:23       ` Jörg-Volker Peetz
  1 sibling, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-04-18 15:47 UTC (permalink / raw)
  To: Jörg-Volker Peetz
  Cc: Jens Axboe, Linux Kernel Mailing List, Christoph Hellwig

On Fri, Apr 18, 2014 at 3:03 AM, Jörg-Volker Peetz <jvpeetz@web.de> wrote:
> Ming Lei wrote, on 04/17/2014 17:49:
>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>> ---
>>  block/blk-mq.c |    7 +------
>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index baff2d0..1eff3d9 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -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 (1 << order) * PAGE_SIZE;
>
> Shouldn't this be
>
>         return ((size_t)1 << order) * PAGE_SIZE;
>
> ?

IMO, it isn't necessary since compiler will cast type
of 1 and the expression to size_t automatically.


Thanks,
-- 
Ming Lei

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-18 15:47     ` Ming Lei
@ 2014-04-18 19:23       ` Jörg-Volker Peetz
  2014-04-19  3:17         ` Ming Lei
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg-Volker Peetz @ 2014-04-18 19:23 UTC (permalink / raw)
  To: Ming Lei; +Cc: Jens Axboe, Linux Kernel Mailing List, Christoph Hellwig

Ming Lei wrote, on 04/18/2014 17:47:
> On Fri, Apr 18, 2014 at 3:03 AM, Jörg-Volker Peetz <jvpeetz@web.de> wrote:
>> Ming Lei wrote, on 04/17/2014 17:49:
>>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>>> ---
>>>  block/blk-mq.c |    7 +------
>>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>>
>>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>>> index baff2d0..1eff3d9 100644
>>> --- a/block/blk-mq.c
>>> +++ b/block/blk-mq.c
>>> @@ -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 (1 << order) * PAGE_SIZE;
>>
>> Shouldn't this be
>>
>>         return ((size_t)1 << order) * PAGE_SIZE;
>>
>> ?
> 
> IMO, it isn't necessary since compiler will cast type
> of 1 and the expression to size_t automatically.
> 
> 
> Thanks,

Testing this with gcc 4.8.2 with order > 30 confirms that the automatic casting
is done operator-wise and the explicit casting is necessary.

Regards,
jvp.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-18 19:23       ` Jörg-Volker Peetz
@ 2014-04-19  3:17         ` Ming Lei
  2014-04-19  5:05           ` Jens Axboe
  0 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2014-04-19  3:17 UTC (permalink / raw)
  To: Jörg-Volker Peetz
  Cc: Jens Axboe, Linux Kernel Mailing List, Christoph Hellwig

On Sat, Apr 19, 2014 at 3:23 AM, Jörg-Volker Peetz <jvpeetz@web.de> wrote:
>
> Testing this with gcc 4.8.2 with order > 30 confirms that the automatic casting
> is done operator-wise and the explicit casting is necessary.

My gcc 4.8.2 doesn't complain the change, see below:

ming@ming:~/ming/linux$ gcc --version
gcc (Ubuntu/Linaro 4.8.2-19ubuntu1) 4.8.2

ming@ming:~/ming/linux$
ming@ming:~/ming/linux$ vim block/blk-mq.c
ming@ming:~/ming/linux$ ./build
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      block/blk-mq.o
  CHK     kernel/config_data.h
  LD      block/built-in.o
  LINK    vmlinux
  LD      vmlinux.o
  MODPOST vmlinux.o



Thanks,
-- 
Ming Lei

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size()
  2014-04-19  3:17         ` Ming Lei
@ 2014-04-19  5:05           ` Jens Axboe
  0 siblings, 0 replies; 13+ messages in thread
From: Jens Axboe @ 2014-04-19  5:05 UTC (permalink / raw)
  To: Ming Lei
  Cc: Jörg-Volker Peetz, Linux Kernel Mailing List,
	Christoph Hellwig

On Apr 18, 2014, at 8:17 PM, Ming Lei <tom.leiming@gmail.com> wrote:
> 
>> On Sat, Apr 19, 2014 at 3:23 AM, Jörg-Volker Peetz <jvpeetz@web.de> wrote:
>> 
>> Testing this with gcc 4.8.2 with order > 30 confirms that the automatic casting
>> is done operator-wise and the explicit casting is necessary.
> 
> My gcc 4.8.2 doesn't complain the change, see below:

It won't complain, but that doesn't mean that it won't get it wrong. The cast is necessary.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-04-19  5:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 15:49 [PATCH next 0/4] blk-mq: misc changes Ming Lei
2014-04-17 15:49 ` [PATCH next 1/4] blk-mq: free hctx->ctx_map when init failed Ming Lei
2014-04-18 14:21   ` Christoph Hellwig
2014-04-17 15:49 ` [PATCH next 2/4] blk-mq: fix allocation of set->tags Ming Lei
2014-04-18 14:22   ` Christoph Hellwig
2014-04-17 15:49 ` [PATCH next 3/4] blk-mq: user (1 << order) to implement order_to_size() Ming Lei
2014-04-17 19:03   ` Jörg-Volker Peetz
2014-04-17 19:13     ` Max Filippov
2014-04-18 15:47     ` Ming Lei
2014-04-18 19:23       ` Jörg-Volker Peetz
2014-04-19  3:17         ` Ming Lei
2014-04-19  5:05           ` Jens Axboe
2014-04-17 15:49 ` [PATCH next 4/4] blk-mq: initialize req->q in allocation Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).