From owner-dev-commits-src-main@freebsd.org Sun Feb 21 21:10:33 2021 Return-Path: Delivered-To: dev-commits-src-main@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 B44A953BB55; Sun, 21 Feb 2021 21:10: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 4DkHyx4nWXz3hxD; Sun, 21 Feb 2021 21:10: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 973BB19824; Sun, 21 Feb 2021 21:10: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 11LLAXkT090339; Sun, 21 Feb 2021 21:10:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11LLAXgh090338; Sun, 21 Feb 2021 21:10:33 GMT (envelope-from git) Date: Sun, 21 Feb 2021 21:10:33 GMT Message-Id: <202102212110.11LLAXgh090338@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 2443068d4860 - main - vfs: shrink struct vnode to 448 bytes on LP64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2443068d486020ed9a4250e0d3b28168c40f741a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Feb 2021 21:10:33 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2443068d486020ed9a4250e0d3b28168c40f741a commit 2443068d486020ed9a4250e0d3b28168c40f741a Author: Mateusz Guzik AuthorDate: 2021-02-21 19:48:49 +0000 Commit: Mateusz Guzik CommitDate: 2021-02-21 21:07:14 +0000 vfs: shrink struct vnode to 448 bytes on LP64 ... by moving v_hash into a 4 byte hole. Combined with several previous size reductions this makes the size small enough to fit 9 vnodes per page as opposed to 8. Add a compilation time assert so that this is not unknowingly worsened. Note the structure still remains bigger than it should be. --- sys/sys/vnode.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index d71f3bfcb817..0e46bea14b64 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -109,6 +109,7 @@ struct vnode { short v_irflag; /* i frequently read flags */ seqc_t v_seqc; /* i modification count */ uint32_t v_nchash; /* u namecache hash */ + u_int v_hash; struct vop_vector *v_op; /* u vnode operations vector */ void *v_data; /* u private data for fs */ @@ -172,9 +173,19 @@ struct vnode { int v_writecount; /* I ref count of writers or (negative) text users */ int v_seqc_users; /* i modifications pending */ - u_int v_hash; }; +#ifndef DEBUG_LOCKS +#ifdef _LP64 +/* + * Not crossing 448 bytes fits 9 vnodes per page. If you have to add fields + * to the structure and there is nothing which can be done to prevent growth + * then so be it. But don't grow it without a good reason. + */ +_Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); +#endif +#endif + #endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ #define bo2vnode(bo) __containerof((bo), struct vnode, v_bufobj)