Bug #1008
closedmigrate lwp from zone to kmalloc
0%
Description
Hello,
After migrating struct proc from zone to kmalloc, I propose to do the same
with struct lwp. The rationale is similar: kmalloc is MP-safe and there
is not much state to cache so objcache seems over the top.
I'll commit the following patch in a couple of days if there are no objections.
Cheers,
Nicolas
Index: src2/sys/kern/kern_exit.c
===================================================================
--- src2.orig/sys/kern/kern_exit.c 2008-05-14 21:48:37.000000000 0200
++ src2/sys/kern/kern_exit.c 2008-05-16 22:22:56.000000000 0200@ -662,7 +662,7
@ lwp_dispose(struct lwp *lp)
lp->lwp_thread = NULL;
lwkt_free_thread(td);
}
- zfree(lwp_zone, lp);
kfree(lp, M_LWP);
}
===================================================================
--- src2.orig/sys/kern/kern_fork.c 2008-05-14 21:48:37.000000000 0200
++ src2/sys/kern/kern_fork.c 2008-05-16 22:22:56.000000000 +0200@ -556,8 +556,7
@ lwp_fork(struct lwp *origlp, struct proc
struct lwp *lp;
struct thread *td;
int
Index: src2/sys/kern/kern_fork.c
- lp = zalloc(lwp_zone);
- bzero(lp, sizeof(*lp));
+ lp = kmalloc(sizeof(struct lwp), M_LWP, M_WAITOK|M_ZERO);
===================================================================
--- src2.orig/sys/kern/kern_proc.c 2008-05-14 21:35:07.850537000 0200
++ src2/sys/kern/kern_proc.c 2008-05-16 22:22:57.000000000 +0200@ -59,6 +59,7
@
static MALLOC_DEFINE(M_PGRP, "pgrp", "process group header");
MALLOC_DEFINE(M_SESSION, "session", "session header");
MALLOC_DEFINE(M_PROC, "proc", "Proc structures");
+MALLOC_DEFINE(M_LWP, "lwp", "lwp structures");
MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures");
===================================================================
--- src2.orig/sys/sys/proc.h 2008-05-14 21:35:07.850961000 0200
++ src2/sys/sys/proc.h 2008-05-16 22:22:57.000000000 +0200@ -397,6 +397,7
@ struct proc {
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_SESSION);
MALLOC_DECLARE(M_PROC);
+MALLOC_DECLARE(M_LWP);
MALLOC_DECLARE(M_SUBPROC);
MALLOC_DECLARE(M_PARGS);
#endif@ -475,7 +476,6
@ struct vm_zone;
struct globaldata;
struct lwp_params;
extern struct vm_zone *proc_zone;
-extern struct vm_zone *lwp_zone;
int enterpgrp (struct proc *p, pid_t pgid, int mksess);
void proc_add_allproc(struct proc *p);
http://leaf.dragonflybsd.org/mailarchive/kernel/2008-03/msg00080.html