All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: decnet: Replace GFP_ATOMIC with GFP_KERNEL in dn_route_init
@ 2018-04-09 14:10 Jia-Ju Bai
  2018-04-09 14:44 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-09 14:10 UTC (permalink / raw)
  To: davem, kafai, weiwan, dsa, johannes.berg, fw
  Cc: linux-decnet-user, netdev, linux-kernel, Jia-Ju Bai

dn_route_init() is never called in atomic context.

The call chain ending up at dn_route_init() is:
[1] dn_route_init() <- decnet_init()
decnet_init() is only set as a parameter of module_init().

Despite never getting called from atomic context,
dn_route_init() calls __get_free_pages() with GFP_ATOMIC,
which waits busily for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
to avoid busy waiting and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

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

diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 0bd3afd..59ed12a 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1898,7 +1898,7 @@ void __init dn_route_init(void)
 		while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
 			dn_rt_hash_mask--;
 		dn_rt_hash_table = (struct dn_rt_hash_bucket *)
-			__get_free_pages(GFP_ATOMIC, order);
+			__get_free_pages(GFP_KERNEL, order);
 	} while (dn_rt_hash_table == NULL && --order > 0);
 
 	if (!dn_rt_hash_table)
-- 
1.9.1

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

* Re: [PATCH] net: decnet: Replace GFP_ATOMIC with GFP_KERNEL in dn_route_init
  2018-04-09 14:10 [PATCH] net: decnet: Replace GFP_ATOMIC with GFP_KERNEL in dn_route_init Jia-Ju Bai
@ 2018-04-09 14:44 ` Eric Dumazet
  2018-04-09 14:48   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2018-04-09 14:44 UTC (permalink / raw)
  To: Jia-Ju Bai, davem, kafai, weiwan, dsa, johannes.berg, fw
  Cc: linux-decnet-user, netdev, linux-kernel



On 04/09/2018 07:10 AM, Jia-Ju Bai wrote:
> dn_route_init() is never called in atomic context.
> 
> The call chain ending up at dn_route_init() is:
> [1] dn_route_init() <- decnet_init()
> decnet_init() is only set as a parameter of module_init().
> 
> Despite never getting called from atomic context,
> dn_route_init() calls __get_free_pages() with GFP_ATOMIC,
> which waits busily for allocation.
> GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
> to avoid busy waiting and improve the possibility of sucessful allocation.
> 
> This is found by a static analysis tool named DCNS written by myself.
> And I also manually check it.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  net/decnet/dn_route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
> index 0bd3afd..59ed12a 100644
> --- a/net/decnet/dn_route.c
> +++ b/net/decnet/dn_route.c
> @@ -1898,7 +1898,7 @@ void __init dn_route_init(void)
>  		while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
>  			dn_rt_hash_mask--;
>  		dn_rt_hash_table = (struct dn_rt_hash_bucket *)
> -			__get_free_pages(GFP_ATOMIC, order);
> +			__get_free_pages(GFP_KERNEL, order);
>  	} while (dn_rt_hash_table == NULL && --order > 0);
>  
>  	if (!dn_rt_hash_table)
> 

This might OOM under pressure.

This would need __GFP_NOWARN | __GFP_NORETRY  I guess, and would target net-next

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

* Re: [PATCH] net: decnet: Replace GFP_ATOMIC with GFP_KERNEL in dn_route_init
  2018-04-09 14:44 ` Eric Dumazet
@ 2018-04-09 14:48   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-09 14:48 UTC (permalink / raw)
  To: Eric Dumazet, davem, kafai, weiwan, dsa, johannes.berg, fw
  Cc: linux-decnet-user, netdev, linux-kernel



On 2018/4/9 22:44, Eric Dumazet wrote:
>
> On 04/09/2018 07:10 AM, Jia-Ju Bai wrote:
>> dn_route_init() is never called in atomic context.
>>
>> The call chain ending up at dn_route_init() is:
>> [1] dn_route_init() <- decnet_init()
>> decnet_init() is only set as a parameter of module_init().
>>
>> Despite never getting called from atomic context,
>> dn_route_init() calls __get_free_pages() with GFP_ATOMIC,
>> which waits busily for allocation.
>> GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
>> to avoid busy waiting and improve the possibility of sucessful allocation.
>>
>> This is found by a static analysis tool named DCNS written by myself.
>> And I also manually check it.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>   net/decnet/dn_route.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
>> index 0bd3afd..59ed12a 100644
>> --- a/net/decnet/dn_route.c
>> +++ b/net/decnet/dn_route.c
>> @@ -1898,7 +1898,7 @@ void __init dn_route_init(void)
>>   		while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
>>   			dn_rt_hash_mask--;
>>   		dn_rt_hash_table = (struct dn_rt_hash_bucket *)
>> -			__get_free_pages(GFP_ATOMIC, order);
>> +			__get_free_pages(GFP_KERNEL, order);
>>   	} while (dn_rt_hash_table == NULL && --order > 0);
>>   
>>   	if (!dn_rt_hash_table)
>>
> This might OOM under pressure.

Sorry, I do not understand this.
Could you please explain the reason?

> This would need __GFP_NOWARN | __GFP_NORETRY  I guess, and would target net-next
>

Do you mean
__get_free_pages(__GFP_NOWARN | __GFP_NORETRY) or
__get_free_pages(__GFP_NOWARN | __GFP_NORETRY | GFP_KERNEL)?


Best wishes,
Jia-Ju Bai

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

end of thread, other threads:[~2018-04-09 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 14:10 [PATCH] net: decnet: Replace GFP_ATOMIC with GFP_KERNEL in dn_route_init Jia-Ju Bai
2018-04-09 14:44 ` Eric Dumazet
2018-04-09 14:48   ` Jia-Ju Bai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.