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:
parent
e804e4b013
commit
b19d9defef
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -117,6 +117,11 @@ cpu_thread_exit(struct thread *td)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cpu_thread_dtor(struct thread *td)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cpu_thread_setup(struct thread *td)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -113,6 +113,11 @@ cpu_thread_exit(struct thread *td)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cpu_thread_dtor(struct thread *td)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cpu_thread_setup(struct thread *td)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user