From owner-svn-src-head@freebsd.org Fri Sep 27 19:12:44 2019 Return-Path: Delivered-To: svn-src-head@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 08FC812A7A4; Fri, 27 Sep 2019 19:12:44 +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) server-signature RSA-PSS (4096 bits) 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 46g1dl6PM9z4Bvw; Fri, 27 Sep 2019 19:12:43 +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 BEF1B1D7F2; Fri, 27 Sep 2019 19:12:43 +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 x8RJChZL046795; Fri, 27 Sep 2019 19:12:43 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8RJChaB046794; Fri, 27 Sep 2019 19:12:43 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201909271912.x8RJChaB046794@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 27 Sep 2019 19:12:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352811 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 352811 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Sep 2019 19:12:44 -0000 Author: mjg Date: Fri Sep 27 19:12:43 2019 New Revision: 352811 URL: https://svnweb.freebsd.org/changeset/base/352811 Log: cache: make negative list shrinking a little bit concurrent Continue protecting demotion from the hotlist and selection of the target list with the ncneg_shrink_lock lock, but drop it before relocking to zap the node. While here count how many times we skipped shrinking due to the lock being already taken. 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 Fri Sep 27 19:12:20 2019 (r352810) +++ head/sys/kern/vfs_cache.c Fri Sep 27 19:12:43 2019 (r352811) @@ -380,8 +380,6 @@ STATNODE_COUNTER(numfullpathfail2, "Number of fullpath search errors (VOP_VPTOCNP failures)"); STATNODE_COUNTER(numfullpathfail4, "Number of fullpath search errors (ENOMEM)"); STATNODE_COUNTER(numfullpathfound, "Number of successful fullpath calls"); -static long numneg_evicted; STATNODE_ULONG(numneg_evicted, - "Number of negative entries evicted when adding a new entry"); STATNODE_COUNTER(zap_and_exit_bucket_relock_success, "Number of successful removals after relocking"); static long zap_and_exit_bucket_fail; STATNODE_ULONG(zap_and_exit_bucket_fail, @@ -392,6 +390,10 @@ static long cache_lock_vnodes_cel_3_failures; STATNODE_ULONG(cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); STATNODE_ULONG(numhotneg, "Number of hot negative entries"); +STATNODE_COUNTER(numneg_evicted, + "Number of negative entries evicted when adding a new entry"); +STATNODE_COUNTER(shrinking_skipped, + "Number of times shrinking was already in progress"); static void cache_zap_locked(struct namecache *ncp, bool neg_locked); static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir, @@ -809,8 +811,10 @@ cache_negative_zap_one(void) struct rwlock *blp; if (mtx_owner(&ncneg_shrink_lock) != NULL || - !mtx_trylock(&ncneg_shrink_lock)) + !mtx_trylock(&ncneg_shrink_lock)) { + counter_u64_add(shrinking_skipped, 1); return; + } mtx_lock(&ncneg_hot.nl_lock); ncp = TAILQ_FIRST(&ncneg_hot.nl_list); @@ -831,8 +835,9 @@ cache_negative_zap_one(void) shrink_list_turn = 0; if (ncp == NULL && shrink_list_turn == 0) cache_negative_shrink_select(shrink_list_turn, &ncp, &neglist); + mtx_unlock(&ncneg_shrink_lock); if (ncp == NULL) - goto out; + return; MPASS(ncp->nc_flag & NCF_NEGATIVE); dvlp = VP2VNODELOCK(ncp->nc_dvp); @@ -845,19 +850,15 @@ cache_negative_zap_one(void) if (ncp != ncp2 || dvlp != VP2VNODELOCK(ncp2->nc_dvp) || blp != NCP2BUCKETLOCK(ncp2) || !(ncp2->nc_flag & NCF_NEGATIVE)) { ncp = NULL; - goto out_unlock_all; + } else { + SDT_PROBE3(vfs, namecache, shrink_negative, done, ncp->nc_dvp, + ncp->nc_name, ncp->nc_neghits); + cache_zap_locked(ncp, true); + counter_u64_add(numneg_evicted, 1); } - SDT_PROBE3(vfs, namecache, shrink_negative, done, ncp->nc_dvp, - ncp->nc_name, ncp->nc_neghits); - - cache_zap_locked(ncp, true); - numneg_evicted++; -out_unlock_all: mtx_unlock(&neglist->nl_lock); rw_wunlock(blp); mtx_unlock(dvlp); -out: - mtx_unlock(&ncneg_shrink_lock); cache_free(ncp); } @@ -2016,6 +2017,8 @@ nchinit(void *dummy __unused) numfullpathfail4 = counter_u64_alloc(M_WAITOK); numfullpathfound = counter_u64_alloc(M_WAITOK); zap_and_exit_bucket_relock_success = counter_u64_alloc(M_WAITOK); + numneg_evicted = counter_u64_alloc(M_WAITOK); + shrinking_skipped = counter_u64_alloc(M_WAITOK); } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);