From 0c3967e7febd9b1c9cbbe632214ed2cc0c30dae7 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 14 Nov 2007 20:21:54 +0000 Subject: [PATCH] o Rename cpu_thread_setup() to cpu_thread_alloc() to better communicate that it relates to (is called by) thread_alloc() o Add cpu_thread_free() which is called from thread_free() to counter-act cpu_thread_alloc(). i386: Have cpu_thread_free() call cpu_thread_clean() to preserve behaviour. ia64: Have cpu_thread_free() call mtx_destroy() for the mutex initialized in cpu_thread_alloc(). PR: ia64/118024 --- sys/amd64/amd64/vm_machdep.c | 7 ++++++- sys/arm/arm/vm_machdep.c | 9 +++++++-- sys/i386/i386/vm_machdep.c | 9 ++++++++- sys/ia64/ia64/machdep.c | 2 +- sys/ia64/ia64/vm_machdep.c | 9 ++++++++- sys/kern/kern_thread.c | 4 ++-- sys/powerpc/aim/vm_machdep.c | 7 ++++++- sys/powerpc/powerpc/vm_machdep.c | 7 ++++++- sys/sparc64/sparc64/vm_machdep.c | 7 ++++++- sys/sun4v/sun4v/vm_machdep.c | 7 ++++++- sys/sys/proc.h | 3 ++- 11 files changed, 58 insertions(+), 13 deletions(-) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index c3c5283c86a9..aba0fad44dc5 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -240,7 +240,7 @@ cpu_thread_swapout(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { td->td_pcb = (struct pcb *)(td->td_kstack + @@ -248,6 +248,11 @@ cpu_thread_setup(struct thread *td) td->td_frame = (struct trapframe *)td->td_pcb - 1; } +void +cpu_thread_free(struct thread *td) +{ +} + /* * Initialize machine state (pcb and trap frame) for a new thread about to * upcall. Put enough state in the new thread's PCB to get it to go back diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c index 2e87030d1090..675927c4df6a 100644 --- a/sys/arm/arm/vm_machdep.c +++ b/sys/arm/arm/vm_machdep.c @@ -333,7 +333,7 @@ cpu_thread_exit(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { td->td_pcb = (struct pcb *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE) - 1; @@ -344,8 +344,13 @@ cpu_thread_setup(struct thread *td) pmap_use_minicache(td->td_kstack, td->td_kstack_pages * PAGE_SIZE); #endif #endif - } + +void +cpu_thread_free(struct thread *td) +{ +} + void cpu_thread_clean(struct thread *td) { diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index bbcdddfe500c..346d423e7a50 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -361,7 +361,7 @@ cpu_thread_swapout(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { td->td_pcb = (struct pcb *)(td->td_kstack + @@ -370,6 +370,13 @@ cpu_thread_setup(struct thread *td) td->td_pcb->pcb_ext = NULL; } +void +cpu_thread_free(struct thread *td) +{ + + cpu_thread_clean(td); +} + /* * Initialize machine state (pcb and trap frame) for a new thread about to * upcall. Put enough state in the new thread's PCB to get it to go back diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index b0854fcfd751..3c44b2e303c6 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -806,7 +806,7 @@ ia64_init(void) * and make proc0's trapframe pointer point to it for sanity. * Initialise proc0's backing store to start after u area. */ - cpu_thread_setup(&thread0); + cpu_thread_alloc(&thread0); thread0.td_frame->tf_flags = FRAME_SYSCALL; thread0.td_pcb->pcb_special.sp = (u_int64_t)thread0.td_frame - 16; diff --git a/sys/ia64/ia64/vm_machdep.c b/sys/ia64/ia64/vm_machdep.c index 40708c4ea8dc..42a17966a505 100644 --- a/sys/ia64/ia64/vm_machdep.c +++ b/sys/ia64/ia64/vm_machdep.c @@ -107,7 +107,7 @@ cpu_thread_clean(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { intptr_t sp; @@ -120,6 +120,13 @@ cpu_thread_setup(struct thread *td) mtx_init(&td->td_md.md_highfp_mtx, "High FP lock", NULL, MTX_SPIN); } +void +cpu_thread_free(struct thread *td) +{ + + mtx_destroy(&td->td_md.md_highfp_mtx); +} + void cpu_thread_swapin(struct thread *td) { diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index e1a27a5ae4c9..7fdfa20c443c 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -325,7 +325,7 @@ thread_alloc(void) uma_zfree(thread_zone, td); return (NULL); } - cpu_thread_setup(td); + cpu_thread_alloc(td); return (td); } @@ -337,7 +337,7 @@ void thread_free(struct thread *td) { - cpu_thread_clean(td); + cpu_thread_free(td); if (td->td_altkstack != 0) vm_thread_dispose_altkstack(td); if (td->td_kstack != 0) diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c index 1492a07a0af3..ce8416a827ea 100644 --- a/sys/powerpc/aim/vm_machdep.c +++ b/sys/powerpc/aim/vm_machdep.c @@ -277,7 +277,7 @@ cpu_thread_clean(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { struct pcb *pcb; @@ -287,6 +287,11 @@ cpu_thread_setup(struct thread *td) td->td_frame = (struct trapframe *)pcb - 1; } +void +cpu_thread_free(struct thread *td) +{ +} + void cpu_thread_swapin(struct thread *td) { diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c index 1492a07a0af3..ce8416a827ea 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/vm_machdep.c @@ -277,7 +277,7 @@ cpu_thread_clean(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { struct pcb *pcb; @@ -287,6 +287,11 @@ cpu_thread_setup(struct thread *td) td->td_frame = (struct trapframe *)pcb - 1; } +void +cpu_thread_free(struct thread *td) +{ +} + void cpu_thread_swapin(struct thread *td) { diff --git a/sys/sparc64/sparc64/vm_machdep.c b/sys/sparc64/sparc64/vm_machdep.c index fce7786313f5..2f4c0ea57bae 100644 --- a/sys/sparc64/sparc64/vm_machdep.c +++ b/sys/sparc64/sparc64/vm_machdep.c @@ -132,7 +132,7 @@ cpu_thread_clean(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { struct pcb *pcb; @@ -143,6 +143,11 @@ cpu_thread_setup(struct thread *td) td->td_pcb = pcb; } +void +cpu_thread_free(struct thread *td) +{ +} + void cpu_thread_swapin(struct thread *td) { diff --git a/sys/sun4v/sun4v/vm_machdep.c b/sys/sun4v/sun4v/vm_machdep.c index fbfa4a06d20d..63a002f5e50d 100644 --- a/sys/sun4v/sun4v/vm_machdep.c +++ b/sys/sun4v/sun4v/vm_machdep.c @@ -111,7 +111,7 @@ cpu_thread_clean(struct thread *td) } void -cpu_thread_setup(struct thread *td) +cpu_thread_alloc(struct thread *td) { struct pcb *pcb; @@ -126,6 +126,11 @@ cpu_thread_setup(struct thread *td) } +void +cpu_thread_free(struct thread *td) +{ +} + void cpu_thread_swapin(struct thread *td) { diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 8e0b90e14f6e..eaf6f03c43d9 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -877,9 +877,10 @@ void upcall_remove(struct thread *td); void cpu_set_upcall(struct thread *td, struct thread *td0); void cpu_set_upcall_kse(struct thread *, void (*)(void *), void *, stack_t *); int cpu_set_user_tls(struct thread *, void *tls_base); +void cpu_thread_alloc(struct thread *); void cpu_thread_clean(struct thread *); void cpu_thread_exit(struct thread *); -void cpu_thread_setup(struct thread *td); +void cpu_thread_free(struct thread *); void cpu_thread_swapin(struct thread *); void cpu_thread_swapout(struct thread *); struct thread *thread_alloc(void);