Subject: Re: [PATCH 1/13]: netdev: Allocate multiple queues for TX.

From: Eric Dumazet <[email-masked]>
Date: Fri, 11 Jul 2008 23:19:39 +0200

David Miller a écrit :
> alloc_netdev_mq() now allocates an array of netdev_queue
> structures for TX, based upon the queue_count argument.
> 
> Furthermore, all accesses to the TX queues are now vectored
> through the netdev_get_tx_queue() and netdev_for_each_tx_queue()
> interfaces.  This makes it easy to grep the tree for all
> things that want to get to a TX queue of a net device.
> 
> Problem spots which are not really multiqueue aware yet, and
> only work with one queue, can easily be spotted by grepping
> for all netdev_get_tx_queue() calls that pass in a zero index.
> 
> Signed-off-by: David S. Miller <[email-masked]>
> ---

>  	}
>  
> +	tx = kzalloc(sizeof(struct netdev_queue) * queue_count, GFP_KERNEL);
> +	if (!tx) {
> +		printk(KERN_ERR "alloc_netdev: Unable to allocate "
> +		       "tx qdiscs.\n");
> +		kfree(p);
> +		return NULL;
> +	}
> +

On i386 for example, sizeof(struct netdev_queue) = 0x2c

Shouldnt we make sure each queue sits on its own cache line on CONFIG_SMP ?

Also, dev->_tx and dev->num_tx_queues might share a cache line with dev->rx_queue, was it intended ?

> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -640,7 +640,9 @@ struct net_device
>  	unsigned char		broadcast[MAX_ADDR_LEN];	/* hw bcast add	*/
>  
>  	struct netdev_queue	rx_queue;
> -	struct netdev_queue	tx_queue ____cacheline_aligned_in_smp;
> +
> +	struct netdev_queue	*_tx;
> +	unsigned int		num_tx_queues;
>  	unsigned long		tx_queue_len;	/* Max frames per queue allowed */