Message ID | 20120622105451.GC8271@suse.de |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Jun 22, 2012 at 11:54:51AM +0100, Mel Gorman wrote: > > This is mostly used by nic to refil their RX skb pool. You add the > > __GFP_MEMALLOC to the allocation to rise the change of a successfull refill > > for the swap case. > > A few drivers use build_skb() to create the skb. __netdev_alloc_skb() > > shouldn't be affected since the allocation happens with GFP_ATOMIC. Looking at > > TG3 it uses build_skb() and get_pages() / kmalloc(). Shouldn't this be some > > considered? > > > > While TG3 is not exactly as you describe after rebasing build_skb should > make a similar check to __alloc_skb. As it is always used for RX allocation > from the skbuff_head_cache cache the following should be suitable. Thanks. As Eric pointed out you end up in netdev_alloc_frag() which is using alloc_page(). This is also used by __netdev_alloc_skb(). Sebastian -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9832001..063830c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -310,8 +310,12 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size) struct skb_shared_info *shinfo; struct sk_buff *skb; unsigned int size = frag_size ? : ksize(data); + gfp_t gfp_mask = GFP_ATOMIC; - skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); + if (sk_memalloc_socks()) + gfp_mask |= __GFP_MEMALLOC; + + skb = kmem_cache_alloc(skbuff_head_cache, gfp_mask); if (!skb) return NULL;