public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vmxnet3: round down # of queues to power of two
@ 2011-07-07  0:58 Shreyas Bhatewara
  2011-07-07  1:08 ` [Pv-drivers] " Dmitry Torokhov
  2011-07-07  1:16 ` [PATCHv2] " Shreyas Bhatewara
  0 siblings, 2 replies; 5+ messages in thread
From: Shreyas Bhatewara @ 2011-07-07  0:58 UTC (permalink / raw)
  To: pv-drivers@vmware.com, netdev@vger.kernel.org; +Cc: yongwang


vmxnet3 device supports only power-of-two number of queues. The driver
therefore needs to check this and rounds down the number of queues to the
nearest power of two.

Signed-off-by: Yong Wang <yongwang@vmware.com>
Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
--

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index fabcded..4ee7750 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2898,12 +2898,18 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 #endif
 		num_rx_queues = 1;
 
+	if (!is_power_of_2(num_rx_queues))
+		num_rx_queues = rounddown_pow_of_two(num_rx_queues);
+
 	if (enable_mq)
 		num_tx_queues = min(VMXNET3_DEVICE_MAX_TX_QUEUES,
 				    (int)num_online_cpus());
 	else
 		num_tx_queues = 1;
 
+	if (!is_power_of_2(num_tx_queues))
+		num_tx_queues = rounddown_pow_of_two(num_tx_queues);
+
 	netdev = alloc_etherdev_mq(sizeof(struct vmxnet3_adapter),
 				   max(num_tx_queues, num_rx_queues));
 	printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n",
@@ -3089,6 +3095,9 @@ vmxnet3_remove_device(struct pci_dev *pdev)
 #endif
 		num_rx_queues = 1;
 
+	if (!is_power_of_2(num_rx_queues))
+		num_rx_queues = rounddown_pow_of_two(num_rx_queues);
+
 	cancel_work_sync(&adapter->work);
 
 	unregister_netdev(netdev);
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index a9cb3fa..b18eac1 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -56,6 +56,7 @@
 #include <linux/if_vlan.h>
 #include <linux/if_arp.h>
 #include <linux/inetdevice.h>
+#include <linux/log2.h>
 
 #include "vmxnet3_defs.h"
 
@@ -69,10 +70,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.1.14.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.1.18.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01010E00
+#define VMXNET3_DRIVER_VERSION_NUM      0x01011200
 
 #if defined(CONFIG_PCI_MSI)
 	/* RSS only makes sense if MSI-X is supported. */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Pv-drivers] [PATCH] vmxnet3: round down # of queues to power of two
  2011-07-07  0:58 [PATCH] vmxnet3: round down # of queues to power of two Shreyas Bhatewara
@ 2011-07-07  1:08 ` Dmitry Torokhov
  2011-07-07  1:53   ` Yong Wang
  2011-07-07  1:16 ` [PATCHv2] " Shreyas Bhatewara
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2011-07-07  1:08 UTC (permalink / raw)
  To: pv-drivers; +Cc: Shreyas Bhatewara, netdev@vger.kernel.org, yongwang

On Wednesday, July 06, 2011 05:58:51 PM Shreyas Bhatewara wrote:

> 
> +	if (!is_power_of_2(num_rx_queues))
> +		num_rx_queues = rounddown_pow_of_two(num_rx_queues);
> +

No need to do the check, just do:

	num_rx_queues = rounddown_pow_of_two(num_rx_queues);

Thanks,
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv2] vmxnet3: round down # of queues to power of two
  2011-07-07  0:58 [PATCH] vmxnet3: round down # of queues to power of two Shreyas Bhatewara
  2011-07-07  1:08 ` [Pv-drivers] " Dmitry Torokhov
