summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_param.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r--sys/kern/subr_param.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index 421bd37..2ca0051 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -93,6 +93,7 @@ int ncallout; /* maximum # of timer events */
int nbuf;
int ngroups_max; /* max # groups per process */
int nswbuf;
+quad_t maxmbufmem; /* max mbuf memory */
pid_t pid_max = PID_MAX;
long maxswzone; /* max swmeta KVA storage */
long maxbcache; /* max buffer cache KVA storage */
@@ -271,6 +272,7 @@ init_param1(void)
void
init_param2(long physpages)
{
+ quad_t realmem;
/* Base parameters */
maxusers = MAXUSERS;
@@ -294,19 +296,25 @@ init_param2(long physpages)
/*
* The following can be overridden after boot via sysctl. Note:
* unless overriden, these macros are ultimately based on maxusers.
- */
- maxproc = NPROC;
- TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
- /*
* Limit maxproc so that kmap entries cannot be exhausted by
* processes.
*/
+ maxproc = NPROC;
+ TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
if (maxproc > (physpages / 12))
maxproc = physpages / 12;
- maxfiles = MAXFILES;
- TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
maxprocperuid = (maxproc * 9) / 10;
- maxfilesperproc = (maxfiles * 9) / 10;
+
+ /*
+ * The default limit for maxfiles is 1/12 of the number of
+ * physical page but not less than 16 times maxusers.
+ * At most it can be 1/6 the number of physical pages.
+ */
+ maxfiles = imax(MAXFILES, physpages / 8);
+ TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
+ if (maxfiles > (physpages / 4))
+ maxfiles = physpages / 4;
+ maxfilesperproc = (maxfiles / 10) * 9;
/*
* Cannot be changed after boot.
@@ -314,20 +322,35 @@ init_param2(long physpages)
nbuf = NBUF;
TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
+ /*
+ * XXX: Does the callout wheel have to be so big?
+ */
ncallout = 16 + maxproc + maxfiles;
TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
/*
+ * The default limit for all mbuf related memory is 1/2 of all
+ * available kernel memory (physical or kmem).
+ * At most it can be 3/4 of available kernel memory.
+ */
+ realmem = qmin(physpages * PAGE_SIZE,
+ VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
+ maxmbufmem = realmem / 2;
+ TUNABLE_QUAD_FETCH("kern.maxmbufmem", &maxmbufmem);
+ if (maxmbufmem > (realmem / 4) * 3)
+ maxmbufmem = (realmem / 4) * 3;
+
+ /*
* The default for maxpipekva is min(1/64 of the kernel address space,
* max(1/64 of main memory, 512KB)). See sys_pipe.c for more details.
*/
maxpipekva = (physpages / 64) * PAGE_SIZE;
+ TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
if (maxpipekva < 512 * 1024)
maxpipekva = 512 * 1024;
if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) /
64;
- TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
}
/*
OpenPOWER on IntegriCloud