From owner-freebsd-current Thu Jan 8 03:59:00 1998 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id DAA07007 for current-outgoing; Thu, 8 Jan 1998 03:59:00 -0800 (PST) (envelope-from owner-freebsd-current) Received: from helios.dnttm.ru (root@dnttm.wave.ras.ru [194.85.104.197]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id DAA06983 for ; Thu, 8 Jan 1998 03:58:47 -0800 (PST) (envelope-from dima@tejblum.dnttm.rssi.ru) Received: (from uucp@localhost) by helios.dnttm.ru (8.8.5/8.8.5/IP-3) with UUCP id OAA25932 for freebsd-current@freebsd.org; Thu, 8 Jan 1998 14:52:31 +0300 Received: from tejblum.dnttm.rssi.ru (localhost [127.0.0.1]) by tejblum.dnttm.rssi.ru (8.8.8/8.8.7) with ESMTP id OAA17797 for ; Thu, 8 Jan 1998 14:55:26 +0300 (MSK) (envelope-from dima@tejblum.dnttm.rssi.ru) Message-Id: <199801081155.OAA17797@tejblum.dnttm.rssi.ru> X-Mailer: exmh version 2.0gamma 1/27/96 To: freebsd-current@freebsd.org Subject: Almost memory leak in getnewvnode Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 08 Jan 1998 14:55:25 +0300 From: Dmitrij Tejblum Sender: owner-freebsd-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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);