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
This commit is contained in:
Richard Scheffenegger 2021-03-31 19:24:01 +02:00
parent c804c8f2c5
commit 869880463c

View file

@ -649,12 +649,13 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
return(error); return(error);
} }
/* Use a buffer for 16 lines */ /* Use a buffer sized for one full bucket */
sbuf_new_for_sysctl(&sb, NULL, 16 * linesize, req); sbuf_new_for_sysctl(&sb, NULL, V_tcp_hostcache.bucket_limit * linesize, req);
sbuf_printf(&sb, sbuf_printf(&sb,
"\nIP address MTU SSTRESH RTT RTTVAR " "\nIP address MTU SSTRESH RTT RTTVAR "
" CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); " CWND SENDPIPE RECVPIPE HITS UPD EXP\n");
sbuf_drain(&sb);
#define msec(u) (((u) + 500) / 1000) #define msec(u) (((u) + 500) / 1000)
for (i = 0; i < V_tcp_hostcache.hashsize; i++) { for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
@ -685,6 +686,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
hc_entry->rmx_expire); hc_entry->rmx_expire);
} }
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
sbuf_drain(&sb);
} }
#undef msec #undef msec
error = sbuf_finish(&sb); error = sbuf_finish(&sb);