From owner-svn-src-all@freebsd.org Wed Feb 24 15:15:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1EC93AB1961; Wed, 24 Feb 2016 15:15:48 +0000 (UTC) (envelope-from kib@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 mx1.freebsd.org (Postfix) with ESMTPS id EF2231245; Wed, 24 Feb 2016 15:15:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1OFFlQ9053717; Wed, 24 Feb 2016 15:15:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1OFFk4q053714; Wed, 24 Feb 2016 15:15:46 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201602241515.u1OFFk4q053714@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 24 Feb 2016 15:15:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295971 - in head/sys: kern sys 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.20 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: Wed, 24 Feb 2016 15:15:48 -0000 Author: kib Date: Wed Feb 24 15:15:46 2016 New Revision: 295971 URL: https://svnweb.freebsd.org/changeset/base/295971 Log: Provide more correct sizing of the KVA consumed by a vnode, used by the virtvnodes calculation. Include the size of fs-specific v_data as the nfs nclnode inline, the NFS nclnode is bigger than either ZFS znode or UFS inode. Include the size of namecache_ts and short cache path element, multiplied by the name cache population factor, again inline. Inline defines are used to avoid pollution of the vnode.h with the subsystem-private objects. Non-significant unsynchronized changes of the definitions are fine, we do not care about that precision, and e.g. ZFS consumes much malloced memory per vnode for reasons unaccounted in the formula. Lower the partition of kmem dedicated to vnodes, from 1/7 to 1/10. The measures reduce vnode cache pressure on kmem and bring the vnode cache memory use below some apparent thresholds that were exceeded by r291244 due to more robust vnode reuse. Reported and tested by: marius (i386, previous version) Reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/kern/vfs_cache.c head/sys/kern/vfs_subr.c head/sys/sys/vnode.h Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Wed Feb 24 13:48:40 2016 (r295970) +++ head/sys/kern/vfs_cache.c Wed Feb 24 15:15:46 2016 (r295971) @@ -171,7 +171,7 @@ SYSCTL_ULONG(_debug, OID_AUTO, numcache, static u_long numcachehv; /* number of cache entries with vnodes held */ SYSCTL_ULONG(_debug, OID_AUTO, numcachehv, CTLFLAG_RD, &numcachehv, 0, "Number of namecache entries with vnodes held"); -static u_int ncsizefactor = 2; +u_int ncsizefactor = 2; SYSCTL_UINT(_vfs, OID_AUTO, ncsizefactor, CTLFLAG_RW, &ncsizefactor, 0, "Size factor for namecache"); Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Wed Feb 24 13:48:40 2016 (r295970) +++ head/sys/kern/vfs_subr.c Wed Feb 24 15:15:46 2016 (r295971) @@ -407,6 +407,27 @@ vnode_fini(void *mem, int size) rw_destroy(BO_LOCKPTR(bo)); } +/* + * Provide the size of NFS nclnode and NFS fh for calculation of the + * vnode memory consumption. The size is specified directly to + * eliminate dependency on NFS-private header. + * + * Other filesystems may use bigger or smaller (like UFS and ZFS) + * private inode data, but the NFS-based estimation is ample enough. + * Still, we care about differences in the size between 64- and 32-bit + * platforms. + * + * Namecache structure size is heuristically + * sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1. + */ +#ifdef _LP64 +#define NFS_NCLNODE_SZ (528 + 64) +#define NC_SZ 148 +#else +#define NFS_NCLNODE_SZ (360 + 32) +#define NC_SZ 92 +#endif + static void vntblinit(void *dummy __unused) { @@ -422,12 +443,12 @@ vntblinit(void *dummy __unused) * marginal ratio of desiredvnodes to the physical memory size is * 1:64. However, desiredvnodes is limited by the kernel's heap * size. The memory required by desiredvnodes vnodes and vm objects - * must not exceed 1/7th of the kernel's heap size. + * must not exceed 1/10th of the kernel's heap size. */ physvnodes = maxproc + pgtok(vm_cnt.v_page_count) / 64 + 3 * min(98304 * 16, pgtok(vm_cnt.v_page_count)) / 64; - virtvnodes = vm_kmem_size / (7 * (sizeof(struct vm_object) + - sizeof(struct vnode))); + virtvnodes = vm_kmem_size / (10 * (sizeof(struct vm_object) + + sizeof(struct vnode) + NC_SZ * ncsizefactor + NFS_NCLNODE_SZ)); desiredvnodes = min(physvnodes, virtvnodes); if (desiredvnodes > MAXVNODES_MAX) { if (bootverbose) Modified: head/sys/sys/vnode.h ============================================================================== --- head/sys/sys/vnode.h Wed Feb 24 13:48:40 2016 (r295970) +++ head/sys/sys/vnode.h Wed Feb 24 15:15:46 2016 (r295971) @@ -372,6 +372,8 @@ struct vattr { MALLOC_DECLARE(M_VNODE); #endif +extern u_int ncsizefactor; + /* * Convert between vnode types and inode formats (since POSIX.1 * defines mode word of stat structure in terms of inode formats).