* [PATCH] net: dccp: Replace GFP_ATOMIC with GFP_KERNEL in dccp_init
@ 2018-04-09 14:10 Jia-Ju Bai
2018-04-09 14:42 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-09 14:10 UTC (permalink / raw)
To: gerrit, davem; +Cc: dccp, netdev, linux-kernel, Jia-Ju Bai
dccp_init() is never called in atomic context.
This function is only set as a parameter of module_init().
Despite never getting called from atomic context,
dccp_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/dccp/proto.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index b68168f..f63ba93 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1159,7 +1159,7 @@ static int __init dccp_init(void)
hash_size--;
dccp_hashinfo.ehash_mask = hash_size - 1;
dccp_hashinfo.ehash = (struct inet_ehash_bucket *)
- __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, ehash_order);
+ __get_free_pages(GFP_KERNEL|__GFP_NOWARN, ehash_order);
} while (!dccp_hashinfo.ehash && --ehash_order > 0);
if (!dccp_hashinfo.ehash) {
@@ -1182,7 +1182,7 @@ static int __init dccp_init(void)
bhash_order > 0)
continue;
dccp_hashinfo.bhash = (struct inet_bind_hashbucket *)
- __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, bhash_order);
+ __get_free_pages(GFP_KERNEL|__GFP_NOWARN, bhash_order);
} while (!dccp_hashinfo.bhash && --bhash_order >= 0);
if (!dccp_hashinfo.bhash) {
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dccp: Replace GFP_ATOMIC with GFP_KERNEL in dccp_init
2018-04-09 14:10 [PATCH] net: dccp: Replace GFP_ATOMIC with GFP_KERNEL in dccp_init Jia-Ju Bai
@ 2018-04-09 14:42 ` Eric Dumazet
2018-04-09 14:46 ` Jia-Ju Bai
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2018-04-09 14:42 UTC (permalink / raw)
To: Jia-Ju Bai, gerrit, davem; +Cc: dccp, netdev, linux-kernel
On 04/09/2018 07:10 AM, Jia-Ju Bai wrote:
> dccp_init() is never called in atomic context.
> This function is only set as a parameter of module_init().
>
> Despite never getting called from atomic context,
> dccp_init() calls __get_free_pages() with GFP_ATOMIC,
> which waits busily for allocation.
What do you mean by "waits busily" ?
GFP_ATOMIC does not sleep, does not wait.
> 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>
> ---
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dccp: Replace GFP_ATOMIC with GFP_KERNEL in dccp_init
2018-04-09 14:42 ` Eric Dumazet
@ 2018-04-09 14:46 ` Jia-Ju Bai
0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-09 14:46 UTC (permalink / raw)
To: Eric Dumazet, gerrit, davem; +Cc: dccp, netdev, linux-kernel
On 2018/4/9 22:42, Eric Dumazet wrote:
>
> On 04/09/2018 07:10 AM, Jia-Ju Bai wrote:
>> dccp_init() is never called in atomic context.
>> This function is only set as a parameter of module_init().
>>
>> Despite never getting called from atomic context,
>> dccp_init() calls __get_free_pages() with GFP_ATOMIC,
>> which waits busily for allocation.
> What do you mean by "waits busily" ?
>
> GFP_ATOMIC does not sleep, does not wait.
Sorry, I should modify it to "does not sleep".
Do you think it is okay?
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-09 14:46 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: dccp: Replace GFP_ATOMIC with GFP_KERNEL in dccp_init Jia-Ju Bai
2018-04-09 14:42 ` Eric Dumazet
2018-04-09 14:46 ` 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).