tcp: add u32 counter in tcp_sock and an SNMP counter for PLB
authorMubashir Adnan Qureshi <mubashirq@google.com>
Wed, 26 Oct 2022 13:51:14 +0000 (13:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Oct 2022 09:47:42 +0000 (10:47 +0100)
A u32 counter is added to tcp_sock for counting the number of PLB
triggered rehashes for a TCP connection. An SNMP counter is also
added to count overall PLB triggered rehash events for a host. These
counters are hooked up to PLB implementation for DCTCP.

TCP_NLA_REHASH is added to SCM_TIMESTAMPING_OPT_STATS that reports
the rehash attempts triggered due to PLB or timeouts. This gives
a historical view of sustained congestion or timeouts experienced
by the TCP connection.

Signed-off-by: Mubashir Adnan Qureshi <mubashirq@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/tcp.h
include/uapi/linux/snmp.h
include/uapi/linux/tcp.h
net/ipv4/proc.c
net/ipv4/tcp.c
net/ipv4/tcp_plb.c

index 41b1da621a458026caeab976843f42e63b59a6de..ca7f05a130d2d14d530207adcc1cc50b7b830c80 100644 (file)
@@ -423,6 +423,7 @@ struct tcp_sock {
                u32               probe_seq_start;
                u32               probe_seq_end;
        } mtu_probe;
+       u32     plb_rehash;     /* PLB-triggered rehash attempts */
        u32     mtu_info; /* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG
                           * while socket was owned by user.
                           */
index 4d7470036a8b5be598bd21367f60854b023cceef..6600cb0164c2beb6f140beaa0bd4ea44e9443b0c 100644 (file)
@@ -292,6 +292,7 @@ enum
        LINUX_MIB_TCPDSACKIGNOREDDUBIOUS,       /* TCPDSACKIgnoredDubious */
        LINUX_MIB_TCPMIGRATEREQSUCCESS,         /* TCPMigrateReqSuccess */
        LINUX_MIB_TCPMIGRATEREQFAILURE,         /* TCPMigrateReqFailure */
+       LINUX_MIB_TCPPLBREHASH,                 /* TCPPLBRehash */
        __LINUX_MIB_MAX
 };
 
index 8fc09e8638b327948705ac57ebddc334a121c18e..c9abe86eda5fda8ed990ed062d8ae93f5d3a2a74 100644 (file)
@@ -315,6 +315,7 @@ enum {
        TCP_NLA_BYTES_NOTSENT,  /* Bytes in write queue not yet sent */
        TCP_NLA_EDT,            /* Earliest departure time (CLOCK_MONOTONIC) */
        TCP_NLA_TTL,            /* TTL or hop limit of a packet received */
+       TCP_NLA_REHASH,         /* PLB and timeout triggered rehash attempts */
 };
 
 /* for TCP_MD5SIG socket option */
index 5386f460bd208c8f30902ea8b6aa613449d59ee0..f88daace9de3e1e747c67710f55a198758243482 100644 (file)
@@ -297,6 +297,7 @@ static const struct snmp_mib snmp4_net_list[] = {
        SNMP_MIB_ITEM("TCPDSACKIgnoredDubious", LINUX_MIB_TCPDSACKIGNOREDDUBIOUS),
        SNMP_MIB_ITEM("TCPMigrateReqSuccess", LINUX_MIB_TCPMIGRATEREQSUCCESS),
        SNMP_MIB_ITEM("TCPMigrateReqFailure", LINUX_MIB_TCPMIGRATEREQFAILURE),
+       SNMP_MIB_ITEM("TCPPLBRehash", LINUX_MIB_TCPPLBREHASH),
        SNMP_MIB_SENTINEL
 };
 
index ef14efa1fb70eaaecfc7884de32b74c49bb25a39..1da7c53b6cb532984497a5da59dfc853371d4480 100644 (file)
@@ -3176,6 +3176,7 @@ int tcp_disconnect(struct sock *sk, int flags)
        tp->sacked_out = 0;
        tp->tlp_high_seq = 0;
        tp->last_oow_ack_time = 0;
+       tp->plb_rehash = 0;
        /* There's a bubble in the pipe until at least the first ACK. */
        tp->app_limited = ~0U;
        tp->rack.mstamp = 0;
@@ -3973,6 +3974,7 @@ static size_t tcp_opt_stats_get_size(void)
                nla_total_size(sizeof(u32)) + /* TCP_NLA_BYTES_NOTSENT */
                nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_EDT */
                nla_total_size(sizeof(u8)) + /* TCP_NLA_TTL */
+               nla_total_size(sizeof(u32)) + /* TCP_NLA_REHASH */
                0;
 }
 
@@ -4049,6 +4051,7 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,
                nla_put_u8(stats, TCP_NLA_TTL,
                           tcp_skb_ttl_or_hop_limit(ack_skb));
 
+       nla_put_u32(stats, TCP_NLA_REHASH, tp->plb_rehash + tp->timeout_rehash);
        return stats;
 }
 
index f4ced370acad3c181e0485411400c3552ae3b243..bb1a08fda113e170cd47d59c5e303d14aa86bad5 100644 (file)
@@ -79,6 +79,8 @@ void tcp_plb_check_rehash(struct sock *sk, struct tcp_plb_state *plb)
 
        sk_rethink_txhash(sk);
        plb->consec_cong_rounds = 0;
+       tcp_sk(sk)->plb_rehash++;
+       NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPPLBREHASH);
 }
 EXPORT_SYMBOL_GPL(tcp_plb_check_rehash);