[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070927165340.fd5dc2d0.akpm@linux-foundation.org>
Date: Thu, 27 Sep 2007 16:53:40 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Jeff Dike <jdike@...toit.com>
Cc: linux-kernel@...r.kernel.org,
user-mode-linux-devel@...ts.sourceforge.net
Subject: Re: [PATCH] UML - Correctly handle skb allocation failures
On Thu, 27 Sep 2007 13:01:26 -0400
Jeff Dike <jdike@...toit.com> wrote:
> +static int update_drop_skb(int max)
> +{
> + struct sk_buff *new;
> + int err = 0;
> +
> + spin_lock(&drop_lock);
> +
> + if (max <= drop_max)
> + goto out;
> +
> + err = -ENOMEM;
> + new = dev_alloc_skb(max);
> + if (new == NULL)
> + goto out;
> +
> + skb_put(new, max);
> +
> + kfree_skb(drop_skb);
> + drop_skb = new;
> + drop_max = max;
> + err = 0;
> +out:
> + spin_unlock(&drop_lock);
> +
> + return err;
> +}
> +
> static int uml_net_rx(struct net_device *dev)
> {
> struct uml_net_private *lp = dev->priv;
> @@ -43,6 +82,9 @@ static int uml_net_rx(struct net_device
> /* If we can't allocate memory, try again next round. */
> skb = dev_alloc_skb(lp->max_packet);
> if (skb == NULL) {
> + drop_skb->dev = dev;
> + /* Read a packet into drop_skb and don't do anything with it. */
> + (*lp->read)(lp->fd, drop_skb, lp);
> lp->stats.rx_dropped++;
> return 0;
Still wanna know why it is safe for uml_net_rx to be playing with
drop_skb when update_drop_skb() could be concurrently reallocating
and freeing it.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists