]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
tcp: embed inpcb into tcpcb
authorGleb Smirnoff <glebius@FreeBSD.org>
Wed, 7 Dec 2022 17:00:48 +0000 (09:00 -0800)
committerGleb Smirnoff <glebius@FreeBSD.org>
Wed, 7 Dec 2022 17:00:48 +0000 (09:00 -0800)
commite68b3792440cac248347afe08ba5881a00ba6523
treeb06ea64de5ac8911963b6fcabe8d0f98c6ee710e
parentf4a176fbaf76902a9b1c46e6c752e1f33eaebd8d
tcp: embed inpcb into tcpcb

For the TCP protocol inpcb storage specify allocation size that would
provide space to most of the data a TCP connection needs, embedding
into struct tcpcb several structures, that previously were allocated
separately.

The most import one is the inpcb itself.  With embedding we can provide
strong guarantee that with a valid TCP inpcb the tcpcb is always valid
and vice versa.  Also we reduce number of allocs/frees per connection.
The embedded inpcb is placed in the beginning of the struct tcpcb,
since in_pcballoc() requires that.  However, later we may want to move
it around for cache line efficiency, and this can be done with a little
effort.  The new intotcpcb() macro is ready for such move.

The congestion algorithm data, the TCP timers and osd(9) data are
also embedded into tcpcb, and temprorary struct tcpcb_mem goes away.
There was no extra allocation here, but we went through extra pointer
every time we accessed this data.

One interesting side effect is that now TCP data is allocated from
SMR-protected zone.  Potentially this allows the TCP stacks or other
TCP related modules to utilize that for their own synchronization.

Large part of the change was done with sed script:

s/tp->ccv->/tp->t_ccv./g
s/tp->ccv/\&tp->t_ccv/g
s/tp->cc_algo/tp->t_cc/g
s/tp->t_timers->tt_/tp->tt_/g
s/CCV\(ccv, osd\)/\&CCV(ccv, t_osd)/g

Dependency side effect is that code that needs to know struct tcpcb
should also know struct inpcb, that added several <netinet/in_pcb.h>.

Differential revision: https://reviews.freebsd.org/D37127
26 files changed:
cddl/lib/libdtrace/tcp.d
sys/conf/options
sys/dev/cxgbe/tom/t4_tom_l2t.c
sys/netinet/cc/cc.h
sys/netinet/cc/cc_cdg.c
sys/netinet/cc/cc_chd.c
sys/netinet/cc/cc_hd.c
sys/netinet/cc/cc_vegas.c
sys/netinet/tcp_debug.c
sys/netinet/tcp_hpts.c
sys/netinet/tcp_input.c
sys/netinet/tcp_output.c
sys/netinet/tcp_pcap.c
sys/netinet/tcp_stacks/rack.c
sys/netinet/tcp_stacks/sack_filter.c
sys/netinet/tcp_subr.c
sys/netinet/tcp_timer.c
sys/netinet/tcp_timer.h
sys/netinet/tcp_usrreq.c
sys/netinet/tcp_var.h
sys/netinet6/in6_pcb.c
sys/netipsec/ipsec_input.c
sys/netipsec/ipsec_output.c
sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c
sys/netpfil/pf/pf_syncookies.c
usr.bin/systat/netstat.c