Re: [PATCH v9] tilegx network driver: initial support

From: Eric Dumazet
Date: Wed Jun 06 2012 - 13:41:06 EST


On Mon, 2012-06-04 at 16:12 -0400, Chris Metcalf wrote:

> +/* Allocate and push a buffer. */
> +static bool tile_net_provide_buffer(bool small)
> +{
> + int stack = small ? small_buffer_stack : large_buffer_stack;
> + const unsigned long buffer_alignment = 128;
> + struct sk_buff *skb;
> + int len;
> +
> + len = sizeof(struct sk_buff **) + buffer_alignment;
> + len += (small ? 128 : 1664);

1664 is a magic number, it should be a nice define

#define ..... ( ETH_DATA_LEN + .... )

> + skb = dev_alloc_skb(len);
> + if (skb == NULL)
> + return false;
> +
> + /* Make room for a back-pointer to 'skb' and guarantee alignment. */
> + skb_reserve(skb, sizeof(struct sk_buff **));
> + skb_reserve(skb, -(long)skb->data & (buffer_alignment - 1));
> +
> + /* Save a back-pointer to 'skb'. */
> + *(struct sk_buff **)(skb->data - sizeof(struct sk_buff **)) = skb;
> +
> + /* Make sure "skb" and the back-pointer have been flushed. */
> + wmb();

Interesting, have you considered using build_skb() instead of this
convoluted thing ?

This could save some cache misses...



--
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/