linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] block: blk-tag: Replace GFP_ATOMIC with GFP_KERNEL in __blk_queue_init_tags
@ 2018-01-25  3:38 Jia-Ju Bai
  2018-01-25  3:44 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2018-01-25  3:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Jia-Ju Bai

After checking all possible call chains to kmalloc here,
my tool finds that kmalloc is never called in atomic context.
Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 block/blk-tag.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-tag.c b/block/blk-tag.c
index 09f19c6..84db7f663 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -124,7 +124,7 @@ static struct blk_queue_tag *__blk_queue_init_tags(struct request_queue *q,
 {
 	struct blk_queue_tag *tags;
 
-	tags = kmalloc(sizeof(struct blk_queue_tag), GFP_ATOMIC);
+	tags = kmalloc(sizeof(struct blk_queue_tag), GFP_KERNEL);
 	if (!tags)
 		goto fail;
 
-- 
1.7.9.5

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

* Re: [PATCH 1/2] block: blk-tag: Replace GFP_ATOMIC with GFP_KERNEL in __blk_queue_init_tags
  2018-01-25  3:38 [PATCH 1/2] block: blk-tag: Replace GFP_ATOMIC with GFP_KERNEL in __blk_queue_init_tags Jia-Ju Bai
@ 2018-01-25  3:44 ` Jens Axboe
  2018-01-25  8:03   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2018-01-25  3:44 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: linux-block, linux-kernel

On 1/24/18 8:38 PM, Jia-Ju Bai wrote:
> After checking all possible call chains to kmalloc here,
> my tool finds that kmalloc is never called in atomic context.
> Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.
> 
> This is found by a static analysis tool named DCNS written by myself.

These two look OK to me, mostly. One issue is that blk_queue_init_tags()
can be used to resize tags, in which case it's called with the
queue lock held. Nobody is using it like that anymore, though. So I'd
prefer if you did a v2 of this patch, and include a correction to that
comment.

-- 
Jens Axboe

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

* Re: [PATCH 1/2] block: blk-tag: Replace GFP_ATOMIC with GFP_KERNEL in __blk_queue_init_tags
  2018-01-25  3:44 ` Jens Axboe
@ 2018-01-25  8:03   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2018-01-25  8:03 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel



On 2018/1/25 11:44, Jens Axboe wrote:
> On 1/24/18 8:38 PM, Jia-Ju Bai wrote:
>> After checking all possible call chains to kmalloc here,
>> my tool finds that kmalloc is never called in atomic context.
>> Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.
>>
>> This is found by a static analysis tool named DCNS written by myself.
> These two look OK to me, mostly.

It sounds good :)

> One issue is that blk_queue_init_tags()
> can be used to resize tags, in which case it's called with the
> queue lock held. Nobody is using it like that anymore, though. So I'd
> prefer if you did a v2 of this patch, and include a correction to that
> comment.
>

I am not sure what you mean...

Do you mean that the code in blk_queue_init_tags:
     else if (q->queue_tags) {
         ...
     }
can be deleted?

Or just delete the comment before blk_queue_init_tags?
  * Queue lock must be held here if the function is called to resize an
  * existing map.
  **/

Or add the description "The case that queue lock held is never used" in 
my patches?


Thanks,
Jia-Ju Bai

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

end of thread, other threads:[~2018-01-25  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25  3:38 [PATCH 1/2] block: blk-tag: Replace GFP_ATOMIC with GFP_KERNEL in __blk_queue_init_tags Jia-Ju Bai
2018-01-25  3:44 ` Jens Axboe
2018-01-25  8:03   ` Jia-Ju Bai

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).