Under certain circumstances, we were calling kmem_free() from

i386 cpu_thread_exit().  This resulted in a panic with WITNESS
since we need to hold Giant to call kmem_free(), and we weren't
helding it anymore in cpu_thread_exit().  We now do this from a
new MD function, cpu_thread_dtor(), called by thread_dtor().

Approved by:	re@
Suggested by:	jhb
This commit is contained in:
Maxime Henrion 2002-11-22 23:57:02 +00:00
parent e804e4b013
commit b19d9defef
10 changed files with 70 additions and 22 deletions

View File

@ -260,6 +260,11 @@ cpu_thread_exit(struct thread *td)
return;
}
void
cpu_thread_dtor(struct thread *td)
{
}
void
cpu_thread_setup(struct thread *td)
{

View File

@ -272,17 +272,6 @@ cpu_thread_exit(struct thread *td)
#ifdef DEV_NPX
npxexit(td);
#endif
if (pcb->pcb_ext != 0) {
/* XXXKSE XXXSMP not SMP SAFE.. what locks do we have? */
/* if (pcb->pcb_ext->ext_refcount-- == 1) ?? */
/*
* XXX do we need to move the TSS off the allocated pages
* before freeing them? (not done here)
*/
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ext,
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
if (pcb->pcb_flags & PCB_DBREGS) {
/*
* disable all hardware breakpoints
@ -292,6 +281,25 @@ cpu_thread_exit(struct thread *td)
}
}
void
cpu_thread_dtor(struct thread *td)
{
struct pcb *pcb;
pcb = td->td_pcb;
if (pcb->pcb_ext != 0) {
/* XXXKSE XXXSMP not SMP SAFE.. what locks do we have? */
/* if (pcb->pcb_ext->ext_refcount-- == 1) ?? */
/*
* XXX do we need to move the TSS off the allocated pages
* before freeing them? (not done here)
*/
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ext,
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
}
void
cpu_sched_exit(td)
register struct thread *td;

View File

@ -272,17 +272,6 @@ cpu_thread_exit(struct thread *td)
#ifdef DEV_NPX
npxexit(td);
#endif
if (pcb->pcb_ext != 0) {
/* XXXKSE XXXSMP not SMP SAFE.. what locks do we have? */
/* if (pcb->pcb_ext->ext_refcount-- == 1) ?? */
/*
* XXX do we need to move the TSS off the allocated pages
* before freeing them? (not done here)
*/
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ext,
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
if (pcb->pcb_flags & PCB_DBREGS) {
/*
* disable all hardware breakpoints
@ -292,6 +281,25 @@ cpu_thread_exit(struct thread *td)
}
}
void
cpu_thread_dtor(struct thread *td)
{
struct pcb *pcb;
pcb = td->td_pcb;
if (pcb->pcb_ext != 0) {
/* XXXKSE XXXSMP not SMP SAFE.. what locks do we have? */
/* if (pcb->pcb_ext->ext_refcount-- == 1) ?? */
/*
* XXX do we need to move the TSS off the allocated pages
* before freeing them? (not done here)
*/
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ext,
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
}
void
cpu_sched_exit(td)
register struct thread *td;

View File

@ -117,6 +117,11 @@ cpu_thread_exit(struct thread *td)
{
}
void
cpu_thread_dtor(struct thread *td)
{
}
void
cpu_thread_setup(struct thread *td)
{

View File

@ -115,6 +115,7 @@ thread_dtor(void *mem, int size, void *arg)
{
struct thread *td;
mtx_assert(&Giant, MA_OWNED);
td = (struct thread *)mem;
#ifdef INVARIANTS
@ -137,6 +138,8 @@ thread_dtor(void *mem, int size, void *arg)
/* NOTREACHED */
}
#endif
cpu_thread_dtor(td);
}
/*

View File

@ -115,6 +115,7 @@ thread_dtor(void *mem, int size, void *arg)
{
struct thread *td;
mtx_assert(&Giant, MA_OWNED);
td = (struct thread *)mem;
#ifdef INVARIANTS
@ -137,6 +138,8 @@ thread_dtor(void *mem, int size, void *arg)
/* NOTREACHED */
}
#endif
cpu_thread_dtor(td);
}
/*

View File

@ -353,6 +353,11 @@ cpu_thread_exit(struct thread *td)
return;
}
void
cpu_thread_dtor(struct thread *td)
{
}
void
cpu_thread_setup(struct thread *td)
{

View File

@ -353,6 +353,11 @@ cpu_thread_exit(struct thread *td)
return;
}
void
cpu_thread_dtor(struct thread *td)
{
}
void
cpu_thread_setup(struct thread *td)
{

View File

@ -113,6 +113,11 @@ cpu_thread_exit(struct thread *td)
{
}
void
cpu_thread_dtor(struct thread *td)
{
}
void
cpu_thread_setup(struct thread *td)
{

View File

@ -905,6 +905,7 @@ void kse_free(struct kse *ke);
void kse_stash(struct kse *ke);
void cpu_set_upcall(struct thread *td, void *pcb);
void cpu_set_upcall_kse(struct thread *td, struct kse *ke);
void cpu_thread_dtor(struct thread *);
void cpu_thread_exit(struct thread *);
void cpu_thread_setup(struct thread *td);
void kse_reassign(struct kse *ke);