Date: Sat, 18 Apr 2026 19:09:57 +0000 From: Andrew Gallatin <gallatin@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 29336f1c9d25 - main - tcp: Allocate t_tcpreq_info on demand Message-ID: <69e3d705.47a27.44829a14@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=29336f1c9d25c32896620a00a6218c332b37c4b7 commit 29336f1c9d25c32896620a00a6218c332b37c4b7 Author: Andrew Gallatin <gallatin@FreeBSD.org> AuthorDate: 2026-04-17 20:01:36 +0000 Commit: Andrew Gallatin <gallatin@FreeBSD.org> CommitDate: 2026-04-18 19:04:05 +0000 tcp: Allocate t_tcpreq_info on demand When TCP_REQUEST_TRK is enabled, the tcb grows by 600 bytes to accommodate the t_tcpreq_info[MAX_TCP_TRK_REQ] array. Even when the option is enabled, not every connection is using this feature. So let's allocate it on-demand, and save 600 bytes in the common case. Sponsored by: Netflix Reviewed by: rrs, tuexen Differential Revision: https://reviews.freebsd.org/D56484 --- sys/netinet/tcp_subr.c | 17 +++++++++++++++++ sys/netinet/tcp_var.h | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 4adc8d859f3e..9844ba176237 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1133,6 +1133,9 @@ tcp_default_fb_fini(struct tcpcb *tp, int tcb_is_purged) MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); MALLOC_DEFINE(M_TCPFUNCTIONS, "tcpfunc", "TCP function set memory"); +#ifdef TCP_REQUEST_TRK +MALLOC_DEFINE(M_TCPREQTRK, "tcpreqtrk", "TCP request tracking"); +#endif static struct mtx isn_mtx; @@ -2445,6 +2448,12 @@ tcp_discardcb(struct tcpcb *tp) #ifdef STATS stats_blob_destroy(tp->t_stats); #endif +#ifdef TCP_REQUEST_TRK + if (tp->t_tcpreq_info != NULL) { + free(tp->t_tcpreq_info, M_TCPREQTRK); + tp->t_tcpreq_info = NULL; + } +#endif CC_ALGO(tp) = NULL; if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { @@ -4890,6 +4899,14 @@ tcp_req_alloc_req_full(struct tcpcb *tp, struct tcp_snd_req *req, uint64_t ts, i struct tcp_sendfile_track *fil; int i, allocated; + /* Allocate the request tracking array on demand */ + if (tp->t_tcpreq_info == NULL) { + tp->t_tcpreq_info = malloc( + sizeof(*tp->t_tcpreq_info) * MAX_TCP_TRK_REQ, + M_TCPREQTRK, M_NOWAIT | M_ZERO); + if (tp->t_tcpreq_info == NULL) + return (NULL); + } /* In case the stack does not check for completions do so now */ tcp_req_check_for_comp(tp, tp->snd_una); /* Check for stale entries */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 987bb98c19af..a1b0519ceac3 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -493,7 +493,7 @@ struct tcpcb { uint32_t tcp_hybrid_start; /* Num of times we started hybrid pacing */ uint32_t tcp_hybrid_stop; /* Num of times we stopped hybrid pacing */ uint32_t tcp_hybrid_error; /* Num of times we failed to start hybrid pacing */ - struct tcp_sendfile_track t_tcpreq_info[MAX_TCP_TRK_REQ]; + struct tcp_sendfile_track *t_tcpreq_info; #endif #ifdef TCP_ACCOUNTING uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS];home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e3d705.47a27.44829a14>
