mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
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
This commit is contained in:
parent
23a6c7330c
commit
0791e0c0e7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295971
@ -171,7 +171,7 @@ SYSCTL_ULONG(_debug, OID_AUTO, numcache, CTLFLAG_RD, &numcache, 0,
|
||||
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");
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user