Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 08 Jan 1998 14:55:25 +0300
From:      Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
To:        freebsd-current@freebsd.org
Subject:   Almost memory leak in getnewvnode
Message-ID:  <199801081155.OAA17797@tejblum.dnttm.rssi.ru>

next in thread | raw e-mail | index | archive | help
getnewvnode() very rare reuse vnodes from the freelist and allocate a new 
vnode instead. It is because the way it use to move vnodes to the end of 
the freelist is too simple. The following patch reduced number of vnodes in my 
system in several times.

--- vfs_subr.c.00	Wed Jan  7 18:55:36 1998
+++ vfs_subr.c	Thu Jan  8 14:08:13 1998
@@ -373,7 +373,8 @@
 		 */
 		vp = NULL;
 	} else {
-		TAILQ_FOREACH(vp, &vnode_free_list, v_freelist) {
+		for(vp = TAILQ_FIRST(&vnode_free_list); vp; vp = tvp) {
+			tvp = TAILQ_NEXT(vp, v_freelist);
 			if (!simple_lock_try(&vp->v_interlock)) 
 				continue;
 			if (vp->v_usecount)
@@ -395,7 +396,7 @@
 		}
 	}
 
-	TAILQ_FOREACH(tvp, &vnode_tmp_list, v_freelist) {
+	while(tvp = TAILQ_FIRST(&vnode_tmp_list)) {
 		TAILQ_REMOVE(&vnode_tmp_list, tvp, v_freelist);
 		TAILQ_INSERT_TAIL(&vnode_free_list, tvp, v_freelist);
 		simple_unlock(&tvp->v_interlock);






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