From e102a9b6dd829c7b39358e1bed4ae6be3a6758d7 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 24 Jun 2002 15:48:02 +0000 Subject: [PATCH] Add an MD callout like cpu_exit, but which is called after sched_lock is obtained, when all other scheduling activity is suspended. This is needed on sparc64 to deactivate the vmspace of the exiting process on all cpus. Otherwise if another unrelated process gets the exact same vmspace structure allocated to it (same address), its address space will not be activated properly. This seems to fix some spontaneous signal 11 problems with smp on sparc64. --- sys/alpha/alpha/vm_machdep.c | 6 ++++++ sys/amd64/amd64/vm_machdep.c | 6 ++++++ sys/i386/i386/vm_machdep.c | 6 ++++++ sys/ia64/ia64/vm_machdep.c | 6 ++++++ sys/kern/kern_exit.c | 1 + sys/powerpc/aim/vm_machdep.c | 6 ++++++ sys/powerpc/powerpc/vm_machdep.c | 6 ++++++ sys/sparc64/sparc64/vm_machdep.c | 22 ++++++++++++++++++++++ sys/sys/proc.h | 1 + 9 files changed, 60 insertions(+) diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index 4209cce55a96..e57593c5ef3b 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -247,6 +247,12 @@ cpu_exit(td) alpha_fpstate_drop(td); } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(p) struct proc *p; diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index a7e852a88955..5dc2e148c8d4 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -282,6 +282,12 @@ cpu_exit(td) } } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(p) struct proc *p; diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index a7e852a88955..5dc2e148c8d4 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -282,6 +282,12 @@ cpu_exit(td) } } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(p) struct proc *p; diff --git a/sys/ia64/ia64/vm_machdep.c b/sys/ia64/ia64/vm_machdep.c index 7a5c327da3f7..24ea100c8d3a 100644 --- a/sys/ia64/ia64/vm_machdep.c +++ b/sys/ia64/ia64/vm_machdep.c @@ -313,6 +313,12 @@ cpu_exit(td) ia64_fpstate_drop(td); } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(p) struct proc *p; diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index d35b3e136a5e..fab943756245 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -448,6 +448,7 @@ exit1(td, rv) binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); + cpu_sched_exit(td); cpu_throw(); panic("exit1"); } diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c index 12aeaf2c2af0..fe9cab7b1b4e 100644 --- a/sys/powerpc/aim/vm_machdep.c +++ b/sys/powerpc/aim/vm_machdep.c @@ -208,6 +208,12 @@ cpu_exit(td) { } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(td) struct proc *td; diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c index 12aeaf2c2af0..fe9cab7b1b4e 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/vm_machdep.c @@ -208,6 +208,12 @@ cpu_exit(td) { } +void +cpu_sched_exit(td) + register struct thread *td; +{ +} + void cpu_wait(td) struct proc *td; diff --git a/sys/sparc64/sparc64/vm_machdep.c b/sys/sparc64/sparc64/vm_machdep.c index 9fd910b3fab2..a896754ddfdf 100644 --- a/sys/sparc64/sparc64/vm_machdep.c +++ b/sys/sparc64/sparc64/vm_machdep.c @@ -86,6 +86,28 @@ cpu_exit(struct thread *td) } } +void +cpu_sched_exit(struct thread *td) +{ + struct vmspace *vm; + struct pcpu *pc; + struct proc *p; + + mtx_assert(&sched_lock, MA_OWNED); + + p = td->td_proc; + vm = p->p_vmspace; + if (vm->vm_refcnt > 1) + return; + SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + if (pc->pc_vmspace == vm) { + vm->vm_pmap.pm_active &= ~pc->pc_cpumask; + vm->vm_pmap.pm_context[pc->pc_cpuid] = -1; + pc->pc_vmspace = NULL; + } + } +} + /* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 9f3789816998..f37ade737b46 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -752,6 +752,7 @@ void userret(struct thread *, struct trapframe *, u_int); void maybe_resched(struct thread *); void cpu_exit(struct thread *); +void cpu_sched_exit(struct thread *); void exit1(struct thread *, int) __dead2; void cpu_fork(struct thread *, struct proc *, struct thread *, int); void cpu_set_fork_handler(struct thread *, void (*)(void *), void *);