]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
ktls: Accurately track if ifnet ktls is enabled
authorAndrew Gallatin <gallatin@FreeBSD.org>
Wed, 8 Feb 2023 20:37:08 +0000 (15:37 -0500)
committerAndrew Gallatin <gallatin@FreeBSD.org>
Thu, 9 Feb 2023 17:44:44 +0000 (12:44 -0500)
commitc0e4090e3d43eeb86270dd35835862660b045c26
treeba4ae9aa67d3aff9caa478220b208ece5a0c14bd
parentce6a0c776b702f063d4f200de34bfeaddcbb3cb7
ktls: Accurately track if ifnet ktls is enabled

This allows us to avoid spurious calls to ktls_disable_ifnet()

When we implemented ifnet kTLSe, we set a flag in the tx socket
buffer (SB_TLS_IFNET) to indicate ifnet kTLS.  This flag meant that
now, or in the past, ifnet ktls was active on a socket.  Later,
I added code to switch ifnet ktls sessions to software in the case
of lossy TCP connections that have a high retransmit rate.
Because TCP was using SB_TLS_IFNET to know if it needed to do math
to calculate the retransmit ratio and potentially call into
ktls_disable_ifnet(), it was doing unneeded work long after
a session was moved to software.

This patch carefully tracks whether or not ifnet ktls is still enabled
on a TCP connection.  Because the inp is now embedded in the tcpcb, and
because TCP is the most frequent accessor of this state, it made sense to
move this from the socket buffer flags to the tcpcb. Because we now need
reliable access to the tcbcb, we take a ref on the inp when creating a tx
ktls session.

While here, I noticed that rack/bbr were incorrectly implementing
tfb_hwtls_change(), and applying the change to all pending sends,
when it should apply only to future sends.

This change reduces spurious calls to  ktls_disable_ifnet() by 95% or so
in a Netflix CDN environment.

Reviewed by: markj, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D38380
sys/kern/uipc_ktls.c
sys/netinet/tcp_output.c
sys/netinet/tcp_ratelimit.c
sys/netinet/tcp_stacks/bbr.c
sys/netinet/tcp_stacks/rack.c
sys/netinet/tcp_var.h
sys/sys/ktls.h
sys/sys/sockbuf.h