]> xenbits.xensource.com Git - freebsd.git/commitdiff
cache: change the formula for calculating lock array sizes
authormjg <mjg@FreeBSD.org>
Tue, 10 Sep 2019 20:11:00 +0000 (20:11 +0000)
committermjg <mjg@FreeBSD.org>
Tue, 10 Sep 2019 20:11:00 +0000 (20:11 +0000)
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

sys/kern/vfs_cache.c

index 61d51c98f394f7557522d7939696e02cd4ae16e3..d45bc43052c5a6856f6192938e0a3bd43c7ddfa9 100644 (file)
@@ -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,