From d20c30720bd75946190688b47500e9780baef631 Mon Sep 17 00:00:00 2001 From: alc Date: Sat, 14 Jun 2003 06:20:25 +0000 Subject: Move the *_new_altkstack() and *_dispose_altkstack() functions out of the various pmap implementations into the machine-independent vm. They were all identical. --- sys/alpha/alpha/pmap.c | 29 ----------------------------- sys/amd64/amd64/pmap.c | 30 ------------------------------ sys/i386/i386/pmap.c | 30 ------------------------------ sys/ia64/ia64/pmap.c | 26 -------------------------- sys/kern/kern_fork.c | 2 +- sys/kern/kern_proc.c | 2 +- sys/powerpc/aim/mmu_oea.c | 25 ------------------------- sys/powerpc/powerpc/mmu_oea.c | 25 ------------------------- sys/powerpc/powerpc/pmap.c | 25 ------------------------- sys/sparc64/sparc64/pmap.c | 28 ---------------------------- sys/vm/pmap.h | 2 -- sys/vm/vm_extern.h | 2 ++ sys/vm/vm_glue.c | 31 +++++++++++++++++++++++++++++++ 13 files changed, 35 insertions(+), 222 deletions(-) diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c index 94cf81b..0823885 100644 --- a/sys/alpha/alpha/pmap.c +++ b/sys/alpha/alpha/pmap.c @@ -1064,35 +1064,6 @@ pmap_dispose_thread(td) } /* - * Set up a variable sized alternate kstack. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Allow the kernel stack for a thread to be prejudicially paged out. */ void diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index d3cdb59..38a5f5b 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -997,36 +997,6 @@ pmap_dispose_thread(td) } /* - * Set up a variable sized alternate kstack. Though it may look MI, it may - * need to be different on certain arches like ia64. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Allow the Kernel stack for a thread to be prejudicially paged out. */ void diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index c913570..c9a910e 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1100,36 +1100,6 @@ pmap_dispose_thread(td) } /* - * Set up a variable sized alternate kstack. Though it may look MI, it may - * need to be different on certain arches like ia64. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Allow the Kernel stack for a thread to be prejudicially paged out. */ void diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 2e9d472..dd6ba1d 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -797,32 +797,6 @@ pmap_dispose_thread(struct thread *td) } /* - * Set up a variable sized alternate kstack. This appears to be MI. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - - td->td_altkstack = td->td_kstack; - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack_pages = td->td_kstack_pages; - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - - pmap_dispose_thread(td); - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Allow the KSTACK for a thread to be prejudicially paged out. */ void diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index e9e38ab..4c514df 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -460,7 +460,7 @@ again: /* Allocate and switch to an alternate kstack if specified */ if (pages != 0) - pmap_new_altkstack(td2, pages); + vm_thread_new_altkstack(td2, pages); PROC_LOCK(p2); PROC_LOCK(p1); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 548f097..c798b68 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -168,7 +168,7 @@ proc_dtor(void *mem, int size, void *arg) * freed, so you gotta do this here. */ if (((p->p_flag & P_KTHREAD) != 0) && (td->td_altkstack != 0)) - pmap_dispose_altkstack(td); + vm_thread_dispose_altkstack(td); /* * We want to make sure we know the initial linkages. diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index 0052881..4808b4d 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -1653,31 +1653,6 @@ pmap_dispose_thread(struct thread *td) } void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -void pmap_swapin_thread(struct thread *td) { vm_page_t ma[KSTACK_MAX_PAGES]; diff --git a/sys/powerpc/powerpc/mmu_oea.c b/sys/powerpc/powerpc/mmu_oea.c index 0052881..4808b4d 100644 --- a/sys/powerpc/powerpc/mmu_oea.c +++ b/sys/powerpc/powerpc/mmu_oea.c @@ -1653,31 +1653,6 @@ pmap_dispose_thread(struct thread *td) } void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -void pmap_swapin_thread(struct thread *td) { vm_page_t ma[KSTACK_MAX_PAGES]; diff --git a/sys/powerpc/powerpc/pmap.c b/sys/powerpc/powerpc/pmap.c index 0052881..4808b4d 100644 --- a/sys/powerpc/powerpc/pmap.c +++ b/sys/powerpc/powerpc/pmap.c @@ -1653,31 +1653,6 @@ pmap_dispose_thread(struct thread *td) } void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -void pmap_swapin_thread(struct thread *td) { vm_page_t ma[KSTACK_MAX_PAGES]; diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index c58d4b4..4e30859 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -1031,34 +1031,6 @@ pmap_dispose_thread(struct thread *td) } /* - * Set up a variable sized alternate kstack. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - -/* * Allow the kernel stack for a thread to be prejudicially paged out. */ void diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h index 1a1e232..36ca187 100644 --- a/sys/vm/pmap.h +++ b/sys/vm/pmap.h @@ -131,8 +131,6 @@ void pmap_prefault(pmap_t, vm_offset_t, vm_map_entry_t); int pmap_mincore(pmap_t pmap, vm_offset_t addr); void pmap_new_thread(struct thread *td, int pages); void pmap_dispose_thread(struct thread *td); -void pmap_new_altkstack(struct thread *td, int pages); -void pmap_dispose_altkstack(struct thread *td); void pmap_swapout_thread(struct thread *td); void pmap_swapin_thread(struct thread *td); void pmap_activate(struct thread *td); diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index eafc300..4718eff 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -96,5 +96,7 @@ void vm_object_print(/* db_expr_t */ long, boolean_t, /* db_expr_t */ long, int vm_fault_quick(caddr_t v, int prot); void vm_proc_new(struct proc *p); void vm_proc_dispose(struct proc *p); +void vm_thread_new_altkstack(struct thread *td, int pages); +void vm_thread_dispose_altkstack(struct thread *td); #endif /* _KERNEL */ #endif /* !_VM_EXTERN_H_ */ diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index ec15d96..2145c0c 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -388,6 +388,37 @@ retry: #endif /* + * Set up a variable-sized alternate kstack. + */ +void +vm_thread_new_altkstack(struct thread *td, int pages) +{ + + td->td_altkstack = td->td_kstack; + td->td_altkstack_obj = td->td_kstack_obj; + td->td_altkstack_pages = td->td_kstack_pages; + + pmap_new_thread(td, pages); +} + +/* + * Restore the original kstack. + */ +void +vm_thread_dispose_altkstack(struct thread *td) +{ + + pmap_dispose_thread(td); + + td->td_kstack = td->td_altkstack; + td->td_kstack_obj = td->td_altkstack_obj; + td->td_kstack_pages = td->td_altkstack_pages; + td->td_altkstack = 0; + td->td_altkstack_obj = NULL; + td->td_altkstack_pages = 0; +} + +/* * Implement fork's actions on an address space. * Here we arrange for the address space to be copied or referenced, * allocate a user struct (pcb and kernel stack), then call the -- cgit v1.1