netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mubashir Adnan Qureshi <mubashirmaq@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, kuba@kernel.org,
	Mubashir Adnan Qureshi <mubashirq@google.com>,
	Yuchung Cheng <ycheng@google.com>,
	Neal Cardwell <ncardwell@google.com>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next v2 4/5] tcp: add u32 counter in tcp_sock and an SNMP counter for PLB
Date: Fri, 30 Sep 2022 04:53:19 +0000	[thread overview]
Message-ID: <20220930045320.5252-5-mubashirmaq@gmail.com> (raw)
In-Reply-To: <20220930045320.5252-1-mubashirmaq@gmail.com>

From: Mubashir Adnan Qureshi <mubashirq@google.com>

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>
---
 include/linux/tcp.h       | 1 +
 include/uapi/linux/snmp.h | 1 +
 include/uapi/linux/tcp.h  | 1 +
 net/ipv4/proc.c           | 1 +
 net/ipv4/tcp.c            | 3 +++
 net/ipv4/tcp_plb.c        | 2 ++
 6 files changed, 9 insertions(+)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index a9fbe22732c3..332870bb09fc 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -417,6 +417,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.
 			   */
diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h
index 4d7470036a8b..6600cb0164c2 100644
--- a/include/uapi/linux/snmp.h
+++ b/include/uapi/linux/snmp.h
@@ -292,6 +292,7 @@ enum
 	LINUX_MIB_TCPDSACKIGNOREDDUBIOUS,	/* TCPDSACKIgnoredDubious */
 	LINUX_MIB_TCPMIGRATEREQSUCCESS,		/* TCPMigrateReqSuccess */
 	LINUX_MIB_TCPMIGRATEREQFAILURE,		/* TCPMigrateReqFailure */
+	LINUX_MIB_TCPPLBREHASH,			/* TCPPLBRehash */
 	__LINUX_MIB_MAX
 };
 
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 8fc09e8638b3..c9abe86eda5f 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -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 */
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 5386f460bd20..f88daace9de3 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -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
 };
 
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 648b5c54bb32..685c06c6d33f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3173,6 +3173,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;
@@ -3969,6 +3970,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;
 }
 
@@ -4045,6 +4047,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;
 }
 
diff --git a/net/ipv4/tcp_plb.c b/net/ipv4/tcp_plb.c
index 26ffc5a45f53..04f4cac8645b 100644
--- a/net/ipv4/tcp_plb.c
+++ b/net/ipv4/tcp_plb.c
@@ -73,6 +73,8 @@ void tcp_plb_check_rehash(struct sock *sk, struct tcp_plb_state *plb)
 	if (!plb->pause_until && (can_idle_rehash || can_force_rehash)) {
 		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);
-- 
2.38.0.rc1.362.ged0d419d3c-goog


  parent reply	other threads:[~2022-09-30  4:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 14:24 [PATCH net-next 0/5] Add PLB functionality to TCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 1/5] tcp: add sysctls for TCP PLB parameters Mubashir Adnan Qureshi
2022-09-30  2:37   ` Jakub Kicinski
2022-09-29 14:24 ` [PATCH net-next 2/5] tcp: add PLB functionality for TCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 3/5] tcp: add support for PLB in DCTCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 4/5] tcp: add u32 counter in tcp_sock and an SNMP counter for PLB Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 5/5] tcp: add rcv_wnd and plb_rehash to TCP_INFO Mubashir Adnan Qureshi
2022-09-30  4:53 ` [PATCH net-next v2 0/5] Add PLB functionality to TCP Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 1/5] tcp: add sysctls for TCP PLB parameters Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 2/5] tcp: add PLB functionality for TCP Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 3/5] tcp: add support for PLB in DCTCP Mubashir Adnan Qureshi
2022-09-30  4:53   ` Mubashir Adnan Qureshi [this message]
2022-09-30  4:53   ` [PATCH net-next v2 5/5] tcp: add rcv_wnd and plb_rehash to TCP_INFO Mubashir Adnan Qureshi
2022-10-03 23:42   ` [PATCH net-next v2 0/5] Add PLB functionality to TCP Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220930045320.5252-5-mubashirmaq@gmail.com \
    --to=mubashirmaq@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=mubashirq@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).