Skip to contentSkip to conversation

default maximal number of RSS queues in mq drivers

PATCH Applied Yuval Mintz 3 participants 15 messages Jul 1, 2012 – Jul 5, 2012

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover default maximal number of RSS queues in mq drivers

Different vendors support different number of RSS queues by default. Today, there exists an ethtool API through which users can change the number of channels their driver supports; This enables us to pursue the goal of using a default number of RSS queues in various multi-queue drivers.

This patch intendeds to achieve the above default, by upper-limiting the number of interrupts multi-queue drivers request (by default, not via the new API) with correlation to the number of cpus on the machine.

After examining multi-queue drivers that call alloc_etherdev_mq[s], it became evident that most drivers allocate their devices using hard-coded values. Changing those defaults directly will most likely cause a regression.

However, (most) multi-queue driver look at the number of online cpus when requesting for interrupts. We assume that the number of interrupts the driver manages to request is propagated across the driver, and the number of RSS queues it configures is based upon it.

This patch modifies said logic - if the number of cpus is large enough, use a smaller default value instead. This serves 2 main purposes:
1. A step forward unity in the number of RSS queues of various drivers.
2. It prevents wasteful requests for memory on machines with many cpus.

Notice no testing was made on this patch (other than on the bnx2x driver) except for compilation test. This patch is based on RFC:
http://marc.info/?l=linux-netdev&m=134062509310404&w=2

Drivers identified as multi-queue, handled in this patch:

* mellanox mlx4
* neterion vxge

* qlogic   qlge
* chelsio  cxgb3, cxgb4
* myricom  myri10ge
* emulex   benet

* broadcom tg3, bnx2, bnx2x

The guys at Intel requested to change their drivers' behaviour on their own, in order to support ethtool's [g|s]et_channels. Thus, igb, igbx2, and igbxevf were not handled in this patch.

Driver identified as multi-queue, no reference to number of online cpus found, and thus unhandled in this patch:

* neterion s2io
* marvell mv643xx
* freescale gianfar

* ibm       ehea
* ti        cpmac
* sun       niu
* sfc       efx
* chelsio   cxgb4vf

Cheers,
Yuval Mintz

Cc Divy Le Ray <[email protected]>
Cc Or Gerlitz <[email protected]>
Cc Jon Mason <[email protected]>
Cc Anirban Chakraborty <[email protected]>
Cc Jitendra Kalsaria <[email protected]>
Cc Ron Mercer <[email protected]>
Cc Jeff Kirsher <[email protected]>
Cc Jon Mason <[email protected]>
Cc Andrew Gallatin <[email protected]>
Cc Sathya Perla <[email protected]>
Cc Subbu Seetharaman <[email protected]>
Cc Ajit Khaparde <[email protected]>
Cc Matt Carlson <[email protected]>
Cc Michael Chan <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Ben Hutchings <[email protected]>
#1 lore raw

PATCH 1/11 net-next: Add netif_get_num_default_rss_queues

Most multi-queue networking driver consider the number of online cpus when configuring RSS queues.
This patch adds a wrapper to the number of cpus, setting an upper limit on the number of cpus a driver should consider (by default) when allocating resources for his queues.

---
 include/linux/netdevice.h |    3 +++
 net/core/dev.c            |   11 +++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
include/linux/netdevice.h +3 -0
index 2c2ecea..ab0251d 100644
@@ -2119,6 +2119,9 @@ static inline int netif_copy_real_num_queues(struct net_device *to_dev,
 #endif
 }
 
+#define DEFAULT_MAX_NUM_RSS_QUEUES	(8)
+extern int netif_get_num_default_rss_queues(void);
+
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts
  * disabled.
net/core/dev.c +11 -0
index ed674e2..69f7a1a 100644
@@ -1793,6 +1793,17 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
 EXPORT_SYMBOL(netif_set_real_num_rx_queues);
 #endif
 
+/* netif_get_num_default_rss_queues - default number of RSS queues
+ *
+ * This routine should set an upper limit on the number of RSS queues
+ * used by default by multiqueue devices.
+ */
+int netif_get_num_default_rss_queues()
+{
+	return min_t(int, DEFAULT_MAX_NUM_RSS_QUEUES, num_online_cpus());
+}
+EXPORT_SYMBOL(netif_get_num_default_rss_queues);
+
 static inline void __netif_reschedule(struct Qdisc *q)
 {
 	struct softnet_data *sd;
Signature · 1 line
1.7.9.rc2
#2 lore raw

PATCH 2/11 mlx4: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Or Gerlitz <[email protected]>
---
 drivers/net/ethernet/mellanox/mlx4/main.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/main.c +3 -2
index a0313de..14d9c76 100644
@@ -41,6 +41,7 @@
 #include <linux/slab.h>
 #include <linux/io-mapping.h>
 #include <linux/delay.h>
+#include <linux/netdevice.h>
 
 #include <linux/mlx4/device.h>
 #include <linux/mlx4/doorbell.h>
@@ -1539,8 +1540,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 	struct mlx4_priv *priv = mlx4_priv(dev);
 	struct msix_entry *entries;
 	int nreq = min_t(int, dev->caps.num_ports *
-			 min_t(int, num_online_cpus() + 1, MAX_MSIX_P_PORT)
-				+ MSIX_LEGACY_SZ, MAX_MSIX);
+			 min_t(int, netif_get_num_default_rss_queues() + 1,
+			       MAX_MSIX_P_PORT) + MSIX_LEGACY_SZ, MAX_MSIX);
 	int err;
 	int i;
 
