Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys calculate vnode cache size based on the resource it gets...
details: https://anonhg.NetBSD.org/src/rev/6fe5ceffab1d
branches: trunk
changeset: 785534:6fe5ceffab1d
user: para <para%NetBSD.org@localhost>
date: Mon Mar 18 13:36:21 2013 +0000
description:
calculate vnode cache size based on the resource it gets allocated from
this stops setting kern.maxvnodes to high so it exhausts available space in kmem
http://mail-index.netbsd.org/tech-kern/2013/03/08/msg015095.html
diffstat:
sys/kern/init_main.c | 17 +++++++----------
sys/kern/init_sysctl.c | 9 +++++----
sys/kern/vfs_bio.c | 8 +++++---
sys/rump/librump/rumpkern/emul.c | 6 +++---
sys/sys/param.h | 6 +++---
sys/sys/systm.h | 5 ++---
6 files changed, 25 insertions(+), 26 deletions(-)
diffs (191 lines):
diff -r 86352640a0cf -r 6fe5ceffab1d sys/kern/init_main.c
--- a/sys/kern/init_main.c Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/kern/init_main.c Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.447 2013/02/21 01:39:55 pgoyette Exp $ */
+/* $NetBSD: init_main.c,v 1.448 2013/03/18 13:36:21 para Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.447 2013/02/21 01:39:55 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.448 2013/03/18 13:36:21 para Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -444,8 +444,8 @@
* 10% of memory for vnodes and associated data structures in the
* assumed worst case. Do not provide fewer than NVNODE vnodes.
*/
- usevnodes =
- calc_cache_size(kernel_map, 10, VNODE_VA_MAXPCT) / VNODE_COST;
+ usevnodes = calc_cache_size(vmem_size(kmem_arena, VMEM_FREE|VMEM_ALLOC),
+ 10, VNODE_KMEM_MAXPCT) / VNODE_COST;
if (usevnodes > desiredvnodes)
desiredvnodes = usevnodes;
#endif
@@ -1078,20 +1078,17 @@
}
/*
- * calculate cache size (in bytes) from physmem and vm_map size.
+ * calculate cache size (in bytes) from physmem and vsize.
*/
vaddr_t
-calc_cache_size(struct vm_map *map, int pct, int va_pct)
+calc_cache_size(vsize_t vsize, int pct, int va_pct)
{
paddr_t t;
/* XXX should consider competing cache if any */
/* XXX should consider submaps */
t = (uintmax_t)physmem * pct / 100 * PAGE_SIZE;
- if (map != NULL) {
- vsize_t vsize;
-
- vsize = vm_map_max(map) - vm_map_min(map);
+ if (vsize != 0) {
vsize = (uintmax_t)vsize * va_pct / 100;
if (t > vsize) {
t = vsize;
diff -r 86352640a0cf -r 6fe5ceffab1d sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/kern/init_sysctl.c Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl.c,v 1.196 2013/03/07 18:02:54 matt Exp $ */
+/* $NetBSD: init_sysctl.c,v 1.197 2013/03/18 13:36:22 para Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.196 2013/03/07 18:02:54 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.197 2013/03/18 13:36:22 para Exp $");
#include "opt_sysv.h"
#include "opt_compat_netbsd.h"
@@ -961,8 +961,9 @@
if (new_vnodes <= 0)
return (EINVAL);
- /* Limits: 75% of KVA and physical memory. */
- new_max = calc_cache_size(kernel_map, 75, 75) / VNODE_COST;
+ /* Limits: 75% of kmem and physical memory. */
+ new_max = calc_cache_size(vmem_size(kmem_arena, VMEM_FREE|VMEM_ALLOC),
+ 75, 75) / VNODE_COST;
if (new_vnodes > new_max)
new_vnodes = new_max;
diff -r 86352640a0cf -r 6fe5ceffab1d sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/kern/vfs_bio.c Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.242 2012/12/30 09:19:24 hannken Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.243 2013/03/18 13:36:22 para Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.242 2012/12/30 09:19:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.243 2013/03/18 13:36:22 para Exp $");
#include "opt_bufcache.h"
@@ -396,6 +396,7 @@
buf_memcalc(void)
{
u_long n;
+ vsize_t mapsz;
/*
* Determine the upper bound of memory to use for buffers.
@@ -417,7 +418,8 @@
printf("forcing bufcache %d -> 95", bufcache);
bufcache = 95;
}
- n = calc_cache_size(buf_map, bufcache,
+ mapsz = vm_map_max(buf_map) - vm_map_min(buf_map);
+ n = calc_cache_size(mapsz, bufcache,
(buf_map != kernel_map) ? 100 : BUFCACHE_VA_MAXPCT)
/ PAGE_SIZE;
}
diff -r 86352640a0cf -r 6fe5ceffab1d sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/rump/librump/rumpkern/emul.c Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emul.c,v 1.154 2013/03/07 19:07:05 pooka Exp $ */
+/* $NetBSD: emul.c,v 1.155 2013/03/18 13:36:23 para Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.154 2013/03/07 19:07:05 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.155 2013/03/18 13:36:23 para Exp $");
#include <sys/param.h>
#include <sys/null.h>
@@ -192,7 +192,7 @@
}
vaddr_t
-calc_cache_size(struct vm_map *map, int pct, int va_pct)
+calc_cache_size(vsize_t vasz, int pct, int va_pct)
{
paddr_t t;
diff -r 86352640a0cf -r 6fe5ceffab1d sys/sys/param.h
--- a/sys/sys/param.h Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/sys/param.h Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.425 2013/02/13 14:03:49 hannken Exp $ */
+/* $NetBSD: param.h,v 1.426 2013/03/18 13:36:23 para Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -149,8 +149,8 @@
#define NVNODE (NPROC + NTEXT + 100)
#define NVNODE_IMPLICIT
#endif
-#ifndef VNODE_VA_MAXPCT
-#define VNODE_VA_MAXPCT 20
+#ifndef VNODE_KMEM_MAXPCT
+#define VNODE_KMEM_MAXPCT 60
#endif
#ifndef BUFCACHE_VA_MAXPCT
#define BUFCACHE_VA_MAXPCT 20
diff -r 86352640a0cf -r 6fe5ceffab1d sys/sys/systm.h
--- a/sys/sys/systm.h Mon Mar 18 13:14:10 2013 +0000
+++ b/sys/sys/systm.h Mon Mar 18 13:36:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.257 2012/08/03 18:08:01 matt Exp $ */
+/* $NetBSD: systm.h,v 1.258 2013/03/18 13:36:23 para Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -62,7 +62,6 @@
struct uio;
struct vnode;
struct vmspace;
-struct vm_map;
extern const char *panicstr; /* panic message */
extern int doing_shutdown; /* shutting down */
@@ -534,6 +533,6 @@
#define ASSERT_SLEEPABLE() /* nothing */
#endif /* defined(DEBUG) */
-vaddr_t calc_cache_size(struct vm_map *, int, int);
+vaddr_t calc_cache_size(vsize_t , int, int);
#endif /* !_SYS_SYSTM_H_ */
Home |
Main Index |
Thread Index |
Old Index