summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2012-04-10 15:50:52 +0000
committerguenther <guenther@openbsd.org>2012-04-10 15:50:52 +0000
commite6fd2ff84860d099ea5ae17d34f29629f598ebc7 (patch)
tree583b593e87386d627543d084f7eab708e15180d9
parentBuild with -O1 on vax for now, pcre_exec can not build with -O2. (diff)
downloadwireguard-openbsd-e6fd2ff84860d099ea5ae17d34f29629f598ebc7.tar.xz
wireguard-openbsd-e6fd2ff84860d099ea5ae17d34f29629f598ebc7.zip
Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimit
count processes instead of threads. New sysctl()s KERN_NTHREADS and KERN_MAXTHREAD count and limit threads. The nprocs and maxproc kernel variables are replaced by nprocess, maxprocess, nthreads, and maxthread. ok tedu@ mikeb@
-rw-r--r--sys/arch/alpha/alpha/pmap.c4
-rw-r--r--sys/arch/arm/arm/pmap.c5
-rw-r--r--sys/arch/m68k/m68k/pmap_motorola.c14
-rw-r--r--sys/arch/vax/vax/pmap.c8
-rw-r--r--sys/compat/linux/linux_misc.c4
-rw-r--r--sys/conf/param.c13
-rw-r--r--sys/kern/kern_exit.c16
-rw-r--r--sys/kern/kern_fork.c52
-rw-r--r--sys/kern/kern_proc.c8
-rw-r--r--sys/kern/kern_prot.c10
-rw-r--r--sys/kern/kern_resource.c4
-rw-r--r--sys/kern/kern_sysctl.c10
-rw-r--r--sys/miscfs/procfs/procfs_vfsops.c6
-rw-r--r--sys/sys/proc.h5
-rw-r--r--sys/sys/sysctl.h10
15 files changed, 98 insertions, 71 deletions
diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c
index 4d089612977..f1d54deac8c 100644
--- a/sys/arch/alpha/alpha/pmap.c
+++ b/sys/arch/alpha/alpha/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.62 2011/11/16 20:50:17 deraadt Exp $ */
+/* $OpenBSD: pmap.c,v 1.63 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.154 2000/12/07 22:18:55 thorpej Exp $ */
/*-
@@ -757,7 +757,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids)
* Figure out how many PTE's are necessary to map the kernel.
*/
lev3mapsize = (VM_PHYS_SIZE + 16 * NCARGS + PAGER_MAP_SIZE) /
- PAGE_SIZE + (maxproc * UPAGES) + nkmempages;
+ PAGE_SIZE + (maxthread * UPAGES) + nkmempages;
#ifdef SYSVSHM
lev3mapsize += shminfo.shmall;
diff --git a/sys/arch/arm/arm/pmap.c b/sys/arch/arm/arm/pmap.c
index a04cad57dd9..f1137fd32d6 100644
--- a/sys/arch/arm/arm/pmap.c
+++ b/sys/arch/arm/arm/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.35 2011/11/09 10:15:49 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.36 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.147 2004/01/18 13:03:50 scw Exp $ */
/*
@@ -4169,8 +4169,7 @@ pmap_postinit(void)
pool_setlowat(&pmap_l2dtable_pool,
(PAGE_SIZE / sizeof(struct l2_dtable)) * 2);
- needed = (maxproc / PMAP_DOMAINS) + ((maxproc % PMAP_DOMAINS) ? 1 : 0);
- needed -= 1;
+ needed = (maxprocess - 1) / PMAP_DOMAINS
l1 = malloc(sizeof(*l1) * needed, M_VMPMAP, M_WAITOK);
diff --git a/sys/arch/m68k/m68k/pmap_motorola.c b/sys/arch/m68k/m68k/pmap_motorola.c
index 63f70ffd5ec..ba96b504a12 100644
--- a/sys/arch/m68k/m68k/pmap_motorola.c
+++ b/sys/arch/m68k/m68k/pmap_motorola.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_motorola.c,v 1.66 2011/11/01 21:20:55 miod Exp $ */
+/* $OpenBSD: pmap_motorola.c,v 1.67 2012/04/10 15:50:52 guenther Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -454,7 +454,7 @@ pmap_init()
* Allocate physical memory for kernel PT pages and their management.
* We need 1 PT page per possible task plus some slop.
*/
- npages = min(atop(MACHINE_MAX_KPTSIZE), maxproc+16);
+ npages = min(atop(MACHINE_MAX_KPTSIZE), maxprocess+16);
s = ptoa(npages) + round_page(npages * sizeof(struct kpt_page));
/*
@@ -495,7 +495,7 @@ pmap_init()
/*
* Allocate the segment table map and the page table map.
*/
- s = maxproc * MACHINE_STSIZE;
+ s = maxprocess * MACHINE_STSIZE;
st_map = uvm_km_suballoc(kernel_map, &addr, &addr2, s, 0, FALSE,
&st_map_store);
@@ -519,17 +519,17 @@ pmap_init()
Sysseg, Sysmap, Sysptmap));
addr = MACHINE_PTBASE;
- if ((MACHINE_PTMAXSIZE / MACHINE_MAX_PTSIZE) < maxproc) {
+ if ((MACHINE_PTMAXSIZE / MACHINE_MAX_PTSIZE) < maxprocess) {
s = MACHINE_PTMAXSIZE;
/*
* XXX We don't want to hang when we run out of
- * page tables, so we lower maxproc so that fork()
+ * page tables, so we lower maxprocess so that fork()
* will fail instead. Note that root could still raise
* this value via sysctl(3).
*/
- maxproc = (MACHINE_PTMAXSIZE / MACHINE_MAX_PTSIZE);
+ maxprocess = (MACHINE_PTMAXSIZE / MACHINE_MAX_PTSIZE);
} else
- s = (maxproc * MACHINE_MAX_PTSIZE);
+ s = (maxprocess * MACHINE_MAX_PTSIZE);
pt_map = uvm_km_suballoc(kernel_map, &addr, &addr2, s, 0,
TRUE, &pt_map_store);
diff --git a/sys/arch/vax/vax/pmap.c b/sys/arch/vax/vax/pmap.c
index 651dafc2f0c..eebcc0ad66f 100644
--- a/sys/arch/vax/vax/pmap.c
+++ b/sys/arch/vax/vax/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.53 2011/07/06 18:33:00 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.54 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.74 1999/11/13 21:32:25 matt Exp $ */
/*
* Copyright (c) 1994, 1998, 1999 Ludd, University of Lule}, Sweden.
@@ -130,13 +130,13 @@ pmap_bootstrap()
*/
/* Kernel alloc area */
- sysptsize = (((0x100000 * maxproc) >> VAX_PGSHIFT) / 4);
+ sysptsize = (((0x100000 * maxprocess) >> VAX_PGSHIFT) / 4);
/* reverse mapping struct */
sysptsize += (avail_end >> VAX_PGSHIFT) * 2;
/* User Page table area. This may grow big */
- sysptsize += ((USRPTSIZE * 4) / VAX_NBPG) * maxproc;
+ sysptsize += ((USRPTSIZE * 4) / VAX_NBPG) * maxprocess;
/* Kernel stacks per process */
- sysptsize += UPAGES * maxproc;
+ sysptsize += UPAGES * maxthread;
/* IO device register space */
sysptsize += IOSPSZ;
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 9d300d33a1e..544bfe72cde 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_misc.c,v 1.74 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: linux_misc.c,v 1.75 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */
/*-
@@ -1437,7 +1437,7 @@ linux_sys_sysinfo(p, v, retval)
si.bufferram = bufpages * PAGE_SIZE;
si.totalswap = uvmexp.swpages * PAGE_SIZE;
si.freeswap = (uvmexp.swpages - uvmexp.swpginuse) * PAGE_SIZE;
- si.procs = nprocs;
+ si.procs = nthreads;
/* The following are only present in newer Linux kernels. */
si.totalbig = 0;
si.freebig = 0;
diff --git a/sys/conf/param.c b/sys/conf/param.c
index d9d4fef2b57..593d18f4d12 100644
--- a/sys/conf/param.c
+++ b/sys/conf/param.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.c,v 1.33 2011/08/08 19:34:25 deraadt Exp $ */
+/* $OpenBSD: param.c,v 1.34 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: param.c,v 1.16 1996/03/12 03:08:40 mrg Exp $ */
/*
@@ -82,12 +82,13 @@ int hz = HZ;
int tick = 1000000 / HZ;
int tickadj = 240000 / (60 * HZ); /* can adjust 240ms in 60s */
struct timezone tz = { TIMEZONE, DST };
-#define NPROC (30 + 16 * MAXUSERS)
-#define NTEXT (80 + NPROC / 8) /* actually the object cache */
-#define NVNODE (NPROC * 2 + NTEXT + 100)
+#define NPROCESS (30 + 16 * MAXUSERS)
+#define NTEXT (80 + NPROCESS / 8) /* actually the object cache */
+#define NVNODE (NPROCESS * 2 + NTEXT + 100)
int desiredvnodes = NVNODE;
-int maxproc = NPROC;
-int maxfiles = 5 * (NPROC + MAXUSERS) + 80;
+int maxprocess = NPROCESS;
+int maxthread = NPROCESS + 8 * MAXUSERS;
+int maxfiles = 5 * (NPROCESS + MAXUSERS) + 80;
int nmbclust = NMBCLUSTERS;
#ifndef MBLOWAT
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a715cd1f1b0..8b5fe9d463a 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.110 2012/04/06 02:18:49 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.111 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -584,13 +584,14 @@ proc_zap(struct proc *p)
if ((p->p_flag & P_THREAD) == 0)
leavepgrp(pr);
LIST_REMOVE(p, p_list); /* off zombproc */
- if ((p->p_flag & P_THREAD) == 0)
+ if ((p->p_flag & P_THREAD) == 0) {
LIST_REMOVE(pr, ps_sibling);
- /*
- * Decrement the count of procs running with this uid.
- */
- (void)chgproccnt(p->p_cred->p_ruid, -1);
+ /*
+ * Decrement the count of procs running with this uid.
+ */
+ (void)chgproccnt(p->p_cred->p_ruid, -1);
+ }
/*
* Release reference to text vnode
@@ -611,8 +612,9 @@ proc_zap(struct proc *p)
crfree(pr->ps_cred->pc_ucred);
pool_put(&pcred_pool, pr->ps_cred);
pool_put(&process_pool, pr);
+ nprocesses--;
}
pool_put(&proc_pool, p);
- nprocs--;
+ nthreads--;
}
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index f7225155e47..8bf4a377777 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.135 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.136 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -69,7 +69,8 @@
# include <machine/tcb.h>
#endif
-int nprocs = 1; /* process 0 */
+int nprocesses = 1; /* process 0 */
+int nthreads = 1; /* proc 0 */
int randompid; /* when set to 1, pid's go random */
pid_t lastpid;
struct forkstat forkstat;
@@ -266,28 +267,46 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
/*
* Although process entries are dynamically created, we still keep
* a global limit on the maximum number we will create. We reserve
- * the last 5 processes to root. The variable nprocs is the current
- * number of processes, maxproc is the limit.
+ * the last 5 processes to root. The variable nprocesses is the
+ * current number of processes, maxprocess is the limit. Similar
+ * rules for threads (struct proc): we reserve the last 5 to root;
+ * the variable nthreads is the current number of procs, maxthread is
+ * the limit.
*/
uid = curp->p_cred->p_ruid;
- if ((nprocs >= maxproc - 5 && uid != 0) || nprocs >= maxproc) {
+ if ((nthreads >= maxthread - 5 && uid != 0) || nthreads >= maxthread) {
static struct timeval lasttfm;
if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("proc");
return (EAGAIN);
}
- nprocs++;
+ nthreads++;
- /*
- * Increment the count of procs running with this uid. Don't allow
- * a nonprivileged user to exceed their current limit.
- */
- count = chgproccnt(uid, 1);
- if (uid != 0 && count > curp->p_rlimit[RLIMIT_NPROC].rlim_cur) {
- (void)chgproccnt(uid, -1);
- nprocs--;
- return (EAGAIN);
+ if ((flags & FORK_THREAD) == 0) {
+ if ((nprocesses >= maxprocess - 5 && uid != 0) ||
+ nprocesses >= maxprocess) {
+ static struct timeval lasttfm;
+
+ if (ratecheck(&lasttfm, &fork_tfmrate))
+ tablefull("process");
+ nthreads--;
+ return (EAGAIN);
+ }
+ nprocesses++;
+
+ /*
+ * Increment the count of processes running with
+ * this uid. Don't allow a nonprivileged user to
+ * exceed their current limit.
+ */
+ count = chgproccnt(uid, 1);
+ if (uid != 0 && count > curp->p_rlimit[RLIMIT_NPROC].rlim_cur) {
+ (void)chgproccnt(uid, -1);
+ nprocesses--;
+ nthreads--;
+ return (EAGAIN);
+ }
}
uaddr = uvm_km_kmemalloc_pla(kernel_map, uvm.kernel_object, USPACE,
@@ -296,7 +315,8 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
0, 0, USPACE/PAGE_SIZE);
if (uaddr == 0) {
chgproccnt(uid, -1);
- nprocs--;
+ nprocesses--;
+ nthreads--;
return (ENOMEM);
}
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 2bf3d8589b1..ad861c8e8af 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.47 2011/09/18 23:20:54 miod Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.48 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -86,9 +86,9 @@ procinit(void)
LIST_INIT(&zombproc);
- pidhashtbl = hashinit(maxproc / 4, M_PROC, M_NOWAIT, &pidhash);
- pgrphashtbl = hashinit(maxproc / 4, M_PROC, M_NOWAIT, &pgrphash);
- uihashtbl = hashinit(maxproc / 16, M_PROC, M_NOWAIT, &uihash);
+ pidhashtbl = hashinit(maxthread / 4, M_PROC, M_NOWAIT, &pidhash);
+ pgrphashtbl = hashinit(maxprocess / 4, M_PROC, M_NOWAIT, &pgrphash);
+ uihashtbl = hashinit(maxprocess / 16, M_PROC, M_NOWAIT, &uihash);
if (!pidhashtbl || !pgrphashtbl || !uihashtbl)
panic("procinit: malloc");
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 95a7c0a2401..c4a833de12e 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_prot.c,v 1.52 2012/02/20 22:23:39 guenther Exp $ */
+/* $OpenBSD: kern_prot.c,v 1.53 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */
/*
@@ -391,8 +391,8 @@ sys_setresuid(struct proc *p, void *v, register_t *retval)
/*
* Transfer proc count to new user.
*/
- (void)chgproccnt(pc->p_ruid, -p->p_p->ps_refcnt);
- (void)chgproccnt(ruid, p->p_p->ps_refcnt);
+ (void)chgproccnt(pc->p_ruid, -1);
+ (void)chgproccnt(ruid, 1);
pc->p_ruid = ruid;
}
if (euid != (uid_t)-1 && euid != pc->pc_ucred->cr_uid) {
@@ -596,8 +596,8 @@ sys_setuid(struct proc *p, void *v, register_t *retval)
* Transfer proc count to new user.
*/
if (uid != pc->p_ruid) {
- (void)chgproccnt(pc->p_ruid, -p->p_p->ps_refcnt);
- (void)chgproccnt(uid, p->p_p->ps_refcnt);
+ (void)chgproccnt(pc->p_ruid, -1);
+ (void)chgproccnt(uid, 1);
}
pc->p_ruid = uid;
pc->p_svuid = uid;
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index ab199d4401e..995b3db15ef 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_resource.c,v 1.39 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.40 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@@ -264,7 +264,7 @@ dosetrlimit(struct proc *p, u_int which, struct rlimit *limp)
maxlim = maxfiles;
break;
case RLIMIT_NPROC:
- maxlim = maxproc;
+ maxlim = maxprocess;
break;
default:
maxlim = RLIM_INFINITY;
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 8651cf8514a..e577f6b1e35 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.218 2012/03/28 16:01:30 guenther Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.219 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -316,7 +316,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case KERN_MAXVNODES:
return(sysctl_int(oldp, oldlenp, newp, newlen, &maxvnodes));
case KERN_MAXPROC:
- return (sysctl_int(oldp, oldlenp, newp, newlen, &maxproc));
+ return (sysctl_int(oldp, oldlenp, newp, newlen, &maxprocess));
case KERN_MAXFILES:
return (sysctl_int(oldp, oldlenp, newp, newlen, &maxfiles));
case KERN_NFILES:
@@ -401,6 +401,10 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (sysctl_rdint(oldp, oldlenp, newp, MAXPARTITIONS));
case KERN_RAWPARTITION:
return (sysctl_rdint(oldp, oldlenp, newp, RAW_PART));
+ case KERN_MAXTHREAD:
+ return (sysctl_int(oldp, oldlenp, newp, newlen, &maxthread));
+ case KERN_NTHREADS:
+ return (sysctl_rdint(oldp, oldlenp, newp, nthreads));
case KERN_SOMAXCONN:
return (sysctl_int(oldp, oldlenp, newp, newlen, &somaxconn));
case KERN_SOMINCONN:
@@ -494,7 +498,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case KERN_CCPU:
return (sysctl_rdint(oldp, oldlenp, newp, ccpu));
case KERN_NPROCS:
- return (sysctl_rdint(oldp, oldlenp, newp, nprocs));
+ return (sysctl_rdint(oldp, oldlenp, newp, nprocesses));
case KERN_POOL:
return (sysctl_dopool(name + 1, namelen - 1, oldp, oldlenp));
case KERN_STACKGAPRANDOM:
diff --git a/sys/miscfs/procfs/procfs_vfsops.c b/sys/miscfs/procfs/procfs_vfsops.c
index 2325b8a4e17..4663c10a0c3 100644
--- a/sys/miscfs/procfs/procfs_vfsops.c
+++ b/sys/miscfs/procfs/procfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_vfsops.c,v 1.26 2010/09/23 18:43:37 oga Exp $ */
+/* $OpenBSD: procfs_vfsops.c,v 1.27 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: procfs_vfsops.c,v 1.25 1996/02/09 22:40:53 christos Exp $ */
/*
@@ -176,8 +176,8 @@ procfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
sbp->f_blocks = vmtotals.t_vm;
sbp->f_bfree = vmtotals.t_vm - vmtotals.t_avm;
sbp->f_bavail = 0;
- sbp->f_files = maxproc; /* approx */
- sbp->f_ffree = maxproc - nprocs; /* approx */
+ sbp->f_files = maxprocess; /* approx */
+ sbp->f_ffree = maxprocess - nprocesses; /* approx */
if (sbp != &mp->mnt_stat) {
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 1af10a61667..f6a52e34e6b 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.153 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: proc.h,v 1.154 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -493,7 +493,8 @@ extern LIST_HEAD(pgrphashhead, pgrp) *pgrphashtbl;
extern u_long pgrphash;
extern struct proc proc0; /* Process slot for swapper. */
-extern int nprocs, maxproc; /* Current and max number of procs. */
+extern int nprocesses, maxprocess; /* Cur and max number of processes. */
+extern int nthreads, maxthread; /* Cur and max number of threads. */
extern int randompid; /* fork() should create random pid's */
LIST_HEAD(proclist, proc);
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index dcb12fedf16..e1363560bba 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.121 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: sysctl.h,v 1.122 2012/04/10 15:50:52 guenther Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -130,8 +130,8 @@ struct ctlname {
#define KERN_DOMAINNAME 22 /* string: (YP) domainname */
#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
#define KERN_RAWPARTITION 24 /* int: raw partition number */
-/*define gap 25 */
-/*define gap 26 */
+#define KERN_MAXTHREAD 25 /* int: max threads */
+#define KERN_NTHREADS 26 /* int: number of threads */
#define KERN_OSVERSION 27 /* string: kernel build version */
#define KERN_SOMAXCONN 28 /* int: listen queue maximum */
#define KERN_SOMINCONN 29 /* int: half-open controllable param */
@@ -212,8 +212,8 @@ struct ctlname {
{ "domainname", CTLTYPE_STRING }, \
{ "maxpartitions", CTLTYPE_INT }, \
{ "rawpartition", CTLTYPE_INT }, \
- { "gap", 0 }, \
- { "gap", 0 }, \
+ { "maxthread", CTLTYPE_INT }, \
+ { "nthreads", CTLTYPE_INT }, \
{ "osversion", CTLTYPE_STRING }, \
{ "somaxconn", CTLTYPE_INT }, \
{ "sominconn", CTLTYPE_INT }, \