Re: [RFC][PATCH 2/9] deadlock prevention core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Peter Zijlstra <[email protected]> 2006-08-08 21:33
> +struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
> +		unsigned length, gfp_t gfp_mask)
> +{
> +	struct sk_buff *skb;
> +
> +	if (dev && (dev->flags & IFF_MEMALLOC)) {
> +		WARN_ON(gfp_mask & (__GFP_NOMEMALLOC | __GFP_MEMALLOC));
> +		gfp_mask &= ~(__GFP_NOMEMALLOC | __GFP_MEMALLOC);
> +
> +		if ((skb = ___netdev_alloc_skb(dev, length,
> +					       gfp_mask | __GFP_NOMEMALLOC)))
> +			goto done;
> +		if (dev_reserve_used(dev) >= dev->rx_reserve)
> +			goto out;
> +		if (!(skb = ___netdev_alloc_skb(dev, length,
> +						gfp_mask | __GFP_MEMALLOC)))
> +			goto out;
> +		atomic_inc(&dev->rx_reserve_used);
> +	} else
> +		if (!(skb = ___netdev_alloc_skb(dev, length, gfp_mask)))
> +			goto out;
> +
> +done:
> +	skb->dev = dev;
> +out:
> +	return skb;
> +}
> +

>  void __kfree_skb(struct sk_buff *skb)
>  {
> +	struct net_device *dev = skb->dev;
> +
>  	dst_release(skb->dst);
>  #ifdef CONFIG_XFRM
>  	secpath_put(skb->sp);
> @@ -389,6 +480,8 @@ void __kfree_skb(struct sk_buff *skb)
>  #endif
>  
>  	kfree_skbmem(skb);
> +	if (dev && (dev->flags & IFF_MEMALLOC))
> +		dev_unreserve_skb(dev);
>  }

skb->dev is not guaranteed to still point to the "allocating" device
once the skb is freed again so reserve/unreserve isn't symmetric.
You'd need skb->alloc_dev or something.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux