From owner-dev-commits-src-all@freebsd.org Tue Sep 7 21:12:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95F6966C36F; Tue, 7 Sep 2021 21:12:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H3yds3mwkz4VNN; Tue, 7 Sep 2021 21:12:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 625D9199A4; Tue, 7 Sep 2021 21:12:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 187LCX2V023354; Tue, 7 Sep 2021 21:12:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 187LCXk3023353; Tue, 7 Sep 2021 21:12:33 GMT (envelope-from git) Date: Tue, 7 Sep 2021 21:12:33 GMT Message-Id: <202109072112.187LCXk3023353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 97cf43ebc5c9 - main - socket: Reorder socket and sockbuf fields to eliminate some padding MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 97cf43ebc5c9cd4b43190ba2b1ff3d0e0f9372cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2021 21:12:33 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=97cf43ebc5c9cd4b43190ba2b1ff3d0e0f9372cc commit 97cf43ebc5c9cd4b43190ba2b1ff3d0e0f9372cc Author: Mark Johnston AuthorDate: 2021-09-07 18:45:22 +0000 Commit: Mark Johnston CommitDate: 2021-09-07 18:59:24 +0000 socket: Reorder socket and sockbuf fields to eliminate some padding This is in preparation for moving sockbuf locks into the owning socket, in order to provide proper interlocking for listen(2). In particular, listening sockets do not use the socket buffers and repurpose that space in struct socket for their own purposes. Moving the locks out of the socket buffers and into the socket proper makes it possible to safely lock socket buffers and test for a listening socket before deciding how to proceed. Reordering these fields saves some space and helps ensure that UMA will provide the same space efficiency for sockets as before. No functional change intended. Reviewed by: tuexen, gallatin Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31656 --- sys/sys/sockbuf.h | 4 ++-- sys/sys/socketvar.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index 4c56f4eaf234..e7a4c8883054 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -85,7 +85,8 @@ struct sockbuf { struct sx sb_sx; /* prevent I/O interlacing */ struct selinfo *sb_sel; /* process selecting read/write */ short sb_state; /* (a) socket state on sockbuf */ -#define sb_startzero sb_mb +#define sb_startzero sb_flags + short sb_flags; /* (a) flags, see above */ struct mbuf *sb_mb; /* (a) the mbuf chain */ struct mbuf *sb_mbtail; /* (a) the last mbuf in the chain */ struct mbuf *sb_lastrecord; /* (a) first mbuf of last @@ -109,7 +110,6 @@ struct sockbuf { struct ktls_session *sb_tls_info; /* (a + b) TLS state */ struct mbuf *sb_mtls; /* (a) TLS mbuf chain */ struct mbuf *sb_mtlstail; /* (a) last mbuf in TLS chain */ - short sb_flags; /* (a) flags, see above */ int (*sb_upcall)(struct socket *, void *, int); /* (a) */ void *sb_upcallarg; /* (a) */ TAILQ_HEAD(, kaiocb) sb_aiojobq; /* (a) pending AIO ops */ diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 47033fdabbfa..506a328b1e0a 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -91,13 +91,13 @@ struct socket { volatile u_int so_count; /* (b / refcount) */ struct selinfo so_rdsel; /* (b/cr) for so_rcv/so_comp */ struct selinfo so_wrsel; /* (b/cs) for so_snd */ - short so_type; /* (a) generic type, see socket.h */ int so_options; /* (b) from socket call, see socket.h */ - short so_linger; /* time to linger close(2) */ + short so_type; /* (a) generic type, see socket.h */ short so_state; /* (b) internal state flags SS_* */ void *so_pcb; /* protocol control block */ struct vnet *so_vnet; /* (a) network stack instance */ struct protosw *so_proto; /* (a) protocol handle */ + short so_linger; /* time to linger close(2) */ short so_timeo; /* (g) connection timeout */ u_short so_error; /* (f) error affecting connection */ u_short so_rerror; /* (f) error affecting connection */