From owner-svn-src-all@FreeBSD.ORG Mon Jan 14 05:44:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4A6E58B1; Mon, 14 Jan 2013 05:44:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 24BF22AA; Mon, 14 Jan 2013 05:44:48 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0E5imom051171; Mon, 14 Jan 2013 05:44:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0E5imKI051170; Mon, 14 Jan 2013 05:44:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201301140544.r0E5imKI051170@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 14 Jan 2013 05:44:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r245408 - head/sys/fs/nullfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2013 05:44:48 -0000 Author: kib Date: Mon Jan 14 05:44:47 2013 New Revision: 245408 URL: http://svnweb.freebsd.org/changeset/base/245408 Log: The current default size of the nullfs hash table used to lookup the existing nullfs vnode by the lower vnode is only 16 slots. Since the default mode for the nullfs is to cache the vnodes, hash has extremely huge chains. Size the nullfs hashtbl based on the current value of desiredvnodes. Use vfs_hash_index() to calculate the hash bucket for a given vnode. Pointy hat to: kib Diagnosed and reviewed by: peter Tested by: peter, pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 5 days Modified: head/sys/fs/nullfs/null_subr.c Modified: head/sys/fs/nullfs/null_subr.c ============================================================================== --- head/sys/fs/nullfs/null_subr.c Mon Jan 14 05:42:54 2013 (r245407) +++ head/sys/fs/nullfs/null_subr.c Mon Jan 14 05:44:47 2013 (r245408) @@ -46,9 +46,6 @@ #include -#define LOG2_SIZEVNODE 8 /* log2(sizeof struct vnode) */ -#define NNULLNODECACHE 16 - /* * Null layer cache: * Each cache entry holds a reference to the lower vnode @@ -57,12 +54,11 @@ * alias is removed the lower vnode is vrele'd. */ -#define NULL_NHASH(vp) \ - (&null_node_hashtbl[(((uintptr_t)vp)>>LOG2_SIZEVNODE) & null_node_hash]) +#define NULL_NHASH(vp) (&null_node_hashtbl[vfs_hash_index(vp) & null_hash_mask]) static LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl; -static u_long null_node_hash; -struct mtx null_hashmtx; +static struct mtx null_hashmtx; +static u_long null_hash_mask; static MALLOC_DEFINE(M_NULLFSHASH, "nullfs_hash", "NULLFS hash table"); MALLOC_DEFINE(M_NULLFSNODE, "nullfs_node", "NULLFS vnode private part"); @@ -77,8 +73,8 @@ nullfs_init(vfsp) struct vfsconf *vfsp; { - NULLFSDEBUG("nullfs_init\n"); /* printed during system boot */ - null_node_hashtbl = hashinit(NNULLNODECACHE, M_NULLFSHASH, &null_node_hash); + null_node_hashtbl = hashinit(desiredvnodes, M_NULLFSHASH, + &null_hash_mask); mtx_init(&null_hashmtx, "nullhs", NULL, MTX_DEF); return (0); } @@ -89,7 +85,7 @@ nullfs_uninit(vfsp) { mtx_destroy(&null_hashmtx); - hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_node_hash); + hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_hash_mask); return (0); }