@ 2011-07-07  1:16 ` Shreyas Bhatewara
  2011-07-07  7:26   ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Shreyas Bhatewara @ 2011-07-07  1:16 UTC (permalink / raw)
  To: pv-drivers@vmware.com, netdev@vger.kernel.org, dtor; +Cc: yongwang


vmxnet3 device supports only power-of-two number of queues. The driver
therefore needs to check this and rounds down the number of queues to the
nearest power of two.

Signed-off-by: Yong Wang <yongwang@vmware.com>
Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
Reviewed-by: Dmitry Torokhov <dtor@vmware.com>
--

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index fabcded..009277e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2897,6 +2897,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 	else
 #endif
 		num_rx_queues = 1;
+	num_rx_queues = rounddown_pow_of_two(num_rx_queues);
 
 	if (enable_mq)
 		num_tx_queues = min(VMXNET3_DEVICE_MAX_TX_QUEUES,
@@ -2904,6 +2905,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 	else
 		num_tx_queues = 1;
 
+	num_tx_queues = rounddown_pow_of_two(num_tx_queues);
 	netdev = alloc_etherdev_mq(sizeof(struct vmxnet3_adapter),
 				   max(num_tx_queues, num_rx_queues));
 	printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n",
@@ -3088,6 +3090,7 @@ vmxnet3_remove_device(struct pci_dev *pdev)
 	else
 #endif
 		num_rx_queues = 1;
+	num_rx_queues = rounddown_pow_of_two(num_rx_queues);
 
 	cancel_work_sync(&adapter->work);
 
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index a9cb3fa..b18eac1 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -56,6 +56,7 @@
 #include <linux/if_vlan.h>
 #include <linux/if_arp.h>
 #include <linux/inetdevice.h>
+#include <linux/log2.h>
 
 #include "vmxnet3_defs.h"
 
@@ -69,10 +70,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.1.14.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.1.18.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01010E00
+#define VMXNET3_DRIVER_VERSION_NUM      0x01011200
 
 #if defined(CONFIG_PCI_MSI)
 	/* RSS only makes sense if MSI-X is supported. */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [Pv-drivers] [PATCH] vmxnet3: round down # of queues to power of two
  2011-07-07  1:08 ` [Pv-drivers] " Dmitry Torokhov
@ 2011-07-07  1:53   ` Yong Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Yong Wang @ 2011-07-07  1:53 UTC (permalink / raw)
  To: Dmitry Torokhov, pv-drivers@vmware.com
  Cc: Shreyas Bhatewara, netdev@vger.kernel.org

I just want to point out that rounddown_pow_of_two() returns 0 when (1) the input is 1; and (2) the __buildin_constant_p(n) path is taken.  In the vmxnet3 case, even if num_rx_queues is 1, we are safe as its value is not known to be constant at compile time and 1 will be returned by taking the other path (1UL << (fls_long(n) - 1)). The original check of power_of_two is there just to be on the safe side.

Related to this, I wonder if we should always return 1 when the input is 1 (1 is also a power of two as 2^0). I don't have the history of this API though and curious if there are any users of this API that depend on this behavior?

Thanks,
Yong

> -----Original Message-----
> From: Dmitry Torokhov [mailto:dtor@vmware.com]
> Sent: Wednesday, July 06, 2011 6:09 PM
> To: pv-drivers@vmware.com
> Cc: Shreyas Bhatewara; netdev@vger.kernel.org; Yong Wang
> Subject: Re: [Pv-drivers] [PATCH] vmxnet3: round down # of queues to power of
> two
> 
> On Wednesday, July 06, 2011 05:58:51 PM Shreyas Bhatewara wrote:
> 
> >
> > +	if (!is_power_of_2(num_rx_queues))
> > +		num_rx_queues = rounddown_pow_of_two(num_rx_queues);
> > +
> 
> No need to do the check, just do:
> 
> 	num_rx_queues = rounddown_pow_of_two(num_rx_queues);
> 
> Thanks,
> Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv2] vmxnet3: round down # of queues to power of two
  2011-07-07  1:16 ` [PATCHv2] " Shreyas Bhatewara
@ 2011-07-07  7:26   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2011-07-07  7:26 UTC (permalink / raw)
  To: sbhatewara; +Cc: pv-drivers, netdev, dtor, yongwang

From: Shreyas Bhatewara <sbhatewara@vmware.com>
Date: Wed, 6 Jul 2011 18:16:53 -0700 (PDT)

> 
> vmxnet3 device supports only power-of-two number of queues. The driver
> therefore needs to check this and rounds down the number of queues to the
> nearest power of two.
> 
> Signed-off-by: Yong Wang <yongwang@vmware.com>
> Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
> Reviewed-by: Dmitry Torokhov <dtor@vmware.com>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-07  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-07  0:58 [PATCH] vmxnet3: round down # of queues to power of two Shreyas Bhatewara
2011-07-07  1:08 ` [Pv-drivers] " Dmitry Torokhov
2011-07-07  1:53   ` Yong Wang
2011-07-07  1:16 ` [PATCHv2] " Shreyas Bhatewara
2011-07-07  7:26   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox