From nobody Mon Oct 6 22:30:45 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cgYrm6TD8z6BhpJ for ; Mon, 06 Oct 2025 22:31:04 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cgYrm4Ld4z3gJy for ; Mon, 06 Oct 2025 22:31:04 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b4c89df6145so386576366b.3 for ; Mon, 06 Oct 2025 15:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759789857; x=1760394657; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bw9BN23UVr6tCmqNvU4R/2nA26f7qMIEeLkO4bu361Y=; b=XGr7GuUVGLdx6jJQyX7tEkBQOVs9Yq5lmux2jHSIFungnFgzfpqFc0GqFJZwVAtboy d0On0GzIS97Hoj3BgreIhHHMgI6gciCKB9brK5wiCWUIx4H5G+2JclNmFN6EdPLcjYcP yoGSHsJjX43yvJh/8XBN4R1x80fSWBIFElijR2YIvV8JXgLFkBV8kCWTFgYezl2XQTMU nl/2o0GXHsdj/KZ0Q+PwOwBgEfnq6W65p+9C+nHdaNdV2xY8WwuQTiIHcQFux69MXimP sAxolokXCYornWE7lZSQRq9MpT/NuiEF8IHJz0Zmxc42t8rr6FgN4bIJEqxhKNQ0eONX 2HeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759789857; x=1760394657; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bw9BN23UVr6tCmqNvU4R/2nA26f7qMIEeLkO4bu361Y=; b=ZnXDY3SDazNtZIMfXVhXUehv6NYYDT+7ZrwAUHulcQM3opp1TuCQep0KJLh1ZHTuUy diVCVMz1fhUUbwc8LcttzywQNlWNUHU4klECbwjBHmkuXJGjp6l0YA0trjz569ED/jqd znkFbg2mLLALkMRLqP+1MtvbvcfDNoUn4BUnZBAXo3T1Rsd109VHdZniGUFwkFS0wwF6 fhS2N8fyClC95jJ3drAE2FErOI3J3eyJmaJfdH51tYDzt4Ps3FYQlnovew/A0LvQY0Tl LYjK3TdO2MlarMaFhcts2V3bX6CXLaTp31f6nGg9TqouIpQ13cL2Pn3TRnfTRWAA+dzd nkqw== X-Forwarded-Encrypted: i=1; AJvYcCUqtgV94X/tM5DZGqcby+dXlc72d6EVGuaZfqU13z72BI88TB9+8NrHhGouFrnBdKZzmPBh2SNhuK9PM2FVgznAXKSCOQ==@freebsd.org X-Gm-Message-State: AOJu0Ywd4c8pGlg846Sk90ycY73ltZ14wzJA+90wAWQ8Iw8tMAPO7rK2 jP6SPMACRbY1Mu3SWaw02YjIAR3uYBayIqYEwgt0GVNj6/MR797OOBgdx4rSGcKc+5rZmy2N9OU kAfa7wWfwFl509ahxm2BEJLBCYKR74Bk= X-Gm-Gg: ASbGncvHoDu+j/H669dkzvZw1KtW6owVIoDNtpkY79KX2BrdiP/C54Glglk90IACuEc bX/ar2rsckFU+YJAkWtvkAUs1wiaqY4ned7m52A6FIephqMXv8tnZu58N9ReEIuqKmb69LCT05d k15/7jtuM58CRBn7ddxVtxkWC7L8vZw3eudsIKSpA0/vKOUHxnptidFuBWWdVz+hHPVGtzlgGlC JY+8WvglZENJxnEe7lgZs3SnZnhg3YX645w5dXrGaomD2nHWqTaeqDY5Py9PPQ= X-Google-Smtp-Source: AGHT+IHrN4XLy6baAvL2sYsxB4kprrHaBBXpQU4gZHuaI3e1rmp8pFrKAJACzNs1oB7fmWL3Rw0WIwSAZbWETVrj1Os= X-Received: by 2002:a17:907:3e92:b0:b3e:580a:184f with SMTP id a640c23a62f3a-b49c1b6bf0bmr1685248166b.4.1759789856982; Mon, 06 Oct 2025 15:30:56 -0700 (PDT) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 References: <202510061823.596IN7oZ084715@gitrepo.freebsd.org> In-Reply-To: From: Mateusz Guzik Date: Tue, 7 Oct 2025 00:30:45 +0200 X-Gm-Features: AS18NWBIFNwJWknlADZcL4p4v0fxbKhewG1EW_Ksu6ncrqhlhNGRcGIt3w-akx4 Message-ID: Subject: Re: git: 84f981ba57e7 - main - nullfs: shrink null_node to 32 bytes To: Konstantin Belousov Cc: Mateusz Guzik , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 4cgYrm4Ld4z3gJy On Tue, Oct 7, 2025 at 12:25=E2=80=AFAM Konstantin Belousov wrote: > > On Mon, Oct 06, 2025 at 06:23:07PM +0000, Mateusz Guzik wrote: > > The branch main has been updated by mjg: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D84f981ba57e77bd3c3d0fbf1= 469ce51bfd132a6b > > > > commit 84f981ba57e77bd3c3d0fbf1469ce51bfd132a6b > > Author: Mateusz Guzik > > AuthorDate: 2025-10-06 17:59:17 +0000 > > Commit: Mateusz Guzik > > CommitDate: 2025-10-06 18:23:01 +0000 > > > > nullfs: shrink null_node to 32 bytes > > --- > > sys/fs/nullfs/null.h | 2 +- > > sys/fs/nullfs/null_subr.c | 12 +++++++----- > > 2 files changed, 8 insertions(+), 6 deletions(-) > > > > diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h > > index aa7a689bec34..ad3f7779e108 100644 > > --- a/sys/fs/nullfs/null.h > > +++ b/sys/fs/nullfs/null.h > > @@ -53,7 +53,7 @@ struct null_mount { > > * A cache of vnode references > > */ > > struct null_node { > > - CK_LIST_ENTRY(null_node) null_hash; /* Hash list */ > > + CK_SLIST_ENTRY(null_node) null_hash; /* Hash list */ > > struct vnode *null_lowervp; /* VREFed once */ > > struct vnode *null_vnode; /* Back pointer */ > > u_int null_flags; > > diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c > > index ad8cd08279cc..bb0ff9966dfd 100644 > > --- a/sys/fs/nullfs/null_subr.c > > +++ b/sys/fs/nullfs/null_subr.c > > @@ -59,7 +59,7 @@ VFS_SMR_DECLARE; > > > > #define NULL_NHASH(vp) (&null_node_hashtbl[vfs_hash_index(vp) & n= ull_hash_mask]) > > > > -static CK_LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl; > > +static CK_SLIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl= ; > > static struct rwlock null_hash_lock; > > static u_long null_hash_mask; > > > > @@ -116,7 +116,7 @@ null_hashget_locked(struct mount *mp, struct vnode = *lowervp) > > * reference count (but NOT the lower vnode's VREF counter). > > */ > > hd =3D NULL_NHASH(lowervp); > > - CK_LIST_FOREACH(a, hd, null_hash) { > > + CK_SLIST_FOREACH(a, hd, null_hash) { > > if (a->null_lowervp !=3D lowervp) > > continue; > > /* > > @@ -148,7 +148,7 @@ null_hashget(struct mount *mp, struct vnode *lowerv= p) > > > > vfs_smr_enter(); > > hd =3D NULL_NHASH(lowervp); > > - CK_LIST_FOREACH(a, hd, null_hash) { > > + CK_SLIST_FOREACH(a, hd, null_hash) { > > if (a->null_lowervp !=3D lowervp) > > continue; > > /* > > @@ -189,7 +189,7 @@ null_hashins(struct mount *mp, struct null_node *xp= ) > > } > > } > > #endif > > - CK_LIST_INSERT_HEAD(hd, xp, null_hash); > > + CK_SLIST_INSERT_HEAD(hd, xp, null_hash); > > } > > > > static void > > @@ -305,9 +305,11 @@ null_nodeget(struct mount *mp, struct vnode *lower= vp, struct vnode **vpp) > > void > > null_hashrem(struct null_node *xp) > > { > > + struct null_node_hashhead *hd; > > > > + hd =3D NULL_NHASH(xp->null_lowervp); > > rw_wlock(&null_hash_lock); > > - CK_LIST_REMOVE(xp, null_hash); > > + CK_SLIST_REMOVE(hd, xp, null_node, null_hash); > This changes O(1) removal into O(N), for N being the size of the hash > chain length for specific hash. I.e. it is on par with the lookup. > > Why it is fine? Why it was not mentioned and explained in the commit > message? > For the hash to be at all useful the chains are supposed to be short. Or to put it differently, a sensibly sized hash with a sensible hashing function makes it automatically fine. This was worthwhile to do because the original size of 40 bytes is a very poor fit for the allocator. fwiw the namecache already works this way for few years. the regular vnode hash should probably get the same treatment, saving 8 bytes off of struct vnode