From owner-svn-src-stable@freebsd.org Fri Aug 7 23:31:46 2020 Return-Path: Delivered-To: svn-src-stable@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 A2353376FC5; Fri, 7 Aug 2020 23:31:46 +0000 (UTC) (envelope-from mjg@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BNhTG3hpdz43m7; Fri, 7 Aug 2020 23:31:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6246C1FA04; Fri, 7 Aug 2020 23:31:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 077NVkgS002197; Fri, 7 Aug 2020 23:31:46 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 077NVknQ002196; Fri, 7 Aug 2020 23:31:46 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202008072331.077NVknQ002196@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 7 Aug 2020 23:31:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r364047 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 364047 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2020 23:31:46 -0000 Author: mjg Date: Fri Aug 7 23:31:45 2020 New Revision: 364047 URL: https://svnweb.freebsd.org/changeset/base/364047 Log: MFC r363855,r363890,r363891 cache: add missing numcache detrement on insertion failure cache: convert ncnegnash into a macro cache: reduce zone alignment to 8 bytes Modified: stable/12/sys/kern/vfs_cache.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/vfs_cache.c ============================================================================== --- stable/12/sys/kern/vfs_cache.c Fri Aug 7 23:08:17 2020 (r364046) +++ stable/12/sys/kern/vfs_cache.c Fri Aug 7 23:31:45 2020 (r364047) @@ -102,9 +102,9 @@ SDT_PROBE_DEFINE2(vfs, namecache, shrink_negative, don */ struct namecache { - LIST_ENTRY(namecache) nc_hash; /* hash chain */ LIST_ENTRY(namecache) nc_src; /* source vnode list */ TAILQ_ENTRY(namecache) nc_dst; /* destination vnode list */ + LIST_ENTRY(namecache) nc_hash; /* hash chain */ struct vnode *nc_dvp; /* vnode of parent of name */ union { struct vnode *nu_vp; /* vnode the name refers to */ @@ -121,6 +121,8 @@ struct namecache { * to be stored. The nc_dotdottime field is used when a cache entry is mapping * both a non-dotdot directory name plus dotdot for the directory's * parent. + * + * See below for alignment requirement. */ struct namecache_ts { struct timespec nc_time; /* timespec provided by fs */ @@ -129,6 +131,14 @@ struct namecache_ts { struct namecache nc_nc; }; +/* + * At least mips n32 performs 64-bit accesses to timespec as found + * in namecache_ts and requires them to be aligned. Since others + * may be in the same spot suffer a little bit and enforce the + * alignment for everyone. Note this is a nop for 64-bit platforms. + */ +#define CACHE_ZONE_ALIGNMENT UMA_ALIGNOF(time_t) + #define nc_vp n_un.nu_vp /* @@ -226,8 +236,8 @@ static struct neglist __read_mostly *neglists; static struct neglist ncneg_hot; static u_long numhotneg; -#define numneglists (ncneghash + 1) -static u_int __read_mostly ncneghash; +#define ncneghash 3 +#define numneglists (ncneghash + 1) static inline struct neglist * NCP2NEGLIST(struct namecache *ncp) { @@ -1853,6 +1863,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, return; out_unlock_free: cache_enter_unlock(&cel); + atomic_add_long(&numcache, -1); cache_free(ncp); return; } @@ -1878,19 +1889,19 @@ nchinit(void *dummy __unused) cache_zone_small = uma_zcreate("S VFS Cache", sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1, - NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache), + NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT); cache_zone_small_ts = uma_zcreate("STS VFS Cache", sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1, - NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache_ts), + NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT); cache_zone_large = uma_zcreate("L VFS Cache", sizeof(struct namecache) + NAME_MAX + 1, - NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache), + NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT); cache_zone_large_ts = uma_zcreate("LTS VFS Cache", sizeof(struct namecache_ts) + NAME_MAX + 1, - NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache_ts), + NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT); ncsize = desiredvnodes * ncsizefactor; @@ -1911,7 +1922,6 @@ nchinit(void *dummy __unused) mtx_init(&vnodelocks[i], "ncvn", NULL, MTX_DUPOK | MTX_RECURSE); ncpurgeminvnodes = numbucketlocks * 2; - ncneghash = 3; neglists = malloc(sizeof(*neglists) * numneglists, M_VFSCACHE, M_WAITOK | M_ZERO); for (i = 0; i < numneglists; i++) {