aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Scheffenegger <rscheff@FreeBSD.org>2021-03-31 17:24:01 +0000
committerRichard Scheffenegger <rscheff@FreeBSD.org>2021-04-16 21:33:20 +0000
commita85003abdad402c27c12cf1a31b243c39483f263 (patch)
treec45e9b8c36fd9aa5f455292b62343b80237f7059
parentc449b8a71bce7d7838164f6a5595f71c91b5b91b (diff)
downloadsrc-a85003abdad402c27c12cf1a31b243c39483f263.tar.gz
src-a85003abdad402c27c12cf1a31b243c39483f263.zip
tcp: drain tcp_hostcache_list in between per-bucket locks
Explicitly drain the sbuf after completing each hash bucket to minimize the work performed while holding the hash bucket lock. PR: 254333 MFC after: 2 weeks Reviewed By: tuexen, jhb, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29483 (cherry picked from commit 869880463cc2ce64e2e6599eaec880a981f3ced6)
-rw-r--r--sys/netinet/tcp_hostcache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c
index e71f13243f0c..c4d51dd0bd59 100644
--- a/sys/netinet/tcp_hostcache.c
+++ b/sys/netinet/tcp_hostcache.c
@@ -642,12 +642,13 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
return(error);
}
- /* Use a buffer for 16 lines */
- sbuf_new_for_sysctl(&sb, NULL, 16 * linesize, req);
+ /* Use a buffer sized for one full bucket */
+ sbuf_new_for_sysctl(&sb, NULL, V_tcp_hostcache.bucket_limit * linesize, req);
sbuf_printf(&sb,
"\nIP address MTU SSTRESH RTT RTTVAR "
" CWND SENDPIPE RECVPIPE HITS UPD EXP\n");
+ sbuf_drain(&sb);
#define msec(u) (((u) + 500) / 1000)
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
@@ -678,6 +679,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
hc_entry->rmx_expire);
}
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
+ sbuf_drain(&sb);
}
#undef msec
error = sbuf_finish(&sb);