From 0e28b643e91801ca0c9dbf92b34311df629e7fe9 Mon Sep 17 00:00:00 2001 From: thorpej Date: Sun, 2 Aug 1998 04:41:32 +0000 Subject: [PATCH] Use a pool for proc structures. --- sys/compat/svr4/svr4_misc.c | 5 +++-- sys/kern/kern_exit.c | 5 +++-- sys/kern/kern_fork.c | 5 +++-- sys/kern/kern_proc.c | 6 +++++- sys/sys/proc.h | 4 +++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 25f9e0a1ba94..eaa1ac53be50 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_misc.c,v 1.60 1998/03/03 13:45:58 fvdl Exp $ */ +/* $NetBSD: svr4_misc.c,v 1.61 1998/08/02 04:41:33 thorpej Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -1306,7 +1307,7 @@ loop: * release while still running in process context. */ cpu_wait(q); - FREE(q, M_PROC); + pool_put(&proc_pool, q); nprocs--; return 0; } diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 416fcc656d20..83daff98f542 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.52 1998/07/31 22:50:49 perry Exp $ */ +/* $NetBSD: kern_exit.c,v 1.53 1998/08/02 04:41:32 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -381,7 +382,7 @@ loop: * release while still running in process context. */ cpu_wait(p); - FREE(p, M_PROC); + pool_put(&proc_pool, p); nprocs--; return (0); } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 64bb8c7fe5fd..f40aca51f9ad 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.43 1998/06/25 21:17:16 thorpej Exp $ */ +/* $NetBSD: kern_fork.c,v 1.44 1998/08/02 04:41:32 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -169,7 +170,7 @@ fork1(p1, flags, retval, rnewprocp) */ /* Allocate new proc. */ - MALLOC(newproc, struct proc *, sizeof(struct proc), M_PROC, M_WAITOK); + newproc = pool_get(&proc_pool, PR_WAITOK); /* * Find an unused process ID. We remember a range of unused IDs diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 72d34ebc512b..208920e5986a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.23 1998/03/01 02:22:29 fvdl Exp $ */ +/* $NetBSD: kern_proc.c,v 1.24 1998/08/02 04:41:32 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -73,6 +74,7 @@ struct pgrphashhead *pgrphashtbl; u_long pgrphash; struct proclist allproc; struct proclist zombproc; +struct pool proc_pool; static void orphanpg __P((struct pgrp *)); #ifdef DEBUG @@ -91,6 +93,8 @@ procinit() pidhashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pidhash); pgrphashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pgrphash); uihashtbl = hashinit(maxproc / 16, M_PROC, M_WAITOK, &uihash); + pool_init(&proc_pool, sizeof(struct proc), 0, 0, 0, "procpl", + 0, NULL, NULL, M_PROC); } /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 69a2203c2e40..587ed955d34e 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.60 1998/05/02 18:41:47 christos Exp $ */ +/* $NetBSD: proc.h,v 1.61 1998/08/02 04:41:32 thorpej Exp $ */ /*- * Copyright (c) 1986, 1989, 1991, 1993 @@ -303,6 +303,8 @@ extern struct proclist allproc; /* List of all processes. */ extern struct proclist zombproc; /* List of zombie processes. */ struct proc *initproc; /* Process slots for init, pager. */ +extern struct pool proc_pool; /* memory pool for procs */ + #define NQS 32 /* 32 run queues. */ int whichqs; /* Bit mask summary of non-empty Q's. */ struct prochd {