Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tom Herbert <therbert@google.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, bhutchings@solarflare.com
Subject: Re: [PATCH 3/3 v2] net: allocate tx queues in register_netdevice
Date: Tue, 19 Oct 2010 10:13:26 +0200	[thread overview]
Message-ID: <1287476006.2676.12.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.1.00.1010182100180.6676@pokey.mtv.corp.google.com>

Le lundi 18 octobre 2010 à 21:04 -0700, Tom Herbert a écrit :
> This patch introduces netif_alloc_netdev_queues which is called from
> register_device instead of alloc_netdev_mq.  This makes TX queue
> allocation symmetric with RX allocation.  Also, queue locks allocation
> is done in netdev_init_one_queue.  Change set_real_num_tx_queues to
> fail if requested number < 1 or greater than number of allocated
> queues.
> 
> Signed-off-by: Tom Herbert <therbert@google.com>
> ---
>  include/linux/netdevice.h |    4 +-
>  net/core/dev.c            |  106 ++++++++++++++++++++++----------------------
>  2 files changed, 55 insertions(+), 55 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 14fbb04..880d565 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1696,8 +1696,8 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
>  	return dev->num_tx_queues > 1;
>  }
>  
> -extern void netif_set_real_num_tx_queues(struct net_device *dev,
> -					 unsigned int txq);
> +extern int netif_set_real_num_tx_queues(struct net_device *dev,
> +					unsigned int txq);
>  
>  #ifdef CONFIG_RPS
>  extern int netif_set_real_num_rx_queues(struct net_device *dev,
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d33adec..7ae5c7e 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1553,18 +1553,20 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
>   * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
>   * greater then real_num_tx_queues stale skbs on the qdisc must be flushed.
>   */
> -void netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
> +int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
>  {
> -	unsigned int real_num = dev->real_num_tx_queues;
> +	if (txq < 1 || txq > dev->num_tx_queues)
> +		return -EINVAL;
>  
> -	if (unlikely(txq > dev->num_tx_queues))
> -		;
> -	else if (txq > real_num)
> -		dev->real_num_tx_queues = txq;
> -	else if (txq < real_num) {
> -		dev->real_num_tx_queues = txq;
> -		qdisc_reset_all_tx_gt(dev, txq);
> +	if (dev->reg_state == NETREG_REGISTERED) {
> +		ASSERT_RTNL();
> +
> +		if (txq < dev->real_num_tx_queues)
> +			qdisc_reset_all_tx_gt(dev, txq);
>  	}
> +
> +	dev->real_num_tx_queues = txq;
> +	return 0;
>  }
>  EXPORT_SYMBOL(netif_set_real_num_tx_queues);
>  
> @@ -4928,20 +4930,6 @@ static void rollback_registered(struct net_device *dev)
>  	rollback_registered_many(&single);
>  }
>  
> -static void __netdev_init_queue_locks_one(struct net_device *dev,
> -					  struct netdev_queue *dev_queue,
> -					  void *_unused)
> -{
> -	spin_lock_init(&dev_queue->_xmit_lock);
> -	netdev_set_xmit_lockdep_class(&dev_queue->_xmit_lock, dev->type);
> -	dev_queue->xmit_lock_owner = -1;
> -}
> -
> -static void netdev_init_queue_locks(struct net_device *dev)
> -{
> -	netdev_for_each_tx_queue(dev, __netdev_init_queue_locks_one, NULL);
> -}
> -
>  unsigned long netdev_fix_features(unsigned long features, const char *name)
>  {
>  	/* Fix illegal SG+CSUM combinations. */
> @@ -5034,6 +5022,41 @@ static int netif_alloc_rx_queues(struct net_device *dev)
>  	return 0;
>  }
>  
> +static int netif_alloc_netdev_queues(struct net_device *dev)
> +{
> +	unsigned int count = dev->num_tx_queues;
> +	struct netdev_queue *tx;
> +
> +	BUG_ON(count < 1);
> +
> +	tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL);
> +	if (!tx) {
> +		pr_err("netdev: Unable to allocate %u tx queues.\n",
> +		       count);
> +			return -ENOMEM;

One extra tab before the return

Other than that, patch seems fine to me, thanks !

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>




      reply	other threads:[~2010-10-19  8:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19  4:04 [PATCH 3/3 v2] net: allocate tx queues in register_netdevice Tom Herbert
2010-10-19  8:13 ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287476006.2676.12.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=therbert@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox