ixgbe: 设置RX/TX队列数量

7
我想设置由Intel 10G网卡使用的RX/TX队列数。让我解释一下原因:
我正在Dell R720系统上使用类型为X520的Intel 10G网卡,使用ixgbe版本3.6.7-k和Ubuntu 3.2.0-59内核。
我在机器上的24个核心中有4个运行网络应用程序。目前,该网卡正在使用流直接器,因此我有24个TX和RX队列,而大多数IRQ最终在运行应用程序的4个核心上运行。
然而,我看到一些IRQ正在其他20个队列上运行(这可能是因为流直接器约有20%的流量被采样,因此一些流量通过常规RSS)。现在,我不想任何IRQ在其他20个核心上运行,因为它们正在执行不同的任务,受到IRQ运行的损害。
我尝试将中断的关联性仅设置为我使用的4个核心,但这在流直接器方面效果不佳。我想更好的方法是仅使用4个RX/TX队列并将它们分配给专用核心。但是我找不到在ixgbe驱动程序中设置RX/TX队列数量的方法(尽管我熟悉的其他10G驱动程序,如Broadcom的bnx2x,非常简单)。
有什么建议吗?
2个回答

4
一些包括ixgbe驱动程序的Linux内核版本(自2013年,3.9内核版本以来,“ixgbe”的“3.11.33-k”版本)甚至可以在没有RSS模块选项的情况下在运行时更改RSS(队列)计数。有一个名为ethtool工具 用于更改网络卡的参数,并且有更改通道的选项:
   ethtool -l|--show-channels devname

   ethtool -L|--set-channels devname [rx N] [tx N] [other N]
          [combined N]


   -l --show-channels
          Queries the specified network device for the numbers of
          channels it has.  A channel is an IRQ and the set of queues
          that can trigger that IRQ.

   -L --set-channels
          Changes the numbers of channels of the specified network
          device.

       rx N   Changes the number of channels with only receive queues.

       tx N   Changes the number of channels with only transmit queues.

       other N
              Changes the number of channels used only for other
              purposes e.g. link interrupts or SR-IOV co-ordination.

       combined N
              Changes the number of multi-purpose channels.

使用ethtool -l eth1测试ixgbe eth1的当前通道(RSS、队列)计数,并使用ethtool -L eth1 combined 4ethtool -L eth1 rx 2 tx 2进行更改。此功能实现在net/ethernet/intel/ixgbe/ixgbe_ethtool.c中:http://elixir.free-electrons.com/linux/v4.12/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c#L3442。其中,ixgbe_get_channels用于获取通道信息:http://elixir.free-electrons.com/linux/v4.12/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c#L3127ixgbe_set_channels用于更改adapter->ring_feature[RING_F_RSS].limithttp://elixir.free-electrons.com/linux/v4.12/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c#L3164。此功能自Linux内核3.9版本(约2013年)开始实现:http://elixir.free-electrons.com/linux/v3.9/ident/ixgbe_get_channelshttps://patchwork.ozlabs.org/patch/211119/https://patchwork.ozlabs.org/patch/211120/

1
是否可以将其增加到默认硬件设置之外?目前,我的Amazon Linux实例有8个RX和8个TX。当我尝试ethtool -L eth1 rx 10 tx 10时,它会抛出无法设置设备通道参数:不支持的操作。是否有绕过方式来增加队列? 由于该实例具有更多的CPU核心,我希望通过增加队列来利用它们。 - Baskar
@Baskar 据我所知,ethtool 是硬件配置工具,不适用于流量整形。如果您想要进行更深入的软件流量整形,可以考虑使用 tc "traffic control" qdiscs、classes 和 filters。详情请参见 https://man7.org/linux/man-pages/man8/tc.8.html。 - TheDiveO

4

最新的Linux内核源代码(截至3.18.0-rc1)中,ixgbe驱动程序(当前版本为3.19.1-k)不支持此操作。

您需要从e1000.sf.net下载最新的ixgbe驱动程序(当前版本为3.22.3),该驱动程序支持RSS参数。通过modinfo ixgbe命令可以查看:

parm: RSS:接收端缩放描述符队列数,默认值为0= CPU数量(int数组)

因此,如果您有一个ixgbe NIC并希望使用4个队列,则需要在modprobe.conf(或相应的发行版中)中添加类似于以下内容的一行:

options ixgbe RSS=4

然后,您需要设置/proc/irq/*/smp_affinity CPU掩码,以匹配/proc/interrupts中与您的网络接口卡相匹配的IRQ。


1
实际上,自2013年内核的3.9版本以及来自内核(而不是e1000 sf net)的“3.11.33-k”版本的ixgbe驱动程序以来,这是可能的。 ethtool -L eth1 combined 4 将更改队列号(我理解需要部分重新初始化卡)。 - osgx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接