From owner-svn-src-head@freebsd.org Tue Jul 14 21:19:34 2020 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 86D5C36FAEF; Tue, 14 Jul 2020 21:19:34 +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 4B5tgp1FfFz434c; Tue, 14 Jul 2020 21:19:34 +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 E61E5C2DA; Tue, 14 Jul 2020 21:19:33 +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 06ELJXSd022347; Tue, 14 Jul 2020 21:19:33 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06ELJXtb022346; Tue, 14 Jul 2020 21:19:33 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202007142119.06ELJXtb022346@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 14 Jul 2020 21:19:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363202 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 363202 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.33 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: Tue, 14 Jul 2020 21:19:34 -0000 Author: mjg Date: Tue Jul 14 21:19:33 2020 New Revision: 363202 URL: https://svnweb.freebsd.org/changeset/base/363202 Log: cache: make negative shrinker round robin on all lists every time Previously it would check 4, 3, 2, 1 lists. In practice by the time it is getting called all lists have some elements and consequently this does not result in new evictions. Nonetheless, the code is clearer. Tested by: pho Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Tue Jul 14 21:17:46 2020 (r363201) +++ head/sys/kern/vfs_cache.c Tue Jul 14 21:19:33 2020 (r363202) @@ -262,7 +262,6 @@ static u_int __read_mostly ncsize; /* the size as comp struct nchstats nchstats; /* cache effectiveness statistics */ static struct mtx __exclusive_cache_line ncneg_shrink_lock; -static int shrink_list_turn; struct neglist { struct mtx nl_lock; @@ -815,18 +814,18 @@ cache_negative_remove(struct namecache *ncp) } static void -cache_negative_shrink_select(int start, struct namecache **ncpp, +cache_negative_shrink_select(struct namecache **ncpp, struct neglist **neglistpp) { struct neglist *neglist; struct namecache *ncp; - int i; + static u_int cycle; + u_int i; *ncpp = ncp = NULL; - neglist = NULL; - for (i = start; i < numneglists; i++) { - neglist = &neglists[i]; + for (i = 0; i < numneglists; i++) { + neglist = &neglists[(cycle + i) % numneglists]; if (TAILQ_FIRST(&neglist->nl_list) == NULL) continue; mtx_lock(&neglist->nl_lock); @@ -838,6 +837,7 @@ cache_negative_shrink_select(int start, struct namecac *neglistpp = neglist; *ncpp = ncp; + cycle++; } static void @@ -870,12 +870,8 @@ cache_negative_zap_one(void) } mtx_unlock(&ncneg_hot.nl_lock); - cache_negative_shrink_select(shrink_list_turn, &ncp, &neglist); - shrink_list_turn++; - if (shrink_list_turn == numneglists) - shrink_list_turn = 0; - if (ncp == NULL && shrink_list_turn == 0) - cache_negative_shrink_select(shrink_list_turn, &ncp, &neglist); + cache_negative_shrink_select(&ncp, &neglist); + mtx_unlock(&ncneg_shrink_lock); if (ncp == NULL) return;