lkml.org 
[lkml]   [2006]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC][PATCH 2/9] deadlock prevention core
    * Peter Zijlstra <a.p.zijlstra@chello.nl> 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 majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-08-08 23:19    [W:3.306 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site