The zone from which proc structures are allocated is marked

UMA_ZONE_NOFREE to guarantee type stability, so proc_fini() should
never be called.  Move an assertion from proc_fini() to proc_dtor()
and garbage-collect the rest of the unreachable code.  I have retained
vm_proc_dispose(), since I consider its disuse a bug.
This commit is contained in:
David Schultz 2004-09-19 18:34:17 +00:00
parent 81d4eca1ef
commit 8daa8c602a
4 changed files with 10 additions and 34 deletions

View File

@ -153,6 +153,8 @@ proc_dtor(void *mem, int size, void *arg)
#ifdef INVARIANTS
KASSERT((p->p_numthreads == 1),
("bad number of threads in exiting process"));
KASSERT((p->p_numksegrps == 1), ("free proc with > 1 ksegrp"));
td = FIRST_THREAD_IN_PROC(p);
KASSERT((td != NULL), ("proc_dtor: bad thread pointer"));
kg = FIRST_KSEGRP_IN_PROC(p);
KASSERT((kg != NULL), ("proc_dtor: bad kg pointer"));
@ -190,27 +192,14 @@ proc_init(void *mem, int size, int flags)
}
/*
* Tear down type-stable parts of a proc (just before being discarded)
* UMA should ensure that this function is never called.
* Freeing a proc structure would violate type stability.
*/
static void
proc_fini(void *mem, int size)
{
struct proc *p;
struct thread *td;
struct ksegrp *kg;
p = (struct proc *)mem;
KASSERT((p->p_numthreads == 1),
("bad number of threads in freeing process"));
td = FIRST_THREAD_IN_PROC(p);
KASSERT((td != NULL), ("proc_fini: bad thread pointer"));
kg = FIRST_KSEGRP_IN_PROC(p);
KASSERT((kg != NULL), ("proc_fini: bad kg pointer"));
vm_proc_dispose(p);
sched_destroyproc(p);
thread_free(td);
ksegrp_free(kg);
mtx_destroy(&p->p_mtx);
panic("proc reclaimed");
}
/*

View File

@ -784,22 +784,6 @@ sched_newproc(struct proc *p, struct ksegrp *kg, struct thread *td)
sched_init_concurrency(kg);
}
/*
* Called by the uma process fini routine..
* undo anything we may have done in the uma_init method.
* Panic if it's not all 1:1:1:1
* Called from:
* proc_fini() (UMA method)
*/
void
sched_destroyproc(struct proc *p)
{
/* this function slated for destruction */
KASSERT((p->p_numthreads == 1), ("Cached proc with > 1 thread "));
KASSERT((p->p_numksegrps == 1), ("Cached proc with > 1 ksegrp "));
}
#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
/*
* thread is being either created or recycled.

View File

@ -108,11 +108,11 @@ sched_unpin(void)
/* temporarily here */
void schedinit(void);
void sched_destroyproc(struct proc *p);
void sched_init_concurrency(struct ksegrp *kg);
void sched_set_concurrency(struct ksegrp *kg, int cuncurrency);
void sched_schedinit(void);
void sched_newproc(struct proc *p, struct ksegrp *kg, struct thread *td);
void sched_thread_exit(struct thread *td);
void sched_newthread(struct thread *td);
#endif /* !_SYS_SCHED_H_ */

View File

@ -282,7 +282,10 @@ vm_proc_new(struct proc *p)
/*
* Dispose the U area for a process that has exited.
* This routine directly impacts the exit perf of a process.
* XXX proc_zone is marked UMA_ZONE_NOFREE, so this should never be called.
*
* XXX UNUSED
* U areas of free proc structures are no longer freed and are never
* swapped out. Ideally we would free U areas lazily, when low on memory.
*/
void
vm_proc_dispose(struct proc *p)