From owner-svn-src-head@freebsd.org Wed Nov 27 01:20:56 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 A85731C6C6C; Wed, 27 Nov 2019 01:20:56 +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 47N2yw3qwvz4VP6; Wed, 27 Nov 2019 01:20:56 +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 683965CCA; Wed, 27 Nov 2019 01:20:56 +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 xAR1Kuht034236; Wed, 27 Nov 2019 01:20:56 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAR1Kuie034221; Wed, 27 Nov 2019 01:20:56 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201911270120.xAR1Kuie034221@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 27 Nov 2019 01:20:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355124 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 355124 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: Wed, 27 Nov 2019 01:20:56 -0000 Author: mjg Date: Wed Nov 27 01:20:55 2019 New Revision: 355124 URL: https://svnweb.freebsd.org/changeset/base/355124 Log: cache: fix numcache accounting on entry . entries are never created and .. can reuse existing entries, meaning the early count bump is both spurious and leading to overcounting in certain cases. Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Wed Nov 27 01:20:21 2019 (r355123) +++ head/sys/kern/vfs_cache.c Wed Nov 27 01:20:55 2019 (r355124) @@ -1690,15 +1690,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, return; #endif - /* - * Avoid blowout in namecache entries. - */ - lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; - if (__predict_false(lnumcache >= ncsize)) { - atomic_add_long(&numcache, -1); - return; - } - cache_celockstate_init(&cel); ndd = NULL; ncp_ts = NULL; @@ -1760,6 +1751,15 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, SDT_PROBE3(vfs, namecache, enter, done, dvp, "..", vp); flag = NCF_ISDOTDOT; } + } + + /* + * Avoid blowout in namecache entries. + */ + lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; + if (__predict_false(lnumcache >= ncsize)) { + atomic_add_long(&numcache, -1); + return; } held_dvp = false;