Bug #1008

migrate lwp from zone to kmalloc

Added by nthery over 6 years ago. Updated over 6 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:nthery% Done:

0%

Category:-
Target version:-

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);
}

int
Index: src2/sys/kern/kern_fork.c
===================================================================
--- 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;

- lp = zalloc(lwp_zone);
- bzero(lp, sizeof(*lp));
+ lp = kmalloc(sizeof(struct lwp), M_LWP, M_WAITOK|M_ZERO);

lp->lwp_proc = destproc;
lp->lwp_vmspace = destproc->p_vmspace;
Index: src2/sys/kern/kern_proc.c
===================================================================
--- 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");

int ps_showallprocs = 1;
@@ -84,7 +85,6 @@ u_long pgrphash;
struct proclist allproc;
struct proclist zombproc;
struct spinlock allproc_spin;
-vm_zone_t lwp_zone;
vm_zone_t thread_zone;

/*
@@ -130,7 +130,6 @@ procinit(void)
spin_init(&allproc_spin);
pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash);
pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
- lwp_zone = zinit("LWP", sizeof (struct lwp), 0, 0, 5);
thread_zone = zinit("THREAD", sizeof (struct thread), 0, 0, 5);
uihashinit();
}
Index: src2/sys/sys/proc.h
===================================================================
--- 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

History

#1 Updated by nthery over 6 years ago

committed

Also available in: Atom PDF