Date: Tue, 10 Sep 2019 20:11:00 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352178 - head/sys/kern Message-ID: <201909102011.x8AKB0e2048287@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Tue Sep 10 20:11:00 2019 New Revision: 352178 URL: https://svnweb.freebsd.org/changeset/base/352178 Log: cache: change the formula for calculating lock array sizes It used to be mp_ncpus * 64, but this gives unnecessarily big values for small machines and at the same time constraints bigger ones. In particular this helps on a 104-way box for which the count is now doubled. While here make cache_purgevfs less likely. Currently it is not efficient in face of contention due to lock ordering issues. These are fixable but not worth it at the moment. Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Tue Sep 10 20:08:24 2019 (r352177) +++ head/sys/kern/vfs_cache.c Tue Sep 10 20:11:00 2019 (r352178) @@ -1879,19 +1879,21 @@ nchinit(void *dummy __unused) UMA_ZONE_ZINIT); nchashtbl = hashinit(desiredvnodes * 2, M_VFSCACHE, &nchash); - ncbuckethash = cache_roundup_2(mp_ncpus * 64) - 1; + ncbuckethash = cache_roundup_2(mp_ncpus * mp_ncpus) - 1; + if (ncbuckethash < 7) /* arbitrarily chosen to avoid having one lock */ + ncbuckethash = 7; if (ncbuckethash > nchash) ncbuckethash = nchash; bucketlocks = malloc(sizeof(*bucketlocks) * numbucketlocks, M_VFSCACHE, M_WAITOK | M_ZERO); for (i = 0; i < numbucketlocks; i++) rw_init_flags(&bucketlocks[i], "ncbuc", RW_DUPOK | RW_RECURSE); - ncvnodehash = cache_roundup_2(mp_ncpus * 64) - 1; + ncvnodehash = ncbuckethash; vnodelocks = malloc(sizeof(*vnodelocks) * numvnodelocks, M_VFSCACHE, M_WAITOK | M_ZERO); for (i = 0; i < numvnodelocks; i++) mtx_init(&vnodelocks[i], "ncvn", NULL, MTX_DUPOK | MTX_RECURSE); - ncpurgeminvnodes = numbucketlocks; + ncpurgeminvnodes = numbucketlocks * 2; ncneghash = 3; neglists = malloc(sizeof(*neglists) * numneglists, M_VFSCACHE,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909102011.x8AKB0e2048287>