From nobody Fri Jan 9 14:16:19 2026 X-Original-To: dev-commits-src-all@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 4dnkN41Fkyz62YlQ for ; Fri, 09 Jan 2026 14:16:20 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dnkN3686yz3YYx for ; Fri, 09 Jan 2026 14:16:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767968179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hwkgqna13aRIyVut2UHj3ftutZvX040sbzjYUsC5qdU=; b=mEdbjfCvqQ+vZC4lBSrPEkHNhCQtWJaxujYjt1ExU2cewlH09ImD8BAgTt+WbyCWWQ7mOv CtKz9beZe/JO1SYxh+i1xCQcna5kzbEJfRYdRwj/xOpDg1r19hOBk3btjCJDmWF/Wfj1qh trH2/l7mnE4sBit81VbP2bUbQJ/RadAGyC0WjlmcEUx38cvfxrI77sMr6Dtfj7L/rVjVMr GXzCFhelVfM2n2QA30nFBrurZgNw4vtTywwLKEzkCqVsNJn8l0P4igQ+79rd5d+dqkMtWl Fhe+vEQkqqZmY0HfR3hTNuaS/WCzs9Eewvos5UAuyDKTD5ouV9THkYTa2sorjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767968179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hwkgqna13aRIyVut2UHj3ftutZvX040sbzjYUsC5qdU=; b=OHDJJQHEn2pQqbdszvnsFJ3dRwhITVTH1Sc1M3LDwhUp8+NiByap+CvvN8TRECjdyph0lg iuCHK7JKVNx+42jAS1zDk6j4ephPNrUjIDM3y49bWryqdWx14/syMPZDIX8bwbyb10oDtx ROeWKCkSRpgLK3k+laf6JiG7pJoUrqaTKDD0FNhdWNeH9CooiQr9R0q5kk9apRv6YztiZ6 uJMK48x8BFew/wKefsPea/7xcUzcVVuNtljx0H2v5HVd9AVa56m8iUNw9GWftBNIEsR5ZK JuXNJn8TBPAYruQJDYGjJtaU/2mezH4jjNwQTX88NWUjC2C7Kyc6dzZ/aNMjrw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767968179; a=rsa-sha256; cv=none; b=CNvGxeMVSYaqC2E00pn7QJvDL1IphG0S9/df3TXPBL93HMQY69iKiOYF3S/mETxNAmvSCH ALD7Ou7256yfnVWryOQODLGaBZmSIhgnfBNID2r6qKn7lKjj82oPXSrmbpB4FQHWvWZWk9 Ic0zksneqQcMKluc4ferAIIP9x6ObcLvEr4J6CINni5DiCaAaoXQhXSN2J/sr3nc2ghcTu bew7E4tjlx5h3XI+5A8n2eSNOlPV8m3XYgP70DGmtib+wveuFY67VzNqpuX9DEUimrOyku MX9v6uIASrAlCMX2QfmzrTM6SVNXuW1Lvk/8NUtWTl10YsNFg8O2/Ab2BU7jXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dnkN35T10z1QpL for ; Fri, 09 Jan 2026 14:16:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id d405 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 09 Jan 2026 14:16:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 1b425afa8d5f - main - cache: avoid hardcoded CACHE_PATH_CUTOFF List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b425afa8d5fb611b17f951e5099c177fd97ffea Auto-Submitted: auto-generated Date: Fri, 09 Jan 2026 14:16:19 +0000 Message-Id: <69610db3.d405.630e1315@gitrepo.freebsd.org> The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=1b425afa8d5fb611b17f951e5099c177fd97ffea commit 1b425afa8d5fb611b17f951e5099c177fd97ffea Author: Brooks Davis AuthorDate: 2026-01-09 14:15:43 +0000 Commit: Brooks Davis CommitDate: 2026-01-09 14:15:43 +0000 cache: avoid hardcoded CACHE_PATH_CUTOFF Compute the cutoff at compile time instead which will avoid the need for a CHERI case. Correct the comment about CACHE_PATH_CUTOFF. It dates to 5.2.0 not 4.4 BSD. Historic values are: 32 - introduced (c2935410f6d5f) 35 - NUL terminated and bumped (5d5c174869104) 39 - sized to alignment (bb48255cf5eff) 45 - bumped to improve efficency on 64-bit (3862838921eb8) No functional change. Reviewed by: markj Suggested by: jhb Effort: CHERI upstreaming Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D54554 --- sys/kern/vfs_cache.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 404234861710..3f8591bd0ba7 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -406,31 +406,35 @@ TAILQ_HEAD(cache_freebatch, namecache); #define CACHE_ZONE_ALIGN_MASK UMA_ALIGNOF(struct namecache_ts) /* - * TODO: the initial value of CACHE_PATH_CUTOFF was inherited from the - * 4.4 BSD codebase. Later on struct namecache was tweaked to become - * smaller and the value was bumped to retain the total size, but it - * was never re-evaluated for suitability. A simple test counting - * lengths during package building shows that the value of 45 covers - * about 86% of all added entries, reaching 99% at 65. + * TODO: CACHE_PATH_CUTOFF was initially introduced with an arbitrary + * value of 32 in FreeBSD 5.2.0. It was bumped to 35 and the path was + * NUL terminated with the introduction of DTrace probes. Later, it was + * expanded to match the alignment allowing an increase to 39, but it + * was not re-evaluated for suitability. It was again bumped to 45 on + * 64-bit systems and 41 on 32-bit systems (the current values, now + * computed at compile time rather than hardcoded). A simple test + * counting lengths during package building in 2020 showed that the + * value of 45 covers about 86% of all added entries, reaching 99% + * at 65. * * Regardless of the above, use of dedicated zones instead of malloc may be * inducing additional waste. This may be hard to address as said zones are * tied to VFS SMR. Even if retaining them, the current split should be * re-evaluated. */ -#ifdef __LP64__ -#define CACHE_PATH_CUTOFF 45 -#else -#define CACHE_PATH_CUTOFF 41 -#endif +#define CACHE_PATH_CUTOFF_MIN 40 +#define CACHE_STRUCT_LEN(pathlen) \ + (offsetof(struct namecache, nc_name) + (pathlen) + 1) +#define CACHE_PATH_CUTOFF \ + (roundup2(CACHE_STRUCT_LEN(CACHE_PATH_CUTOFF_MIN), \ + _Alignof(struct namecache_ts)) - CACHE_STRUCT_LEN(0)) #define CACHE_ZONE_SMALL_SIZE \ - (offsetof(struct namecache, nc_name) + CACHE_PATH_CUTOFF + 1) + CACHE_STRUCT_LEN(CACHE_PATH_CUTOFF) #define CACHE_ZONE_SMALL_TS_SIZE \ (offsetof(struct namecache_ts, nc_nc) + CACHE_ZONE_SMALL_SIZE) #define CACHE_ZONE_LARGE_SIZE \ - roundup2(offsetof(struct namecache, nc_name) + NAME_MAX + 1, \ - _Alignof(struct namecache_ts)) + roundup2(CACHE_STRUCT_LEN(NAME_MAX), _Alignof(struct namecache_ts)) #define CACHE_ZONE_LARGE_TS_SIZE \ (offsetof(struct namecache_ts, nc_nc) + CACHE_ZONE_LARGE_SIZE)