Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Aug 2020 10:06:50 +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: r364420 - head/sys/kern
Message-ID:  <202008201006.07KA6o7s042332@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Aug 20 10:06:50 2020
New Revision: 364420
URL: https://svnweb.freebsd.org/changeset/base/364420

Log:
  cache: don't use cache_purge_negative when renaming
  
  It avoidably scans (and evicts) unrelated entries. Instead take
  advantage of passed componentname and perform a hash lookup
  for the exact one.
  
  Sample data from buildworld probed on cache_purge_negative extended
  to count both scanned and evicted entries on each call are below.
  At most it has to evict 1.
  
    evicted
             value  ------------- Distribution ------------- count
                -1 |                                         0
                 0 |@@@@@@@@@@@@@@@                          19506
                 1 |@@@@@                                    5820
                 2 |@@@@@@                                   7751
                 4 |@@@@@                                    6506
                 8 |@@@@@                                    5996
                16 |@@@                                      4029
                32 |@                                        1489
                64 |                                         193
               128 |                                         109
               256 |                                         56
               512 |                                         16
              1024 |                                         7
              2048 |                                         3
              4096 |                                         1
              8192 |                                         1
             16384 |                                         0
  
    scanned
             value  ------------- Distribution ------------- count
                -1 |                                         0
                 0 |@@                                       2456
                 1 |@                                        1496
                 2 |@@                                       2728
                 4 |@@@                                      4171
                 8 |@@@@                                     5122
                16 |@@@@                                     5335
                32 |@@@@@                                    6279
                64 |@@@@                                     5671
               128 |@@@@                                     4558
               256 |@@                                       3123
               512 |@@                                       2790
              1024 |@@                                       2449
              2048 |@@                                       3021
              4096 |@                                        1398
              8192 |@                                        886
             16384 |                                         0

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Thu Aug 20 10:05:46 2020	(r364419)
+++ head/sys/kern/vfs_cache.c	Thu Aug 20 10:06:50 2020	(r364420)
@@ -2351,9 +2351,13 @@ cache_rename(struct vnode *fdvp, struct vnode *fvp, st
 		ASSERT_VOP_IN_SEQC(tvp);
 
 	cache_purge(fvp);
-	if (tvp != NULL)
+	if (tvp != NULL) {
 		cache_purge(tvp);
-	cache_purge_negative(tdvp);
+		KASSERT(!cache_remove_cnp(tdvp, tcnp),
+		    ("%s: lingering negative entry", __func__));
+	} else {
+		cache_remove_cnp(tdvp, tcnp);
+	}
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008201006.07KA6o7s042332>