lkml.org 
[lkml]   [2019]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net: fix sk_page_frag() recursion from memory reclaim
Hello,

On Sat, Oct 19, 2019 at 11:15:28AM -0700, Eric Dumazet wrote:
> It seems compiler generates better code with :
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index ab905c4b1f0efd42ebdcae333b3f0a2c7c1b2248..56de6ac99f0952bd0bc003353c094ce3a5a852f4 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2238,7 +2238,8 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
> */
> static inline struct page_frag *sk_page_frag(struct sock *sk)
> {
> - if (gfpflags_allow_blocking(sk->sk_allocation))
> + if (likely((sk->sk_allocation & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
> + __GFP_DIRECT_RECLAIM))
> return &current->task_frag;
>
> return &sk->sk_frag;
>
>
> WDYT ?

Whatever works is fine by me. gfpflags_allow_blocking() is clearer
than testing __GFP_DIRECT_RECLAIM directly tho. Maybe a better way is
introducing a new gfpflags_ helper?

Thanks.

--
tejun

\
 
 \ /
  Last update: 2019-10-19 23:20    [W:0.132 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site