Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jan 2021 06:53:12 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7220a10b5b34 - main - cache: predict on no spurious slashes in cache_fpl_handle_root
Message-ID:  <202101030653.1036rCnF023152@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=7220a10b5b343f0528612c62072f80458076a061

commit 7220a10b5b343f0528612c62072f80458076a061
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-01-01 02:25:19 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-01-03 06:50:06 +0000

    cache: predict on no spurious slashes in cache_fpl_handle_root
    
    This is a step towards speculatively not handling them.
---
 sys/kern/vfs_cache.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index b4882079790d..396969bb10ec 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -3623,9 +3623,15 @@ cache_fpl_handle_root(struct cache_fpl *fpl)
 	ndp = fpl->ndp;
 	cnp = fpl->cnp;
 
-	while (*(cnp->cn_nameptr) == '/') {
-		cnp->cn_nameptr++;
-		ndp->ni_pathlen--;
+	MPASS(*(cnp->cn_nameptr) == '/');
+	cnp->cn_nameptr++;
+	ndp->ni_pathlen--;
+
+	if (__predict_false(*(cnp->cn_nameptr) == '/')) {
+		do {
+			cnp->cn_nameptr++;
+			ndp->ni_pathlen--;
+		} while (*(cnp->cn_nameptr) == '/');
 	}
 
 	return (ndp->ni_rootdir);



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