首页 > 其他分享 >[RoCE] 通过QoS对Mellanox网卡进行限速

[RoCE] 通过QoS对Mellanox网卡进行限速

时间:2024-04-16 19:47:53浏览次数:19  
标签:priority QoS unlimited vendor tsa 网卡 ratelimit RoCE tc

参考资料:

Quality of Service (QoS) - NVIDIA Docs

【RDMA】RoCE网络QoS|应用层设置PFC等级|Tos|Priority|TC_cma_roce_tos-CSDN博客

【RDMA】mellonx流控配置工具mlnx_qos|PFC-CSDN博客

前言

目标:我有一个Mellanox-5网卡,我想用RoCE,同时对某些qp进行限速。

然而,Mellanox-5网卡在RoCE模式下是无法对每个QP进行单独限速的。

我试了很多方法,但都失败了。最显然的做法是使用 ibv_modify_qp时修改attr.ah_attr.static_rate参数(rdmamojo.com)。然而并没有效果。我尝试了其它一些可能和rate limit有关的API,比如ibv_modify_qp_rate_limit和修改attr.rate_limit,也都没有用。我在官方的perftest(linux-rdma/perftest: Infiniband Verbs Performance Tests (github.com))里设置static_rate参数,结果它告诉我:

The QP failed to accept HW rate limit

我查看网卡的配置,发现:

$ ibv_devinfo -v
hca_id: mlx5_1
		...
        packet_pacing_caps:
                qp_rate_limit_min:      0kbps
                qp_rate_limit_max:      0kbps

qp_rate_limit_minqp_rate_limit_max都是0,这明摆着是用不了rate limit。无奈只得另寻他法。

经过一番寻找,我找到了用QoS进行限速的方法。

使用QoS进行限速

具体的文档可见Quality of Service (QoS) - NVIDIA Docs

1. 查看网卡的QoS信息

ifconfig里,我的网卡名字是ens10f1np1

$ mlnx_qos -i ens10f1np1
DCBX mode: OS controlled
Priority trust state: pcp
default priority:
Receive buffer size (bytes): 0,262016,0,0,0,0,0,0,
Cable len: 7
PFC configuration:
        priority    0   1   2   3   4   5   6   7
        enabled     0   0   0   0   0   0   0   0   
        buffer      1   1   1   1   1   1   1   1   
tc: 1 ratelimit: unlimited, tsa: vendor
         priority:  0
tc: 0 ratelimit: unlimited, tsa: vendor
         priority:  1
tc: 2 ratelimit: unlimited, tsa: vendor
         priority:  2
tc: 3 ratelimit: unlimited, tsa: vendor
         priority:  3
tc: 4 ratelimit: unlimited, tsa: vendor
         priority:  4
tc: 5 ratelimit: unlimited, tsa: vendor
         priority:  5
tc: 6 ratelimit: unlimited, tsa: vendor
         priority:  6
tc: 7 ratelimit: unlimited, tsa: vendor
         priority:  7

QoS有两种trust mode:PCP和DSCP。其中PCP是L2层的,使用vlan包头的一部分。而DSCP是L3层的,使用IP包头的一部分。由于我们想要使用RoCEv2,不包含vlan而包含IP,所以自然用DSCP是更合适的。

网卡默认的trust mode是PCP,这里我们把它改成DSCP。

$ sudo mlnx_qos -i ens10f1np1 --trust dscp
DCBX mode: OS controlled
Priority trust state: dscp
dscp2prio mapping:
        prio:0 dscp:07,06,05,04,03,02,01,00,
        prio:1 dscp:15,14,13,12,11,10,09,08,
        prio:2 dscp:23,22,21,20,19,18,17,16,
        prio:3 dscp:31,30,29,28,27,26,25,24,
        prio:4 dscp:39,38,37,36,35,34,33,32,
        prio:5 dscp:47,46,45,44,43,42,41,40,
        prio:6 dscp:55,54,53,52,51,50,49,48,
        prio:7 dscp:63,62,61,60,59,58,57,56,
default priority:
Receive buffer size (bytes): 0,262016,0,0,0,0,0,0,
Cable len: 7
PFC configuration:
        priority    0   1   2   3   4   5   6   7
        enabled     0   0   0   0   0   0   0   0   
        buffer      1   1   1   1   1   1   1   1   
tc: 1 ratelimit: unlimited, tsa: vendor
         priority:  0
tc: 0 ratelimit: unlimited, tsa: vendor
         priority:  1
tc: 2 ratelimit: unlimited, tsa: vendor
         priority:  2
tc: 3 ratelimit: unlimited, tsa: vendor
         priority:  3
tc: 4 ratelimit: unlimited, tsa: vendor
         priority:  4
tc: 5 ratelimit: unlimited, tsa: vendor
         priority:  5
tc: 6 ratelimit: unlimited, tsa: vendor
         priority:  6
tc: 7 ratelimit: unlimited, tsa: vendor
         priority:  7

可以看到,上面一共包含8个Traffic Class(TC),8个priority,以及8个buffer。由于我们的目标只是限速,所以我们不去修改TC,priority,buffer之间的关系。

2. 设置ToS

在RoCEv2模式下,配置一个qp对应哪个Traffic TC的流程如下。

  1. 在应用层,为每个qp设置一个Type-of-Service(ToS)。
  2. ToS的高6bit为DSCP,低2bit无所谓。
  3. 根据上文的映射表将DSCP映射为TC。

ToS在IP包头中的含义在这里:

image

假如我们想要对TC4进行限速。根据DSCP的映射表,我们可以选取DSCP=32(32到39都行)。因此对应的ToS就是128(128到159都行)。

然后,我们想要把TC4限速为4Gbps。

$ sudo mlnx_qos -i ens10f1np1 --ratelimit=0,0,0,0,4,0,0,0
...
tc: 4 ratelimit: 4.0 Gbps, tsa: vendor
         priority:  4

配置成功。

3. 应用层设置ToS

对于ibverb API的使用者,在设置Address Vector的时候,将attr.ah_attr.grh.traffic_class这一项设置为想要的ToS即可(注意虽然这个参数叫traffic_class,但它的值不是TC,而是ToS)。

对于RDMA CM的使用者,使用rdma_set_option(cma_id, RDMA_OPTION_ID, RDMA_OPTION_ID_TOS, &your_tos, sizeof(uint8_t))即可设置ToS。

测试

我们已经在机器A上配置好了限速,现在测一下从机器A到另一台机器B进行RDMA WRITE的吞吐。

在B上运行(这里mlx5_1是网卡的ib名字,使用ibdev2netdev可以查看)

$ ib_write_bw -d mlx5_1 -x 3

在A上运行

$ ib_write_bw <B_IP> -d mlx5_1 -x 3 --tclass=128

结果

---------------------------------------------------------------------------------------
 #bytes     #iterations    BW peak[MB/sec]    BW average[MB/sec]   MsgRate[Mpps]
 65536      5000             9205.89            450.24             0.007204
---------------------------------------------------------------------------------------

可以发现,确实将平均速度限制到了4Gbps以下。然而,峰值速度貌似是限制不住的(悲)。

而对于其它的ToS:

$ ib_write_bw <B_IP> -d mlx5_1 -x 3 --tclass=0
---------------------------------------------------------------------------------------
 #bytes     #iterations    BW peak[MB/sec]    BW average[MB/sec]   MsgRate[Mpps]
 65536      5000             8501.98            4726.36            0.075622
---------------------------------------------------------------------------------------

速度则不受限制。

标签:priority,QoS,unlimited,vendor,tsa,网卡,ratelimit,RoCE,tc
From: https://www.cnblogs.com/CQzhangyu/p/18139026

相关文章

  • process scheduling (进程调度)& practice 1 process operation
    进程切换并发进程的切换并发进程中,一个进程在执行过程中可能被另一个进程替换占有CPU,这个过程称为“进程切换”是什么触发了进程切换?进程切换时要做什么?操作系统到底做了什么操作2中断技术中断是指程序执行过程中当发生某一个事件时,中止cpu上现行的程序的运行in......
  • 【Spring】AOP进阶-JoinPoint和ProceedingJoinPoint详解
    2024-04-141.前言在Spring AOP中,JoinPoint和ProceedingJoinPoint都是关键的接口,用于在切面中获取方法的相关信息以及控制方法的执行。它们的主要区别在于它们在AOP通知中的使用方式和功能。2.JoinPoint简介Joinpoint是面向切面编程(AOP)中的一个重要概念,指的是在应用程序执行......
  • SpringBoot项目中对定义的多个BeanPostProcessor排序
    前言BeanPostProcessor是Spring提供的一种扩展机制,可以让我们在bean初始化前后做一些额外的操作,Spring中的@Async,@Scheduled,@RabbitHandler等注解的底层实现都是BeanPostProcessor在起作用,如RabbitListenerAnnotationBeanPostProcessor。代码示例@Configurationpub......
  • process concept
    进程的定义程序和进程Aprogramisapassiveentity(是被动的主体),suchasafilecontainingalistofinstructionsstoredondisk(oftencalledanexecutablefile(就是可执行文件))Aprogrambecomesaprocesswhenanexecutablefileisloadedintomemory.(可执......
  • Kaggle自然语言处理入门 推特灾难文本分类 Natural Language Processing with Disaste
    和新闻按照标题分类差不多,用的朴素贝叶斯#导入必要的包importrandomimportsysfromsklearnimportmodel_selectionfromsklearn.naive_bayesimportMultinomialNBimportjoblibimportre,stringimportpandasaspdimportnumpyasnpdeftext_to_words(file_path)......
  • 揭秘:哪种物联网卡信号好网速快?
    物联卡是一种专门用于物联网设备通信的SIM卡,它能够提供网络连接以支持设备之间的数据传输。在选择物联卡时,信号质量和网速是两个重要的考虑因素。物联卡的信号覆盖直接关系到设备的通信稳定性和数据传输效率。在选择物联卡时,我们需要关注运营商的基站数量、网络覆盖范围以及信号质......
  • 52 Things: Number 2: What is the difference between a multi-core processor and a
    52Things:Number2:Whatisthedifferencebetweenamulti-coreprocessorandavectorprocessor?52件事:数字2:多核处理器和矢量处理器有什么区别?Onthefaceofit,youmaybeconfusedastowhatthedifferenceisbetweenthesetwoprocessors.Afterall,yo......
  • 52 Things: Number 1 : Different Types of Processors
    52Things:Number1:DifferentTypesofProcessors52件事:数字1:不同类型的处理器Thisisthefirstinaseriesofblogpoststoaddressthelistof '52ThingsEveryPhDStudentShouldKnow' todoCryptography.Thesetofquestionshasbeencompiledt......
  • Understanding the linux kernel Chapter 7 Process Scheduling
    SchedulingPolicyLinuxschedulingisbasedonthetimesharingtechnique:severalprocessesrunin“timemultiplexing”becausetheCPUtimeisdividedintoslices(called,quantum),oneforeachrunnableprocess.Analternativeclassificationdistinguis......
  • Hyper-V下的Linux虚拟机网卡丢失问题原因及解决办法
    陌上归人的博客-博客园 https://www.cnblogs.com/fjping0606/p/4428495.htmlHyper-V下的Linux虚拟机网卡丢失问题原因及解决办法Hyper-V下的Linux虚拟机网卡丢失问题原因及解决办法 虚拟化大势所趋公司推行了虚拟化,全部用的是MicrosoftWindows2008R2EnterprisewithHyp......