public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc
@ 2017-12-18  8:11 Jia-Ju Bai
  2017-12-18  8:54 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2017-12-18  8:11 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, linux-kernel, Jia-Ju Bai

The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context,
namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

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

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 8267439..b0d025a 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
 	int cpu;
 
 	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-					 GFP_ATOMIC);
+					 GFP_KERNEL);
 	if (hv_context.hv_numa_map == NULL) {
 		pr_err("Unable to allocate NUMA map\n");
 		goto err;
-- 
1.7.9.5

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

* Re: [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc
  2017-12-18  8:11 [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc Jia-Ju Bai
@ 2017-12-18  8:54 ` Vitaly Kuznetsov
  2017-12-18  8:58   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Kuznetsov @ 2017-12-18  8:54 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: kys, haiyangz, sthemmin, devel, linux-kernel

Jia-Ju Bai <baijiaju1990@gmail.com> writes:

> The kzalloc function is called with GFP_ATOMIC.
> But according to driver call graph, it is not in atomic context,
> namely no spinlock is held nor in an interrupt handler.
>
> This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/hv/hv.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 8267439..b0d025a 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -150,7 +150,7 @@ int hv_synic_alloc(void)
>  	int cpu;
>
>  	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
> -					 GFP_ATOMIC);
> +					 GFP_KERNEL);
>  	if (hv_context.hv_numa_map == NULL) {
>  		pr_err("Unable to allocate NUMA map\n");
>  		goto err;

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

The subject line is not very accurate: GFP_KERNEL you switch too is the
one supporting 'sleep' when there's not enough memory, not
GFP_ATOMIC so you don't actually "Fix unnecessary sleeping". I'd suggest
you use something like "hyper-v: use GFP_KERNEL for hv_context.hv_numa_map"

-- 
  Vitaly

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

* Re: [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc
  2017-12-18  8:54 ` Vitaly Kuznetsov
@ 2017-12-18  8:58   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2017-12-18  8:58 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: kys, haiyangz, sthemmin, devel, linux-kernel



On 2017/12/18 16:54, Vitaly Kuznetsov wrote:
> Jia-Ju Bai <baijiaju1990@gmail.com> writes:
>
>> The kzalloc function is called with GFP_ATOMIC.
>> But according to driver call graph, it is not in atomic context,
>> namely no spinlock is held nor in an interrupt handler.
>>
>> This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>   drivers/hv/hv.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
>> index 8267439..b0d025a 100644
>> --- a/drivers/hv/hv.c
>> +++ b/drivers/hv/hv.c
>> @@ -150,7 +150,7 @@ int hv_synic_alloc(void)
>>   	int cpu;
>>
>>   	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
>> -					 GFP_ATOMIC);
>> +					 GFP_KERNEL);
>>   	if (hv_context.hv_numa_map == NULL) {
>>   		pr_err("Unable to allocate NUMA map\n");
>>   		goto err;
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> The subject line is not very accurate: GFP_KERNEL you switch too is the
> one supporting 'sleep' when there's not enough memory, not
> GFP_ATOMIC so you don't actually "Fix unnecessary sleeping". I'd suggest
> you use something like "hyper-v: use GFP_KERNEL for hv_context.hv_numa_map"
>

Thanks for you suggestion :)
Okay, I found my description is not correct, too, sorry.
I will revise it and resubmit the patch.


Thanks,
Jia-Ju Bai

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

end of thread, other threads:[~2017-12-18  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18  8:11 [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc Jia-Ju Bai
2017-12-18  8:54 ` Vitaly Kuznetsov
2017-12-18  8:58   ` 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