Re: [PATCH 10/17] netvm: Allow skb allocation to use PFMEMALLOCreserves

From: Sebastian Andrzej Siewior
Date: Thu Jun 21 2012 - 12:30:43 EST


> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 1d6ecc8..9a58dcc 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -167,14 +206,19 @@ static void skb_under_panic(struct sk_buff *skb, int sz, void *here)
> * %GFP_ATOMIC.
> */
> struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
> - int fclone, int node)
> + int flags, int node)
> {
> struct kmem_cache *cache;
> struct skb_shared_info *shinfo;
> struct sk_buff *skb;
> u8 *data;
> + bool pfmemalloc;
>
> - cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
> + cache = (flags & SKB_ALLOC_FCLONE)
> + ? skbuff_fclone_cache : skbuff_head_cache;
> +
> + if (sk_memalloc_socks() && (flags & SKB_ALLOC_RX))
> + gfp_mask |= __GFP_MEMALLOC;
>
> /* Get the HEAD */
> skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);

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?

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/