Messages in this thread | | | Date | Sat, 19 Oct 2019 14:18:56 -0700 | From | Tejun Heo <> | Subject | Re: [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 ¤t->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
| |