[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20080925142833.GA15185@2ka.mipt.ru>
Date: Thu, 25 Sep 2008 18:28:33 +0400
From: Evgeniy Polyakov <johnpol@....mipt.ru>
To: Ram.Natarajan@...lex.Com
Cc: netdev@...r.kernel.org
Subject: Re: Using skb_get() to recycle skbs
Hi.
On Thu, Sep 25, 2008 at 06:03:03AM -0700, Ram.Natarajan@...lex.Com (Ram.Natarajan@...lex.Com) wrote:
> In our netdev driver, we preallocate a pool of skb which are
> used by our h/w to DMA frames.
>
> Normally, when we indicate a packet to stack (netif_rx),
> the stack ends up freeing it. If we do a skb_get() prior
> to that, then the stack just reduces the use_count,
> and our driver is able to re-use it. We do have to use
> caution to see that stack has dropped it's reference
> (atomic_read(skb->users) <= 1) prior to returning
> the buffer to our h/w.
>
> Is this a valid approach? It so it could save some
> CPU cycles which are used in alloc_skb(). If this
> can be done, how come more drivers in tree are not
> doing it, is there any flip side to it? One could be
> that stack may not free it in time (we could starve
> the hardware of free buffers), but in that case
> we can drop our reference, and let the stack
> free it up, and force an allocation instead of
> reuse.
Now stack allocates new skb and copy data from old one to the new, since
it belives that skb is shared between different users and thus can not
be modified in the rx path. You can check how skb_share_check() is
called in ip_rcv() and similar receiving functions.
--
Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists