ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Is TCP PACING enabled by default on linux?

2022-02-08 01:05:40  阅读:220  来源: 互联网

标签:default enabled pacing TCP sk rate PACING


https://unix.stackexchange.com/questions/337456/is-tcp-pacing-enabled-by-default-on-linux

 

Asked 5 years ago
Active 2 years, 10 months ago
Viewed 3k times

Q

 

I want to ask a basic question: Is TCP PACING enabled by default on Linux? I'm using Ubuntu right now, kernel 4.4.0.

I saw that it can be enabled/disabled using TC-FQ, but is it enabled by default using TC only, or the default is disabled?

 

 

 

Answer

 

Short answer: for kernel 4.4.0 TCP PACING is enabled by default and is set to ~34.36Gb/s per socket. Since kernel 4.13.0-rc1, TCP PACING is disabled by default. On both cases, since TSO is enabled, TCP PACING would have no effect when pacing rate is set to the default value.

TCP PACING is set for a socket using the sock_setsockopt() function (net/core/sock.c). The flag for doing so is SO_MAX_PACING_RATE, and the handling code is as follow:

case SO_MAX_PACING_RATE:
        sk->sk_max_pacing_rate = val;
        sk->sk_pacing_rate = min(sk->sk_pacing_rate,
                     sk->sk_max_pacing_rate);
        break;
On socket creation the relevant fields are set to ~0U in sock_init_data() (net/core/sock.c):

sk->sk_max_pacing_rate = ~0U;
sk->sk_pacing_rate = ~0U;
So the default values for pacing rate and max pacing rate is max unsigned int value, which is (2^32 - 1), or 4,294,967,295 Bytes per second, which are 34.36Gb/s.

It is possible, however, to get to higher rates even with a single socket by using TCP segmentation offload (TSO). The TSO takes the pacing rate into consideration, but isn't really bounded by the default rate. In tcp_tso_autosize() function (net/ipv4/tcp_output.c) the pacing rate might reduce the size of the TSO session, but since the default value is ~4.3GB and even after shifting right by 10 you still get ~4MB, it is much bigger than the typical TSO session.

static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now)
{
    u32 bytes, segs;

    bytes = min(sk->sk_pacing_rate >> 10,
            sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);

    /* Goal is to send at least one packet per ms,
     * not one big TSO packet every 100 ms.
     * This preserves ACK clocking and is consistent
     * with tcp_tso_should_defer() heuristic.
     */
    segs = max_t(u32, bytes / mss_now, sysctl_tcp_min_tso_segs);

    return min_t(u32, segs, sk->sk_gso_max_segs);
}
I tried actually hitting the 34Gb/s limitation, but unfortunately, without TSO CPU utilization on TX side limit the single socket BW to ~23Gb/s.

A patch by Eric Dumazet tcp: internal implementation for pacing was introduced on kernel 4.13.0-rc1. This patch enhances TCP PACING abilities. For once, it allow for pacing without using TC-FQ. It also disables pacing entirely if the sk_pacing_rate field is set to 0 or ~0U (default). See the patch cover and code for more details.

 

标签:default,enabled,pacing,TCP,sk,rate,PACING
来源: https://www.cnblogs.com/ztguang/p/15869898.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有