socket/tcp: Implement asynchronized pru_attach for TCP
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 15 Oct 2015 13:00:11 +0000 (21:00 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 20 Oct 2015 07:19:52 +0000 (15:19 +0800)
commitc892825ffb53edaa4e5d7270b9254de80099dc53
tree5fd78a82de652278c891a7b2913e4c4a1af7505c
parentabe62df915d69cd0fcf66763f907fa6972b98f3e
socket/tcp: Implement asynchronized pru_attach for TCP

This commit mainly splits TCP pru_attach into two parts:
- First part operates on socket buffer, so it could run directly in
  the caller thread.
- The second part creates and initializes tcpcb, which still runs in
  netisr.  But we don't wait for the result of this operation
  (lwkt_sendmsg() is used instead of lwkt_domsg()).

This removes the last lwkt_domsg on commonly/mostly used socket APIs.
This is enabled by default and could be disabled by setting sysctl
kern.ipc.socreate_fast to 0.

The measured effect of this change on 2-ways E5-2600v2 with Intel 82599
(10Gbe) using tools/kq_connect_client:
- Connect rate increases by ~10Kconns/s; we are now doing 395Kconns/s.
- Idle time on the CPUs not running netisrs increases (55% -> 65%).
- IPIs rate to the CPUs not running netisrs reduces (40Kipis/s ->
  23Kipis/s).
sys/kern/uipc_msg.c
sys/kern/uipc_socket.c
sys/netinet/tcp_usrreq.c
sys/sys/protosw.h
sys/sys/socketops.h