default maximal number of RSS queues in mq drivers
Subsystems (10)
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
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
@@ -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
@@ -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
PATCH 2/11 mlx4: set maximal number of default RSS queues
In reply to Yuval Mintz--- drivers/net/ethernet/mellanox/mlx4/main.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/main.c +3 -2
@@ -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
PATCH 3/11 vxge: set maximal number of default RSS queues
In reply to Yuval Mintz--- 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
@@ -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
PATCH 4/11 qlge: set maximal number of default RSS queues
In reply to Yuval Mintz--- 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
@@ -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
PATCH 5/11 cxgb3: set maximal number of default RSS queues
In reply to Yuval Mintz--- 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
@@ -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
PATCH 6/11 cxgb4: set maximal number of default RSS queues
In reply to Yuval Mintz--- 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
@@ -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
PATCH 7/11 myri10ge: set maximal number of default RSS queues
In reply to Yuval Mintz--- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 -1
@@ -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
PATCH 8/11 tg3: set maximal number of default RSS queues
In reply to Yuval Mintz--- drivers/net/ethernet/broadcom/tg3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +1 -1
@@ -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
PATCH 9/11 bnx2: set maximal number of default RSS queues
In reply to Yuval Mintz--- drivers/net/ethernet/broadcom/bnx2.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +1 -1
@@ -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
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
@@ -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
PATCH 11/11 be2net: set maximal number of default RSS queues
In reply to Yuval Mintz--- 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
@@ -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
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.
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
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.