From: Nicolas Thery Date: Tue, 1 Apr 2008 18:06:34 +0000 (+0000) Subject: Migrate allocation of proc structures from zones to kmalloc(). This gives us X-Git-Tag: v2.0.1~897 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/fb2a331e81488b92fa9632684279c9508cd58655 Migrate allocation of proc structures from zones to kmalloc(). This gives us MP-safety and does not seem to decrease performance (using make buildworld as benchmark). Using an objcache seems unnecessary because there isn't much pre-initialization code we could move to a constructor and there is no performance gain. Debatted-With: dillon@, hsu@, corecode@ --- diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 0b037f15b8..f337c19072 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.88 2008/03/21 19:42:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.89 2008/04/01 18:06:34 nth Exp $ */ #include "opt_compat.h" @@ -834,7 +834,7 @@ loop: } vm_waitproc(p); - zfree(proc_zone, p); + kfree(p, M_PROC); nprocs--; return (0); } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 636748a03d..9cd2fa032f 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -37,7 +37,7 @@ * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 * $FreeBSD: src/sys/kern/kern_fork.c,v 1.72.2.14 2003/06/26 04:15:10 silby Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.71 2007/08/15 03:15:06 dillon Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.72 2008/04/01 18:06:34 nth Exp $ */ #include "opt_ktrace.h" @@ -332,7 +332,7 @@ fork1(struct lwp *lp1, int flags, struct proc **procp) } /* Allocate new proc. */ - p2 = zalloc(proc_zone); + p2 = kmalloc(sizeof(struct proc), M_PROC, M_WAITOK); bzero(p2, sizeof(*p2)); /* diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 1ea9e9faba..6ef80705a7 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -32,7 +32,7 @@ * * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 * $FreeBSD: src/sys/kern/kern_proc.c,v 1.63.2.9 2003/05/08 07:47:16 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_proc.c,v 1.41 2008/01/04 12:16:19 matthias Exp $ + * $DragonFly: src/sys/kern/kern_proc.c,v 1.42 2008/04/01 18:06:34 nth Exp $ */ #include @@ -58,7 +58,7 @@ static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header"); MALLOC_DEFINE(M_SESSION, "session", "session header"); -static MALLOC_DEFINE(M_PROC, "proc", "Proc structures"); +MALLOC_DEFINE(M_PROC, "proc", "Proc structures"); MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures"); int ps_showallprocs = 1; @@ -84,7 +84,6 @@ u_long pgrphash; struct proclist allproc; struct proclist zombproc; struct spinlock allproc_spin; -vm_zone_t proc_zone; vm_zone_t lwp_zone; vm_zone_t thread_zone; @@ -131,7 +130,6 @@ procinit(void) spin_init(&allproc_spin); pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash); pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash); - proc_zone = zinit("PROC", sizeof (struct proc), 0, 0, 5); lwp_zone = zinit("LWP", sizeof (struct lwp), 0, 0, 5); thread_zone = zinit("THREAD", sizeof (struct thread), 0, 0, 5); uihashinit(); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index bd98f636e3..278c574c4a 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.115 2007/12/06 22:15:06 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.116 2008/04/01 18:06:34 nth Exp $ */ #ifndef _SYS_PROC_H_ @@ -396,6 +396,7 @@ struct proc { #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_SESSION); +MALLOC_DECLARE(M_PROC); MALLOC_DECLARE(M_SUBPROC); MALLOC_DECLARE(M_PARGS); #endif