From owner-svn-src-all@freebsd.org Thu Aug 20 10:06:53 2020 Return-Path: Delivered-To: svn-src-all@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 9E00A3B9390; Thu, 20 Aug 2020 10:06:53 +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 4BXL0X24JZz4DcR; Thu, 20 Aug 2020 10:06:52 +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 5AB5B12671; Thu, 20 Aug 2020 10:06:51 +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 07KA6oht042333; Thu, 20 Aug 2020 10:06:50 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07KA6o7s042332; Thu, 20 Aug 2020 10:06:50 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202008201006.07KA6o7s042332@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 20 Aug 2020 10:06:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364420 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 364420 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Aug 2020 10:06:54 -0000 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); + } } /*