Index | Thread | Search

From:
Vitaliy Makkoveev <otto@bsdbox.dev>
Subject:
Re: parallel TCP output
To:
Alexander Bluhm <bluhm@openbsd.org>
Cc:
tech@openbsd.org
Date:
Thu, 26 Dec 2024 06:34:09 +0300

Download raw body.

Thread
  • Alexander Bluhm:

    parallel TCP output

    • Vitaliy Makkoveev:

      parallel TCP output

> On 25 Dec 2024, at 18:56, Alexander Bluhm <bluhm@openbsd.org> wrote:
> 
> Hi,
> 
> I think tcp_output() is MP safe when called with shared netlock
> together with socket lock.  This is the lock for tcpcb.  So let's
> mark TCP protocol with PR_MPSOCKET.  Also t_oobflags is protected
> this way.
> 
> ok?
> 

Go ahead, ok mvs.

> bluhm
> 
> Index: kern/uipc_socket.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v
> diff -u -p -r1.347 uipc_socket.c
> --- kern/uipc_socket.c	19 Dec 2024 22:11:35 -0000	1.347
> +++ kern/uipc_socket.c	25 Dec 2024 15:41:36 -0000
> @@ -927,9 +927,9 @@ soreceive(struct socket *so, struct mbuf
> 		flags = 0;
> 	if (flags & MSG_OOB) {
> 		m = m_get(M_WAIT, MT_DATA);
> -		solock(so);
> +		solock_shared(so);
> 		error = pru_rcvoob(so, m, flags & MSG_PEEK);
> -		sounlock(so);
> +		sounlock_shared(so);
> 		if (error)
> 			goto bad;
> 		do {
> Index: netinet/in_proto.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_proto.c,v
> diff -u -p -r1.117 in_proto.c
> --- netinet/in_proto.c	19 Dec 2024 22:10:35 -0000	1.117
> +++ netinet/in_proto.c	25 Dec 2024 15:39:23 -0000
> @@ -198,7 +198,7 @@ const struct protosw inetsw[] = {
>   .pr_type	= SOCK_STREAM,
>   .pr_domain	= &inetdomain,
>   .pr_protocol	= IPPROTO_TCP,
> -  .pr_flags	= PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE,
> +  .pr_flags	= PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE|PR_MPSOCKET,
>   .pr_input	= tcp_input,
>   .pr_ctlinput	= tcp_ctlinput,
>   .pr_ctloutput	= tcp_ctloutput,
> Index: netinet6/in6_proto.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_proto.c,v
> diff -u -p -r1.121 in6_proto.c
> --- netinet6/in6_proto.c	19 Dec 2024 22:10:35 -0000	1.121
> +++ netinet6/in6_proto.c	25 Dec 2024 15:39:23 -0000
> @@ -148,7 +148,7 @@ const struct protosw inet6sw[] = {
>   .pr_type	= SOCK_STREAM,
>   .pr_domain	= &inet6domain,
>   .pr_protocol	= IPPROTO_TCP,
> -  .pr_flags	= PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE,
> +  .pr_flags	= PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE|PR_MPSOCKET,
>   .pr_input	= tcp_input,
>   .pr_ctlinput	= tcp6_ctlinput,
>   .pr_ctloutput	= tcp_ctloutput,
>