Signature · 1 line
1.7.9.rc2
#3 lore raw

PATCH 3/11 vxge: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Jon Mason <[email protected]>
---
 drivers/net/ethernet/neterion/vxge/vxge-main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/ethernet/neterion/vxge/vxge-main.c +2 -1
index 2578eb1..2fd1edb 100644
@@ -3687,7 +3687,8 @@ static int __devinit vxge_config_vpaths(
 			return 0;
 
 		if (!driver_config->g_no_cpus)
-			driver_config->g_no_cpus = num_online_cpus();
+			driver_config->g_no_cpus =
+				netif_get_num_default_rss_queues();
 
 		driver_config->vpath_per_dev = driver_config->g_no_cpus >> 1;
 		if (!driver_config->vpath_per_dev)
Signature · 1 line
1.7.9.rc2
#5 lore raw

PATCH 5/11 cxgb3: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Divy Le Ray <[email protected]>
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +1 -1
index abb6ce7..9b08749 100644
@@ -3050,7 +3050,7 @@ static struct pci_error_handlers t3_err_handler = {
 static void set_nqsets(struct adapter *adap)
 {
 	int i, j = 0;
-	int num_cpus = num_online_cpus();
+	int num_cpus = netif_get_num_default_rss_queues();
 	int hwports = adap->params.nports;
 	int nqsets = adap->msix_nvectors - 1;
 
Signature · 1 line
1.7.9.rc2
#6 lore raw

PATCH 6/11 cxgb4: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Divy Le Ray <[email protected]>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +2 -2
index e1f96fb..5ed49af 100644
@@ -3493,8 +3493,8 @@ static void __devinit cfg_queues(struct adapter *adap)
 	 */
 	if (n10g)
 		q10g = (MAX_ETH_QSETS - (adap->params.nports - n10g)) / n10g;
-	if (q10g > num_online_cpus())
-		q10g = num_online_cpus();
+	if (q10g > netif_get_num_default_rss_queues())
+		q10g = netif_get_num_default_rss_queues();
 
 	for_each_port(adap, i) {
 		struct port_info *pi = adap2pinfo(adap, i);
Signature · 1 line
1.7.9.rc2
#4 lore raw

PATCH 4/11 qlge: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Anirban Chakraborty <[email protected]>
Cc Jitendra Kalsaria <[email protected]>
Cc Ron Mercer <[email protected]>
---
 drivers/net/ethernet/qlogic/qlge/qlge_main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/qlogic/qlge/qlge_main.c +1 -1
index 09d8d33..3c3499d 100644
@@ -4649,7 +4649,7 @@ static int __devinit qlge_probe(struct pci_dev *pdev,
 	int err = 0;
 
 	ndev = alloc_etherdev_mq(sizeof(struct ql_adapter),
-			min(MAX_CPUS, (int)num_online_cpus()));
+			min(MAX_CPUS, netif_get_num_default_rss_queues()));
 	if (!ndev)
 		return -ENOMEM;
 
Signature · 1 line
1.7.9.rc2
#8 lore raw

PATCH 8/11 tg3: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Matt Carlson <[email protected]>
---
 drivers/net/ethernet/broadcom/tg3.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +1 -1
index e47ff8b..6cbab03 100644
@@ -9908,7 +9908,7 @@ static bool tg3_enable_msix(struct tg3 *tp)
 	int i, rc;
 	struct msix_entry msix_ent[tp->irq_max];
 
-	tp->irq_cnt = num_online_cpus();
+	tp->irq_cnt = netif_get_num_default_rss_queues();
 	if (tp->irq_cnt > 1) {
 		/* We want as many rx rings enabled as there are cpus.
 		 * In multiqueue MSI-X mode, the first MSI-X vector
Signature · 1 line
1.7.9.rc2
#9 lore raw

PATCH 9/11 bnx2: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Michael Chan <[email protected]>
---
 drivers/net/ethernet/broadcom/bnx2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +1 -1
index 9eb7624..1901da1 100644
@@ -6250,7 +6250,7 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
 static int
 bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
 {
-	int cpus = num_online_cpus();
+	int cpus = netif_get_num_default_rss_queues();
 	int msix_vecs;
 
 	if (!bp->num_req_rx_rings)
Signature · 1 line
1.7.9.rc2
#7 lore raw

PATCH 7/11 myri10ge: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Jon Mason <[email protected]>
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 -1
index 90153fc..fa85cf1 100644
@@ -3775,7 +3775,7 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp)
 
 	mgp->num_slices = 1;
 	msix_cap = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-	ncpus = num_online_cpus();
+	ncpus = netif_get_num_default_rss_queues();
 
 	if (myri10ge_max_slices == 1 || msix_cap == 0 ||
 	    (myri10ge_max_slices == -1 && ncpus < 2))
Signature · 1 line
1.7.9.rc2
#10 lore raw

PATCH 10/11 bnx2x: set maximal number of default RSS queues

In reply to Yuval Mintz
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +2 -1
index daa894b..53659f3 100644
@@ -822,7 +822,8 @@ static inline int bnx2x_calc_num_queues(struct bnx2x *bp)
 {
 	return  num_queues ?
 		 min_t(int, num_queues, BNX2X_MAX_QUEUES(bp)) :
-		 min_t(int, num_online_cpus(), BNX2X_MAX_QUEUES(bp));
+		 min_t(int, netif_get_num_default_rss_queues(),
+		       BNX2X_MAX_QUEUES(bp));
 }
 
 static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp)
Signature · 1 line
1.7.9.rc2
#11 lore raw

PATCH 11/11 be2net: set maximal number of default RSS queues

In reply to Yuval Mintz
Cc Sathya Perla <[email protected]>
Cc Subbu Seetharaman <[email protected]>
Cc Ajit Khaparde <[email protected]>
---
 drivers/net/ethernet/emulex/benet/be_main.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +6 -4
index edce7af..2141bd7 100644
@@ -2172,12 +2172,14 @@ static void be_msix_disable(struct be_adapter *adapter)
 
 static uint be_num_rss_want(struct be_adapter *adapter)
 {
+	u32 num = 0;
 	if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
 	     !sriov_want(adapter) && be_physfn(adapter) &&
-	     !be_is_mc(adapter))
-		return (adapter->be3_native) ? BE3_MAX_RSS_QS : BE2_MAX_RSS_QS;
-	else
-		return 0;
+	     !be_is_mc(adapter)) {
+		num = (adapter->be3_native) ? BE3_MAX_RSS_QS : BE2_MAX_RSS_QS;
+		num = min_t(u32, num, (u32)netif_get_num_default_rss_queues());
+	}
+	return num;
 }
 
 static void be_msix_enable(struct be_adapter *adapter)
Signature · 1 line
1.7.9.rc2
#12 lore raw
In reply to Yuval Mintz
Quoted 4 lines · Yuval Mintz

Different vendors support different number of RSS queues by default. Today, there exists an ethtool API through which users can change the number of channels their driver supports; This enables us to pursue the goal of using a default number of RSS queues in various multi-queue drivers.

Yuval,

I assume this posting is actually v3 of "[RFC net-next (v2) 00/14] default maximal number of RSS queues in mq drivers" see http://marc.info/?l=linux-netdev&m=134062509310404&w=2?

correct? so what has been changed along v0/v1/v2 --> v3? It would be very helpful to follow if you make sure to mark the patches that makes Vn with "PATCH net-next Vn" and specify the changes from Vn-1, Vn-2...V1, V0.

Or.

#13 lore raw
Quoted 2 lines

I assume this posting is actually v3 of "[RFC net-next (v2) 00/14] default maximal number of RSS queues in mq drivers" see http://marc.info/?l=linux-netdev&m=134062509310404&w=2?

Of course you are correct - the fact that it's based on that RFC is stated explicitly in PATCH 0 of this series.

Quoted 3 lines

correct? so what has been changed along v0/v1/v2 --> v3? It would be very helpful to follow if you make sure to mark the patches that makes Vn with "PATCH net-next Vn" and specify the changes from Vn-1, Vn-2...V1, V0.

Certainly -

Changes from RFC v2:
- Removed changes for igb, igbxe, and igxbevf drivers.

Changes from RFC v1:
- Use 'netif_get_num_default_rss_queues()' wrapper function instead of using a hard-coded define value directly.
- Corrected be2net implementation of this fix.

Cheers,
Yuval

maintainer Applied
#14 lore raw
In reply to Yuval Mintz

From: "Yuval Mintz" <[email protected]>
Date: Sun, 1 Jul 2012 16:18:49 +0300

Quoted 8 lines

Different vendors support different number of RSS queues by default. Today, there exists an ethtool API through which users can change the number of channels their driver supports; This enables us to pursue the goal of using a default number of RSS queues in various multi-queue drivers.

This patch intendeds to achieve the above default, by upper-limiting the number of interrupts multi-queue drivers request (by default, not via the new API) with correlation to the number of cpus on the machine.

Applied to net-next, thanks a lot.