freebsd-nq/sys/netinet
Robert Watson 252ca42863 Move from solely write-locking the global tcbinfo in tcp_input()
to read-locking in the TCP input path, allowing greater TCP
input parallelism where multiple ithreads or ithread and netisr
are able to run in parallel.  Previously, most TCP input paths
held a write lock on the global tcbinfo lock, effectively
serializing TCP input.

Before looking up the connection, acquire a write lock if a
potentially state-changing flag is set on the TCP segment header
(FIN, RST, SYN), and otherwise a read lock.  We may later have
to upgrade to a write lock in certain cases (ACKs received by the
syncache or during TIMEWAIT) in order to support global state
transitions, but this is never required for steady-state packets.

Upgrading from a write lock to a read lock must be done as a
trylock operation to avoid deadlocks, and actually violates the
lock order as the tcbinfo lock preceeds the inpcb lock held at
the time of upgrade.  If the trylock fails, we bump the refcount
on the inpcb, drop both locks, and re-acquire in-order.  If
another thread has freed the connection while the locks are
dropped, we free the inpcb and repeat the lookup (this should
hardly ever or never happen in practice).

For now, maintain a number of new counters measuring how many
times various cases execute, and in particular whether various
optimistic assumptions about when read locks can be used, whether
upgrades are done using the fast path, and whether connections
close in practice in the above-described race, actually occur.

MFC after:	6 weeks
Discussed with:	kmacy
Reviewed by:	bz, gnn, kmacy
Tested by:	kmacy
2008-12-08 20:27:00 +00:00
..
libalias
accf_data.c
accf_dns.c
accf_http.c
icmp6.h
icmp_var.h
if_atm.c
if_atm.h
if_ether.c in_rtalloc1(9) returns a locked route, so make sure that we use 2008-12-06 19:09:38 +00:00
if_ether.h
igmp_var.h
igmp.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
igmp.h
in_cksum.c
in_gif.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
in_gif.h
in_mcast.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
in_pcb.c Add a reference count to struct inpcb, which may be explicitly 2008-12-08 20:18:50 +00:00
in_pcb.h Add a reference count to struct inpcb, which may be explicitly 2008-12-08 20:18:50 +00:00
in_proto.c Change the initialization methodology for global variables scheduled 2008-11-19 09:39:34 +00:00
in_rmx.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
in_systm.h
in_var.h Change the initialization methodology for global variables scheduled 2008-11-19 09:39:34 +00:00
in.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
in.h Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip6.h Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_carp.c In a case of CARP status change run through the if_link_state_change() 2008-12-05 14:37:14 +00:00
ip_carp.h
ip_divert.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_divert.h
ip_dummynet.c
ip_dummynet.h Type of q_time (start of queue idle time) has changed: uint32_t -> uint64_t. 2008-10-28 14:14:57 +00:00
ip_ecn.c
ip_ecn.h
ip_encap.c
ip_encap.h
ip_fastfwd.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_fw2.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_fw_nat.c
ip_fw_pfil.c Merge more of currently non-functional (i.e. resolving to 2008-11-26 22:32:07 +00:00
ip_fw.h
ip_gre.c
ip_gre.h
ip_icmp.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_icmp.h Change the initialization methodology for global variables scheduled 2008-11-19 09:39:34 +00:00
ip_id.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_input.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_ipsec.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_ipsec.h
ip_mroute.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_mroute.h
ip_options.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_options.h
ip_output.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
ip_var.h Unhide declarations of network stack virtualization structs from 2008-11-28 23:30:51 +00:00
ip.h
ipprotosw.h
pim_var.h
pim.h
raw_ip.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
sctp_asconf.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_asconf.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_auth.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_auth.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_bsd_addr.c
sctp_bsd_addr.h
sctp_cc_functions.c
sctp_cc_functions.h
sctp_constants.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_crc32.c
sctp_crc32.h
sctp_header.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_indata.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_indata.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_input.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_input.h
sctp_lock_bsd.h
sctp_os_bsd.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_os.h
sctp_output.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_output.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_pcb.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_pcb.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_peeloff.c
sctp_peeloff.h
sctp_structs.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_sysctl.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_sysctl.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_timer.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_timer.h Invariants changes that make more sense. 2008-10-27 13:53:31 +00:00
sctp_uio.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_usrreq.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp_var.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctp.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctputil.c Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
sctputil.h Code from the hack-session known as the IETF (and a 2008-12-06 13:19:54 +00:00
tcp_debug.c
tcp_debug.h
tcp_fsm.h
tcp_hostcache.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_hostcache.h Add an essential .h file that skipped from the last commit (r185419). 2008-11-28 23:39:25 +00:00
tcp_input.c Move from solely write-locking the global tcbinfo in tcp_input() 2008-12-08 20:27:00 +00:00
tcp_lro.c
tcp_lro.h
tcp_offload.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_offload.h
tcp_output.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_reass.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_sack.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_seq.h
tcp_subr.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_syncache.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_syncache.h
tcp_timer.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_timer.h
tcp_timewait.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_usrreq.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
tcp_var.h Change the initialization methodology for global variables scheduled 2008-11-19 09:39:34 +00:00
tcp.h
tcpip.h
toedev.h
udp_usrreq.c Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00
udp_var.h
udp.h
vinet.h Rather than using hidden includes (with cicular dependencies), 2008-12-02 21:37:28 +00:00