From nobody Fri Sep 18 22:02:20 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hmmnS4vxsz6t2lY for ; Fri, 18 Sep 2026 22:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hmmnS43g3z4yr1 for ; Fri, 18 Sep 2026 22:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789768940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+3AnTa6oxLzEWPvkho/LeLj6iDxJiZ6eeEjjmoGFvBg=; b=WcgLqDM1od6Q1mKnyqY1TZZaUb3KJ4gDeRtevqw31Dc7WMeoFhnBD8KYETqVPQnMWudKsp ZYJ8fMHZN5GwSNi5QoJgxxCl8Idjfjo59h4AeVGmkz6PNBm5TjGfvw+tVUDRoDoN3enlXT RXaHX5d6bxDzdyE7qPHACHCDvcrbE4689aSnj9/Xp4YHbr3hMNSQ56aBvsFn2AP0b/KzcU PhKiI9lGTyp0Lhvn4bO6CITXC1/EPxmUi0LgGqKtoqFXuqdRdiL61NYHpsvIT4/gJo+hn0 ALPoNSudFq34U6/9OWv86nLK+QKh3hF/8oq1Z0K9059rPQwsj1SFcwQGg+YBiA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789768940; b=UGspz/lciBkAy7OO1o51674PxrbM24aTQbpL2FwTKWRSYtK/iqSt4+6CIFZ2KTd6tvgTHK 00McdL71XYIyl/aEq9zTC/iOAUOpUAZkwoKcpHLdWkOjH8sh76FHGojd05/bVwlYvuBHex lc8FqP0SYCU+MspKfOxl4fXj+psfwXu+YqPz5c9l440hJ9ld2KOe3/myfXZUf+u0UTZoDx gYv6hlcf/HkxLieRmGkyQkTl9bbPbX6PNMlDY9SxTru4h5JhMPUjO3eeJS2hEaNqUgAelP HQRL1aBaISjhFkQwlyw8PzdYJEjd9ihAAjTqWV91s64Bhq7iP9VRD1MCC2mepg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789768940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+3AnTa6oxLzEWPvkho/LeLj6iDxJiZ6eeEjjmoGFvBg=; b=xfRapQy13N1yCuCA5SvSJSbjra8lEITYmfyTdepwZuhdKBYFu63m1d5iO2vVKzwkjVWqWj r+C1KV8L0jdCtf3V8TECwPYWAAQca7ZlGQovRqA1HWMw+W10OyN0RYWNGmxmwjQPIKVT2H 7A9ORlNdmSYQzrn4k4dMg+9Z+i1YVKmJqdh3Y5fYJkagNbr+yVpSPSaq4MnrlGnsz70vov rH7yCS3TEUctwav80rwzXlsIDYeOLyDPyKW55cbo0STMDmLBTw+1RXq4liKmHfYf759sQU 8eIQI5NWSHtZ8E4KNF0whNlz/3sxsTjM3uTmlJzF5gvEGMLdJD4np2hQNfosRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hmmnS35bkzf3f for ; Fri, 18 Sep 2026 22:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c9cb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 18 Sep 2026 22:02:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: f8f05fe48d0f - main - tcp: collect and report more statistics on the TCP host cache List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8f05fe48d0fe2538dad4c2d0f8e26ea3407b1f7 Auto-Submitted: auto-generated Date: Fri, 18 Sep 2026 22:02:20 +0000 Message-Id: <6aadb4ec.1c9cb.14321e6b@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=f8f05fe48d0fe2538dad4c2d0f8e26ea3407b1f7 commit f8f05fe48d0fe2538dad4c2d0f8e26ea3407b1f7 Author: Gleb Smirnoff AuthorDate: 2026-09-18 21:56:54 +0000 Commit: Gleb Smirnoff CommitDate: 2026-09-18 21:56:54 +0000 tcp: collect and report more statistics on the TCP host cache Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D59451 --- sys/netinet/in_kdtrace.c | 12 ++++++++--- sys/netinet/in_kdtrace.h | 12 ++++++++--- sys/netinet/tcp_hostcache.c | 12 +++++++---- sys/netinet/tcp_var.h | 13 +++++++++--- usr.bin/netstat/inet.c | 49 ++++++++++++++++++++++++++++++--------------- 5 files changed, 69 insertions(+), 29 deletions(-) diff --git a/sys/netinet/in_kdtrace.c b/sys/netinet/in_kdtrace.c index de2a98ce541c..917e6b8be137 100644 --- a/sys/netinet/in_kdtrace.c +++ b/sys/netinet/in_kdtrace.c @@ -259,9 +259,6 @@ MIB_PROBE_TCP(tcps_pawsdrop); MIB_PROBE_TCP(tcps_predack); MIB_PROBE_TCP(tcps_preddat); MIB_PROBE_TCP(tcps_pcbackemiss); -MIB_PROBE_TCP(tcps_cachedrtt); -MIB_PROBE_TCP(tcps_cachedrttvar); -MIB_PROBE_TCP(tcps_cachedssthresh); MIB_PROBE_TCP(tcps_usedrtt); MIB_PROBE_TCP(tcps_usedrttvar); MIB_PROBE_TCP(tcps_usedssthresh); @@ -289,8 +286,17 @@ MIB_PROBE_TCP(tcps_sc_recvcookie); MIB_PROBE_TCP(tcps_sc_spurcookie); MIB_PROBE_TCP(tcps_sc_failcookie); +MIB_PROBE_TCP(tcps_hc_hits); +MIB_PROBE_TCP(tcps_hc_misses); MIB_PROBE_TCP(tcps_hc_added); MIB_PROBE_TCP(tcps_hc_bucketoverflow); +MIB_PROBE_TCP(tcps_hc_allocfail); +MIB_PROBE_TCP(tcps_cachedrtt); +MIB_PROBE_TCP(tcps_cachedrttvar); +MIB_PROBE_TCP(tcps_cachedssthresh); +MIB_PROBE_TCP(tcps_cachedcwnd); +MIB_PROBE_TCP(tcps_cachedsendpipe); +MIB_PROBE_TCP(tcps_cachedrecvpipe); MIB_PROBE_TCP(tcps_finwait2_drops); diff --git a/sys/netinet/in_kdtrace.h b/sys/netinet/in_kdtrace.h index a203b660d777..08fab3949b5c 100644 --- a/sys/netinet/in_kdtrace.h +++ b/sys/netinet/in_kdtrace.h @@ -251,9 +251,6 @@ SDT_PROBE_DECLARE(mib, tcp, count, tcps_pawsdrop); SDT_PROBE_DECLARE(mib, tcp, count, tcps_predack); SDT_PROBE_DECLARE(mib, tcp, count, tcps_preddat); SDT_PROBE_DECLARE(mib, tcp, count, tcps_pcbcachemiss); -SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrtt); -SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrttvar); -SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedssthresh); SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrtt); SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrttvar); SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedssthresh); @@ -281,8 +278,17 @@ SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_recvcookie); SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_spurcookie); SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_failcookie); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_hits); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_misses); SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_added); SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_bucketoverflow); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_allocfail); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrtt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrttvar); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedssthresh); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedcwnd); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedsendpipe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrecvpipe); SDT_PROBE_DECLARE(mib, tcp, count, tcps_finwait2_drops); diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index 7a5e2ef095ec..d3bac8f7f11d 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -362,8 +362,11 @@ tcp_hc_lookup(const struct in_conninfo *inc) #ifdef TCP_HC_COUNTERS hc_entry->hc_hits++; #endif - } else + TCPSTAT_INC(tcps_hc_hits); + } else { smr_exit(V_tcp_hostcache.smr); + TCPSTAT_INC(tcps_hc_misses); + } return (hc_entry); } @@ -527,6 +530,7 @@ tcp_hc_update(const struct in_conninfo *inc, struct tcp_hc_metrics *hcm) hc_entry = uma_zalloc_smr(V_tcp_hostcache.zone, M_NOWAIT); if (hc_entry == NULL) { THC_UNLOCK(hc_head); + TCPSTAT_INC(tcps_hc_allocfail); return; } @@ -584,7 +588,7 @@ tcp_hc_update(const struct in_conninfo *inc, struct tcp_hc_metrics *hcm) v = ((uint64_t)hc_entry->hc_cwnd + (uint64_t)hcm->hc_cwnd) / 2; atomic_store_32(&hc_entry->hc_cwnd, v); - /* TCPSTAT_INC(tcps_cachedcwnd); */ + TCPSTAT_INC(tcps_cachedcwnd); } if (hcm->hc_sendpipe != 0) { if (hc_entry->hc_sendpipe == 0) @@ -593,7 +597,7 @@ tcp_hc_update(const struct in_conninfo *inc, struct tcp_hc_metrics *hcm) v = ((uint64_t)hc_entry->hc_sendpipe + (uint64_t)hcm->hc_sendpipe) / 2; atomic_store_32(&hc_entry->hc_sendpipe, v); - /* TCPSTAT_INC(tcps_cachedsendpipe); */ + TCPSTAT_INC(tcps_cachedsendpipe); } if (hcm->hc_recvpipe != 0) { if (hc_entry->hc_recvpipe == 0) @@ -602,7 +606,7 @@ tcp_hc_update(const struct in_conninfo *inc, struct tcp_hc_metrics *hcm) v = ((uint64_t)hc_entry->hc_recvpipe + (uint64_t)hcm->hc_recvpipe) / 2; atomic_store_32(&hc_entry->hc_recvpipe, v); - /* TCPSTAT_INC(tcps_cachedrecvpipe); */ + TCPSTAT_INC(tcps_cachedrecvpipe); } /* diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 39a5cca1d635..8400824761ed 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1022,9 +1022,6 @@ struct tcpstat { uint64_t tcps_predack; /* times hdr predict ok for acks */ uint64_t tcps_preddat; /* times hdr predict ok for data pkts */ uint64_t tcps_pcbcachemiss; - uint64_t tcps_cachedrtt; /* times cached RTT in route updated */ - uint64_t tcps_cachedrttvar; /* times cached rttvar updated */ - uint64_t tcps_cachedssthresh; /* times cached ssthresh updated */ uint64_t tcps_usedrtt; /* times RTT initialized from route */ uint64_t tcps_usedrttvar; /* times RTTVAR initialized from rt */ uint64_t tcps_usedssthresh; /* times ssthresh initialized from rt*/ @@ -1052,8 +1049,18 @@ struct tcpstat { uint64_t tcps_sc_spurcookie; /* SYN cookie spurious, rejected */ uint64_t tcps_sc_failcookie; /* SYN cookie failed, rejected */ + /* TCP host cache */ + uint64_t tcps_hc_hits; + uint64_t tcps_hc_misses; uint64_t tcps_hc_added; /* entry added to hostcache */ uint64_t tcps_hc_bucketoverflow;/* hostcache per bucket limit hit */ + uint64_t tcps_hc_allocfail; /* hostcache zone full */ + uint64_t tcps_cachedrtt; /* times cached RTT in route updated */ + uint64_t tcps_cachedrttvar; /* times cached rttvar updated */ + uint64_t tcps_cachedssthresh; /* times cached ssthresh updated */ + uint64_t tcps_cachedcwnd; /* times cached congestion window */ + uint64_t tcps_cachedsendpipe; /* times cached send buffer size */ + uint64_t tcps_cachedrecvpipe; /* times cached recv buffer size */ uint64_t tcps_finwait2_drops; /* Drop FIN_WAIT_2 connection after time limit */ diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index ddc9a2fdd2f4..07e3e952a289 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -612,6 +612,8 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) xo_emit(m, (uintmax_t )tcpstat.f, plural(tcpstat.f)) #define p1a(f, m) if (tcpstat.f || sflag <= 1) \ xo_emit(m, (uintmax_t )tcpstat.f) +#define p1b(f, m) if (tcpstat.f || sflag <= 1) \ + xo_emit(m, (uintmax_t )tcpstat.f, plurales(tcpstat.f)) #define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ xo_emit(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \ (uintmax_t )tcpstat.f2, plural(tcpstat.f2)) @@ -714,23 +716,9 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) "{N:/ignored RSTs in the window%s}\n"); p(tcps_connects, "\t{:connections-established/%ju} " "{N:/connection%s established (including accepts)}\n"); - p(tcps_usedrtt, "\t\t{:connections-hostcache-rtt/%ju} " - "{N:/time%s used RTT from hostcache}\n"); - p(tcps_usedrttvar, "\t\t{:connections-hostcache-rttvar/%ju} " - "{N:/time%s used RTT variance from hostcache}\n"); - p(tcps_usedssthresh, "\t\t{:connections-hostcache-ssthresh/%ju} " - "{N:/time%s used slow-start threshold from hostcache}\n"); p2(tcps_closed, tcps_drops, "\t{:connections-closed/%ju} " "{N:/connection%s closed (including} " "{:connection-drops/%ju} {N:/drop%s})\n"); - p(tcps_cachedrtt, "\t\t{:connections-updated-rtt-on-close/%ju} " - "{N:/connection%s updated cached RTT on close}\n"); - p(tcps_cachedrttvar, "\t\t" - "{:connections-updated-variance-on-close/%ju} " - "{N:/connection%s updated cached RTT variance on close}\n"); - p(tcps_cachedssthresh, "\t\t" - "{:connections-updated-ssthresh-on-close/%ju} " - "{N:/connection%s updated cached ssthresh on close}\n"); p(tcps_conndrops, "\t{:embryonic-connections-dropped/%ju} " "{N:/embryonic connection%s dropped}\n"); p2(tcps_rttupdated, tcps_segstimed, "\t{:segments-updated-rtt/%ju} " @@ -800,8 +788,37 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) p3(tcps_hc_added, "\t{:entries-added/%ju} " "{N:/hostcache entr%s added}\n"); - p1a(tcps_hc_bucketoverflow, "\t\t{:buffer-overflows/%ju} " - "{N:/bucket overflow}\n"); + p(tcps_hc_hits, "\t\t{:cache-hits/%ju} " + "{N:/cache lookup hit%s}\n"); + p1b(tcps_hc_misses, "\t\t{:cache-misses/%ju} " + "{N:/cache lookup miss%s}\n"); + p(tcps_hc_bucketoverflow, "\t\t{:bucket-overflows/%ju} " + "{N:/bucket overflow%s}\n"); + p(tcps_hc_allocfail, "\t\t{:allocation-failures/%ju} " + "{N:/allocation failure%s}\n"); + p(tcps_cachedrtt, "\t\t{:connections-updated-rtt-on-close/%ju} " + "{N:/connection%s updated cached RTT on close}\n"); + p(tcps_usedrtt, "\t\t{:connections-hostcache-rtt/%ju} " + "{N:/time%s used RTT from hostcache}\n"); + p(tcps_cachedrttvar, "\t\t" + "{:connections-updated-variance-on-close/%ju} " + "{N:/connection%s updated cached RTT variance on close}\n"); + p(tcps_usedrttvar, "\t\t{:connections-hostcache-rttvar/%ju} " + "{N:/time%s used RTT variance from hostcache}\n"); + p(tcps_cachedssthresh, "\t\t" + "{:connections-updated-ssthresh-on-close/%ju} " + "{N:/connection%s updated cached ssthresh on close}\n"); + p(tcps_usedssthresh, "\t\t{:connections-hostcache-ssthresh/%ju} " + "{N:/time%s used slow-start threshold from hostcache}\n"); + p(tcps_cachedcwnd, "\t\t" + "{:connections-updated-cwnd-on-close/%ju} " + "{N:/connection%s updated cached congestion windows on close}\n"); + p(tcps_cachedsendpipe, "\t\t" + "{:connections-updated-send-space-on-close/%ju} " + "{N:/connection%s updated cached send buffer space on close}\n"); + p(tcps_cachedrecvpipe, "\t\t" + "{:connections-updated-recv-space-on-close/%ju} " + "{N:/connection%s updated cached recv buffer space on close}\n"); xo_close_container("hostcache");