diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s index a378c1643fee..7968b3183677 100644 --- a/sys/arch/alpha/alpha/locore.s +++ b/sys/arch/alpha/alpha/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.48 1998/05/19 18:35:11 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.49 1998/09/09 00:07:48 thorpej Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.48 1998/05/19 18:35:11 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.49 1998/09/09 00:07:48 thorpej Exp $"); #ifndef EVCNT_COUNTERS #include @@ -800,9 +800,10 @@ LEAF(switch_trampoline, 0) /* * switch_exit(struct proc *p) - * Make a the named process exit. Partially switch to proc0, unmap - * the old proc's user struct, and jump into the middle of cpu_switch - * to switch into a few process. MUST BE CALLED AT SPLHIGH. + * Make a the named process exit. Partially switch to proc0 (we don't + * update curproc or restore registers), and jump into the middle of + * cpu_switch to switch into a few process. The process reaper will + * free the dead process's VM resources. MUST BE CALLED AT SPLHIGH. */ LEAF(switch_exit, 1) LDGP(pv) @@ -825,15 +826,9 @@ LEAF(switch_exit, 1) * the saved regs. */ - /* blow away the old user struct */ - ldq a0, kernel_map - ldq a1, P_ADDR(s2) - ldiq a2, (UPAGES * NBPG) -#if defined(UVM) - CALL(uvm_km_free) -#else - CALL(kmem_free) -#endif + /* Schedule the vmspace and stack to be freed. */ + mov s2, a0 + CALL(exit2) /* * Now jump back into the middle of cpu_switch(). Note that diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index 892c2a08a372..c80937f9eaca 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.37 1998/08/14 16:50:02 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.38 1998/09/09 00:07:48 thorpej Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -31,7 +31,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.37 1998/08/14 16:50:02 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.38 1998/09/09 00:07:48 thorpej Exp $"); #include #include @@ -108,10 +108,9 @@ cpu_coredump(p, vp, cred, chdr) /* * cpu_exit is called as the last action during exit. - * We release the address space of the process, block interrupts, - * and call switch_exit. switch_exit switches to proc0's PCB and stack, - * then jumps into the middle of cpu_switch, as if it were switching - * from proc0. + * We block interrupts and call switch_exit. switch_exit switches + * to proc0's PCB and stack, then jumps into the middle of cpu_switch, + * as if it were switching from proc0. */ void cpu_exit(p) @@ -129,12 +128,6 @@ cpu_exit(p) */ pmap_deactivate(p); -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - (void) splhigh(); switch_exit(p); /* NOTREACHED */ diff --git a/sys/arch/amiga/amiga/locore.s b/sys/arch/amiga/amiga/locore.s index 5d5fc1de4817..8c8053634c88 100644 --- a/sys/arch/amiga/amiga/locore.s +++ b/sys/arch/amiga/amiga/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.98 1998/07/10 20:24:05 mhitch Exp $ */ +/* $NetBSD: locore.s,v 1.99 1998/09/09 00:07:49 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1152,23 +1152,18 @@ pcbflag: /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's user area. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 movl #nullpcb,_curpcb | save state into garbage pcb lea tmpstk,sp | goto a tmp stack - /* Free old process's user area. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address u-area of process - movl _kernel_map,sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _cpu_switch diff --git a/sys/arch/amiga/amiga/vm_machdep.c b/sys/arch/amiga/amiga/vm_machdep.c index 93505ee59711..b247cfae2544 100644 --- a/sys/arch/amiga/amiga/vm_machdep.c +++ b/sys/arch/amiga/amiga/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.37 1998/07/28 18:34:53 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.38 1998/09/09 00:07:49 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -135,21 +135,15 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, + * * Block context switches and then call switch_exit() which will - * free our stack and user area and switch to another process - * thus we never return. + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - + (void)splhigh(); #if defined(UVM) uvmexp.swtch++; diff --git a/sys/arch/arm32/arm32/cpuswitch.S b/sys/arch/arm32/arm32/cpuswitch.S index 37801b374a3d..0ca0ee1eb65a 100644 --- a/sys/arch/arm32/arm32/cpuswitch.S +++ b/sys/arch/arm32/arm32/cpuswitch.S @@ -1,4 +1,4 @@ -/* $NetBSD: cpuswitch.S,v 1.27 1998/08/16 02:17:17 mark Exp $ */ +/* $NetBSD: cpuswitch.S,v 1.28 1998/09/09 00:07:49 thorpej Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -649,27 +649,10 @@ Lse_context_switched: str r3, [sp, #-0x0004]! /* - * Have to wait until we have switched to proc0 as the - * pmap gets released in vmspace_free() + * Schedule the vmspace and stack to be freed. */ - ldr r0, [r3, #(P_VMSPACE)] -#if defined(UVM) - bl _uvmspace_free -#else - bl _vmspace_free -#endif - - /* This has to be done here */ - mov r2, #(UPAGES << PGSHIFT) - ldr r0, [sp], #0x0004 - ldr r1, [r0, #(P_ADDR)] - ldr r0, Lkernel_map - ldr r0, [r0] -#if defined(UVM) - bl _uvm_km_free -#else - bl _kmem_free -#endif + mov r0, r3 /* exit2(p) */ + bl _exit2 /* Paranoia */ mov r0, #0x00000000 diff --git a/sys/arch/arm32/arm32/vm_machdep.c b/sys/arch/arm32/arm32/vm_machdep.c index 8e5e204bea4f..fc33e76e8a5e 100644 --- a/sys/arch/arm32/arm32/vm_machdep.c +++ b/sys/arch/arm32/arm32/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.29 1998/08/27 04:00:53 mark Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.30 1998/09/09 00:07:49 thorpej Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -193,10 +193,8 @@ cpu_set_kpc(p, pc) * cpu_exit is called as the last action during exit. * * We clean up a little and then call switch_exit() with the old proc as an - * argument. switch_exit() first switches to proc0's context, then does the - * vmspace_free() and kmem_free() (or their UVM counterparts) that we don't - * do here, and finally jumps into switch() to wait for another process - * to wake up. + * argument. switch_exit() first switches to proc0's context, and finally + * jumps into switch() to wait for another process to wake up. */ void diff --git a/sys/arch/atari/atari/locore.s b/sys/arch/atari/atari/locore.s index c7a7f703413c..a9ffc3acc7b6 100644 --- a/sys/arch/atari/atari/locore.s +++ b/sys/arch/atari/atari/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.52 1998/07/04 22:18:21 jonathan Exp $ */ +/* $NetBSD: locore.s,v 1.53 1998/09/09 00:07:50 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1103,23 +1103,18 @@ pcbflag: /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's user area. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 movl #nullpcb,_curpcb | save state into garbage pcb lea tmpstk,sp | goto a tmp stack - /* Free old process's user area. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _kernel_map,sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _cpu_switch diff --git a/sys/arch/atari/atari/vm_machdep.c b/sys/arch/atari/atari/vm_machdep.c index 2624e491da9c..7bdf638af71d 100644 --- a/sys/arch/atari/atari/vm_machdep.c +++ b/sys/arch/atari/atari/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.18 1998/09/02 14:58:03 leo Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.19 1998/09/09 00:07:50 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -131,21 +131,15 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, + * * Block context switches and then call switch_exit() which will - * free our stack and user area and switch to another process - * thus we never return. + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - + (void)splhigh(); #if defined(UVM) uvmexp.swtch++; diff --git a/sys/arch/bebox/bebox/locore.s b/sys/arch/bebox/bebox/locore.s index c7231e997990..4b966bf8dbd6 100644 --- a/sys/arch/bebox/bebox/locore.s +++ b/sys/arch/bebox/bebox/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.7 1998/07/04 22:18:22 jonathan Exp $ */ +/* $NetBSD: locore.s,v 1.8 1998/09/09 00:07:50 thorpej Exp $ */ /* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */ /* @@ -194,8 +194,7 @@ ASENTRY(Idle) b _ASM_LABEL(Idle) /* - * switchexit gets called from cpu_exit to free the user structure - * and kernel stack of the current process. + * switchexit gets called from cpu_exit to complete the exit procedure. */ ENTRY(switchexit) /* First switch to the idle pcb/kernel stack */ @@ -204,12 +203,12 @@ ENTRY(switchexit) lis 7,_C_LABEL(curpcb)@ha stw 6,_C_LABEL(curpcb)@l(7) addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */ -/* Now free the old user structure (args are already in r3, r4, r5) */ -#if defined(UVM) - bl _C_LABEL(uvm_km_free) -#else - bl _C_LABEL(kmem_free) -#endif + /* + * Schedule the vmspace and stack to be freed (the proc arg is + * already in r3). + */ + bl _C_LABEL(exit2) + /* Fall through to cpu_switch to actually select another proc */ li 3,0 /* indicate exited process */ diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index 643281cf05e2..e658e44639fe 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.87 1998/07/04 22:18:23 jonathan Exp $ */ +/* $NetBSD: locore.s,v 1.88 1998/09/09 00:07:51 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -1195,7 +1195,8 @@ ASBSS(nullpcb,SIZEOF_PCB) /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 @@ -1203,16 +1204,10 @@ ENTRY(switch_exit) movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb) lea _ASM_LABEL(tmpstk),sp | goto a tmp stack - /* Free old process's resources. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _C_LABEL(cpu_switch) diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index 624bbd698de2..29e339ffa43c 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.42 1998/08/20 08:33:47 kleink Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.43 1998/09/09 00:07:51 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -116,24 +116,16 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call switch_exit, which switches to a temporary - * pcb and stack and never returns. We block memory allocation - * until switch_exit has made things safe again. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - - (void) splimp(); + (void) splhigh(); #if defined(UVM) uvmexp.swtch++; #else diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 60a85f04120f..29727277f37f 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.199 1998/08/15 05:10:23 mycroft Exp $ */ +/* $NetBSD: locore.s,v 1.200 1998/09/09 00:07:52 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -2111,24 +2111,15 @@ ENTRY(switch_exit) /* Interrupts are okay again. */ sti - /* Thoroughly nuke the old process's resources. */ - pushl P_ADDR(%edi) + /* + * Nuke the TSS and schedule the dead process's + * vmspace and stack to be freed. + */ + pushl P_ADDR(%edi) /* tss_free(p->p_addr) */ call _tss_free - pushl P_VMSPACE(%edi) -#if defined(UVM) - call _uvmspace_free -#else - call _vmspace_free -#endif - pushl $USPACE - pushl P_ADDR(%edi) - pushl _kernel_map -#if defined(UVM) - call _uvm_km_free -#else - call _kmem_free -#endif - addl $20,%esp + pushl %edi /* exit2(p) */ + call _exit2 + addl $8,%esp /* Jump into cpu_switch() with the right state. */ movl %ebx,%esi diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index ad38c11c36c1..ced61ed716ce 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.71 1998/08/13 21:36:04 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.72 1998/09/09 00:07:52 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -188,9 +188,8 @@ cpu_swapout(p) * cpu_exit is called as the last action during exit. * * We clean up a little and then call switch_exit() with the old proc as an - * argument. switch_exit() first switches to proc0's context, then does the - * vmspace_free() and uvm_km_free() that we don't do here, and finally jumps - * into switch() to wait for another process to wake up. + * argument. switch_exit() first switches to proc0's context, and finally + * jumps into switch() to wait for another process to wake up. */ void cpu_exit(p) diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s index 90271df7b2e3..98dc365b22f4 100644 --- a/sys/arch/mac68k/mac68k/locore.s +++ b/sys/arch/mac68k/mac68k/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.106 1998/08/16 22:29:03 scottr Exp $ */ +/* $NetBSD: locore.s,v 1.107 1998/09/09 00:07:52 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1029,7 +1029,8 @@ ASBSS(nullpcb,SIZEOF_PCB) /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 @@ -1037,16 +1038,10 @@ ENTRY(switch_exit) movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb) lea _ASM_LABEL(tmpstk),sp | goto a tmp stack - /* Free old process's resources. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _C_LABEL(cpu_switch) diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c index 7ebf6cf2b08d..ea49f327866d 100644 --- a/sys/arch/mac68k/mac68k/vm_machdep.c +++ b/sys/arch/mac68k/mac68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.29 1998/07/28 18:34:55 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.30 1998/09/09 00:07:52 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -141,20 +141,14 @@ void switch_exit __P((struct proc *)); /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * block context switches and then call switch_exit() which will - * free our stack and user area and switch to another process. - * Thus, we never return. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ -volatile void +void cpu_exit(p) struct proc *p; { -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif (void)splhigh(); #if defined(UVM) @@ -163,7 +157,6 @@ cpu_exit(p) cnt.v_swtch++; #endif switch_exit(p); - for(;;); /* Get rid of a compile warning */ /* NOTREACHED */ } diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S index af36eaba04d5..bf7f8e768fff 100644 --- a/sys/arch/macppc/macppc/locore.S +++ b/sys/arch/macppc/macppc/locore.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.5 1998/07/21 17:53:50 tsubai Exp $ */ +/* $NetBSD: locore.S,v 1.6 1998/09/09 00:07:53 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -278,8 +278,7 @@ ASENTRY(Idle) b _ASM_LABEL(Idle) /* - * switchexit gets called from cpu_exit to free the user structure - * and kernel stack of the current process. + * switchexit gets called from cpu_exit to complete the exit procedure. */ ENTRY(switchexit) /* First switch to the idle pcb/kernel stack */ @@ -288,12 +287,12 @@ ENTRY(switchexit) lis 7,_C_LABEL(curpcb)@ha stw 6,_C_LABEL(curpcb)@l(7) addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */ -/* Now free the old user structure (args are already in r3, r4, r5) */ -#if defined(UVM) - bl _C_LABEL(uvm_km_free) -#else - bl _C_LABEL(kmem_free) -#endif + /* + * Schedule the vmspace and stack to be freed (the proc arg is + * already in r3). + */ + bl _C_LABEL(exit2) + /* Fall through to cpu_switch to actually select another proc */ li 3,0 /* indicate exited process */ diff --git a/sys/arch/mips/mips/locore_r2000.S b/sys/arch/mips/mips/locore_r2000.S index 66b3e841906e..2c398000e42d 100644 --- a/sys/arch/mips/mips/locore_r2000.S +++ b/sys/arch/mips/mips/locore_r2000.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore_r2000.S,v 1.43 1998/03/12 05:45:05 thorpej Exp $ */ +/* $NetBSD: locore_r2000.S,v 1.44 1998/09/09 00:07:53 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -1617,9 +1617,9 @@ END(mips1_proc_trampoline) /* * switch_exit(struct proc *) - * Make the named process exit. Switch SP to nullproc stack, free the - * exiting proc's USPACE, then jump into the middle of cpu_switch(). - * MUST BE CALLED AT SPLHIGH. + * Make the named process exit. Switch SP to nullproc stack, schedule + * the exiting proc's vmspace and stack to be freed, then jump into the + * middle of cpu_switch(). MUST BE CALLED AT SPLHIGH. */ LEAF(mips1_switch_exit) la v1, _C_LABEL(nullproc) # !! SP runs on p->p_addr !! @@ -1651,15 +1651,8 @@ LEAF(mips1_switch_exit) tlbwi # Write the TLB entry. addu sp, v0, USPACE - START_FRAME - li a2, USPACE - lw a1, P_ADDR(a0) - lw a0, kernel_map la ra, sw1 # goto cpu_switch() -#if defined(UVM) - j uvm_km_free # free exiting USPACE -#else - j kmem_free # free exiting USPACE -#endif + j exit2 # proc already in a0 END(mips1_switch_exit) /* diff --git a/sys/arch/mips/mips/locore_r4000.S b/sys/arch/mips/mips/locore_r4000.S index 7825d47b7644..d03c5ad780be 100644 --- a/sys/arch/mips/mips/locore_r4000.S +++ b/sys/arch/mips/mips/locore_r4000.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore_r4000.S,v 1.43 1998/04/19 01:48:34 jonathan Exp $ */ +/* $NetBSD: locore_r4000.S,v 1.44 1998/09/09 00:07:53 thorpej Exp $ */ /* * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author) @@ -2113,9 +2113,9 @@ END(mips3_proc_trampoline) /* * mips3_switch_exit(struct proc *) - * Make the named process exit. Switch SP to nullproc stack, free the - * exiting proc's USPACE, then jump into the middle of cpu_switch(). - * MUST BE CALLED AT SPLHIGH. + * Make the named process exit. Switch SP to nullproc stack, schedule + * the exiting proc's vmspace and stack to be freed, then jump into the + * middle of cpu_switch(). MUST BE CALLED AT SPLHIGH. */ LEAF(mips3_switch_exit) la v1, _C_LABEL(nullproc) # !! SP runs on p->p_addr !! @@ -2141,15 +2141,8 @@ LEAF(mips3_switch_exit) tlbwi # Write the TLB entry. addu sp, v0, USPACE - START_FRAME - li a2, USPACE - lw a1, P_ADDR(a0) - lw a0, kernel_map la ra, sw1 # goto cpu_switch() -#if defined(UVM) - j uvm_km_free # free exiting USPACE -#else - j kmem_free # free exiting USPACE -#endif + j exit2 # proc already in a0 nop # XXX schedule better END(mips3_switch_exit) diff --git a/sys/arch/mips/mips/vm_machdep.c b/sys/arch/mips/mips/vm_machdep.c index 0e5d570d8653..5c96407e4529 100644 --- a/sys/arch/mips/mips/vm_machdep.c +++ b/sys/arch/mips/mips/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.27 1998/09/02 06:41:22 nisimura Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.28 1998/09/09 00:07:53 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,7 +43,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.27 1998/09/02 06:41:22 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.28 1998/09/09 00:07:53 thorpej Exp $"); #include "opt_uvm.h" @@ -145,10 +145,11 @@ cpu_swapin(p) /* * cpu_exit is called as the last action during exit. - * We release the address space of the process, block interrupts, - * and call switch_exit. switch_exit switches to nullproc's PCB and stack, - * then jumps into the middle of cpu_switch, as if it were switching - * from nullproc. + * + * We clean up a little and then call switch_exit() with the old proc as an + * argument. switch_exit() first switches to nullproc's PCB and stack, + * schedules the dead proc's vmspace and stack to be freed, then jumps + * into the middle of cpu_switch(), as if it were switching from nullproc. */ void cpu_exit(p) @@ -158,12 +159,8 @@ cpu_exit(p) fpcurproc = (struct proc *)0; #if defined(UVM) - uvmspace_free(p->p_vmspace); - uvmexp.swtch++; #else - vmspace_free(p->p_vmspace); - cnt.v_swtch++; #endif (void)splhigh(); diff --git a/sys/arch/mvme68k/mvme68k/locore.s b/sys/arch/mvme68k/mvme68k/locore.s index 9994184d9e80..aee57d9df6e1 100644 --- a/sys/arch/mvme68k/mvme68k/locore.s +++ b/sys/arch/mvme68k/mvme68k/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.38 1998/08/16 15:33:48 scw Exp $ */ +/* $NetBSD: locore.s,v 1.39 1998/09/09 00:07:54 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -969,23 +969,18 @@ mdpflag: /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 movl #nullpcb,_curpcb | save state into garbage pcb lea tmpstk,sp | goto a tmp stack - /* Free old process's resources. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _kernel_map,sp@- | map it was allocated in -#ifdef UVM - jbsr _uvm_km_free | deallocate it -#else - jbsr _kmem_free | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _cpu_switch diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index e927bfa8fc34..029fd15cc398 100644 --- a/sys/arch/mvme68k/mvme68k/vm_machdep.c +++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.15 1998/08/22 10:55:36 scw Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.16 1998/09/09 00:07:54 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -117,23 +117,15 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call switch_exit, which switches to a temporary - * pcb and stack and never returns. We block memory allocation - * until switch_exit has made things safe again. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#ifdef UVM - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - (void) splhigh(); #ifdef UVM uvmexp.swtch++; diff --git a/sys/arch/next68k/next68k/locore.s b/sys/arch/next68k/next68k/locore.s index ec77e20f33bf..c30fd88cd60d 100644 --- a/sys/arch/next68k/next68k/locore.s +++ b/sys/arch/next68k/next68k/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.3 1998/08/28 22:47:12 dbj Exp $ */ +/* $NetBSD: locore.s,v 1.4 1998/09/09 00:07:54 thorpej Exp $ */ /* * Copyright (c) 1998 Darrin B. Jewell @@ -1113,7 +1113,8 @@ ASBSS(nullpcb,SIZEOF_PCB) /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 @@ -1121,12 +1122,10 @@ ENTRY(switch_exit) movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb) lea _ASM_LABEL(tmpstk),sp | goto a tmp stack - /* Free old process's resources. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in - jbsr _C_LABEL(kmem_free) | deallocate it - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _C_LABEL(cpu_switch) diff --git a/sys/arch/next68k/next68k/vm_machdep.c b/sys/arch/next68k/next68k/vm_machdep.c index 494fd1d2f54d..02685ca789bf 100644 --- a/sys/arch/next68k/next68k/vm_machdep.c +++ b/sys/arch/next68k/next68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.3 1998/08/28 23:05:55 dbj Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.4 1998/09/09 00:07:54 thorpej Exp $ */ /* * This file was taken from from mvme68k/mvme68k/vm_machdep.c @@ -126,23 +126,15 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call switch_exit, which switches to a temporary - * pcb and stack and never returns. We block memory allocation - * until switch_exit has made things safe again. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#ifdef UVM - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - (void) splhigh(); #ifdef UVM uvmexp.swtch++; diff --git a/sys/arch/ofppc/ofppc/locore.S b/sys/arch/ofppc/ofppc/locore.S index 82cfc14ad501..6c3e5bcb5473 100644 --- a/sys/arch/ofppc/ofppc/locore.S +++ b/sys/arch/ofppc/ofppc/locore.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.8 1998/07/04 22:18:34 jonathan Exp $ */ +/* $NetBSD: locore.S,v 1.9 1998/09/09 00:07:54 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -255,8 +255,7 @@ ASENTRY(Idle) b _ASM_LABEL(Idle) /* - * switchexit gets called from cpu_exit to free the user structure - * and kernel stack of the current process. + * switchexit gets called from cpu_exit to complete the exit procedure. */ ENTRY(switchexit) /* First switch to the idle pcb/kernel stack */ @@ -265,12 +264,12 @@ ENTRY(switchexit) lis 7,_C_LABEL(curpcb)@ha stw 6,_C_LABEL(curpcb)@l(7) addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */ -/* Now free the old user structure (args are already in r3, r4, r5) */ -#if defined(UVM) - bl _C_LABEL(uvm_km_free) -#else - bl _C_LABEL(kmem_free) -#endif + /* + * Schedule the vmspace and stack to be freed (the proc arg is + * already in r3). + */ + bl _C_LABEL(exit2) + /* Fall through to cpu_switch to actually select another proc */ li 3,0 /* indicate exited process */ diff --git a/sys/arch/pc532/pc532/vm_machdep.c b/sys/arch/pc532/pc532/vm_machdep.c index 60d7b4eb31d0..59b833789220 100644 --- a/sys/arch/pc532/pc532/vm_machdep.c +++ b/sys/arch/pc532/pc532/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.27 1998/09/02 19:17:21 matthias Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.28 1998/09/09 00:07:54 thorpej Exp $ */ /*- * Copyright (c) 1996 Matthias Pfaller. @@ -159,11 +159,9 @@ cpu_swapout(p) /* * cpu_exit is called as the last action during exit. * - * We switch to a temorary stack and address space. Then we release - * release the original address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call cpu_exit, which never returns. - * We block interrupts until cpu_switch has made things safe again. + * We clean up a little and then call switch_exit() with the old proc as an + * argument. switch_exit() first switches to proc0's context, and finally + * jumps into switch() to wait for another process to wake up. */ void cpu_exit(arg) @@ -188,16 +186,9 @@ cpu_exit(arg) lprd(sp, INTSTACK); load_ptb(proc0paddr->u_pcb.pcb_ptb); - /* Free resources. */ -#if defined(UVM) - uvmspace_free(p->p_vmspace); + /* Schedule the vmspace and stack to be freed. */ (void) splhigh(); - uvm_km_free(kernel_map, (vaddr_t)p->p_addr, USPACE); -#else - vmspace_free(p->p_vmspace); - (void) splhigh(); - kmem_free(kernel_map, (vaddr_t)p->p_addr, USPACE); -#endif + exit2(p); /* Don't update pcb in cpu_switch. */ curproc = NULL; diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c index 7169b4773610..02aca9a03b3c 100644 --- a/sys/arch/powerpc/powerpc/vm_machdep.c +++ b/sys/arch/powerpc/powerpc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.4 1998/08/31 14:43:41 tsubai Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.5 1998/09/09 00:07:55 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -154,12 +154,11 @@ pagemove(from, to, size) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. * - * Since we don't have curproc anymore, we cannot sleep, and therefor - * this is at least incorrect for the multiprocessor version. - * Not sure whether we can get away with this in the single proc version. XXX + * We clean up a little and then call switchexit() with the old proc + * as an argument. switchexit() switches to the idle context, schedules + * the old vmspace and stack to be freed, then selects a new process to + * run. */ void cpu_exit(p) @@ -168,12 +167,7 @@ cpu_exit(p) if (p == fpuproc) /* release the fpu */ fpuproc = 0; -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - switchexit(kernel_map, p->p_addr, USPACE); + switchexit(p); } /* diff --git a/sys/arch/sparc/include/pmap.h b/sys/arch/sparc/include/pmap.h index 086d2ab1d025..d8c100c3ecd6 100644 --- a/sys/arch/sparc/include/pmap.h +++ b/sys/arch/sparc/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.34 1998/08/21 14:12:18 pk Exp $ */ +/* $NetBSD: pmap.h,v 1.35 1998/09/09 00:07:55 thorpej Exp $ */ /* * Copyright (c) 1996 @@ -265,7 +265,7 @@ void pmap_virtual_space __P((vaddr_t *, vaddr_t *)); void pmap_redzone __P((void)); void kvm_uncache __P((caddr_t, int)); struct user; -void switchexit __P((vm_map_t, struct user *, int)); +void switchexit __P((struct proc *)); int mmu_pagein __P((struct pmap *pm, int, int)); void pmap_writetext __P((unsigned char *, int)); diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index 4a36742334db..fe0a0fbf932f 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.87 1998/09/06 21:18:59 pk Exp $ */ +/* $NetBSD: locore.s,v 1.88 1998/09/09 00:07:55 thorpej Exp $ */ /* * Copyright (c) 1996 Paul Kranenburg @@ -4329,15 +4329,14 @@ ENTRY(write_user_windows) /* * switchexit is called only from cpu_exit() before the current process - * has freed its kernel stack; we must free it. (curproc is already NULL.) + * has freed its vmspace and kernel stack; we must schedule them to be + * freed. (curproc is already NULL.) * * We lay the process to rest by changing to the `idle' kernel stack, * and note that the `last loaded process' is nonexistent. */ ENTRY(switchexit) - mov %o0, %g2 ! save the - mov %o1, %g3 ! ... three parameters - mov %o2, %g4 ! ... to kmem_free + mov %o0, %g2 ! save proc for exit2() call /* * Change pcb to idle u. area, i.e., set %sp to top of stack @@ -4359,14 +4358,8 @@ ENTRY(switchexit) SET_SP_REDZONE(%l6, %l5) #endif wr %g0, PSR_S|PSR_ET, %psr ! and then enable traps - mov %g2, %o0 ! now ready to call kmem_free - mov %g3, %o1 -#if defined(UVM) - call _uvm_km_free -#else - call _kmem_free -#endif - mov %g4, %o2 + call _exit2 ! exit2(p) + mov %g2, %o0 /* * Now fall through to `the last switch'. %g6 was set to diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c index 7224e8fa7270..85efbd1bf153 100644 --- a/sys/arch/sparc/sparc/vm_machdep.c +++ b/sys/arch/sparc/sparc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.38 1998/08/21 14:13:56 pk Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.39 1998/09/09 00:07:55 thorpej Exp $ */ /* * Copyright (c) 1996 @@ -312,10 +312,11 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Since the latter is also the interrupt stack, we release it - * from assembly code after switching to a temporary pcb+stack. + * + * We clean up a little and then call switchexit() with the old proc + * as an argument. switchexit() switches to the idle context, schedules + * the old vmspace and stack to be freed, then selects a new process to + * run. */ void cpu_exit(p) @@ -330,12 +331,7 @@ cpu_exit(p) } free((void *)fs, M_SUBPROC); } -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - switchexit(kernel_map, p->p_addr, USPACE); + switchexit(p); /* NOTREACHED */ } diff --git a/sys/arch/sparc64/include/pmap.h b/sys/arch/sparc64/include/pmap.h index 1145d2e6bdca..12cf4ade58ee 100644 --- a/sys/arch/sparc64/include/pmap.h +++ b/sys/arch/sparc64/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.5 1998/08/30 15:32:17 eeh Exp $ */ +/* $NetBSD: pmap.h,v 1.6 1998/09/09 00:07:56 thorpej Exp $ */ /*- * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -165,8 +165,8 @@ int pmap_dumpsize __P((void)); int pmap_dumpmmu __P((int (*)__P((dev_t, daddr_t, caddr_t, size_t)), daddr_t)); int pmap_pa_exists __P((paddr_t)); -struct user; -void switchexit __P((vm_map_t, struct user *, int)); +struct proc; +void switchexit __P((struct proc *)); /* SPARC64 specific */ int ctx_alloc __P((struct pmap*)); diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 31e72edead26..47717458b84d 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -6500,7 +6500,8 @@ _C_LABEL(masterpaddr): /* * switchexit is called only from cpu_exit() before the current process - * has freed its kernel stack; we must free it. (curproc is already NULL.) + * has freed its vmspace and kernel stack; we must schedule them to be + * freed. (curproc is already NULL.) * * We lay the process to rest by changing to the `idle' kernel stack, * and note that the `last loaded process' is nonexistent. @@ -6513,9 +6514,7 @@ ENTRY(switchexit) restore #endif wrpr %g0, PSTATE_KERN, %pstate ! Make sure we're on the right globals - mov %o0, %g2 ! save the - mov %o1, %g3 ! ... three parameters - mov %o2, %g4 ! ... to kmem_free + mov %o0, %g2 ! save proc arg for exit2() call #ifdef NOTDEF_DEBUG save %sp, -CC64FSZ, %sp @@ -6573,14 +6572,8 @@ ENTRY(switchexit) SET_SP_REDZONE(%l6, %l5) #endif wrpr %g0, PSTATE_INTR, %pstate ! and then enable traps - mov %g2, %o0 ! now ready to call kmem_free - mov %g3, %o1 -#if defined(UVM) - call _C_LABEL(uvm_km_free) -#else - call _C_LABEL(kmem_free) -#endif - mov %g4, %o2 + call _C_LABEL(exit2) ! exit2(p) + mov %g2, %o0 /* * Now fall through to `the last switch'. %g6 was set to diff --git a/sys/arch/sparc64/sparc64/vm_machdep.c b/sys/arch/sparc64/sparc64/vm_machdep.c index 422dbd5343d3..4d7c3824af48 100644 --- a/sys/arch/sparc64/sparc64/vm_machdep.c +++ b/sys/arch/sparc64/sparc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.8 1998/09/06 21:53:43 eeh Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.9 1998/09/09 00:07:56 thorpej Exp $ */ /* * Copyright (c) 1996 @@ -379,10 +379,11 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Since the latter is also the interrupt stack, we release it - * from assembly code after switching to a temporary pcb+stack. + * + * We clean up a little and then call switchexit() with the old proc + * as an argument. switchexit() switches to the idle context, schedules + * the old vmspace and stack to be freed, then selects a new process to + * run. */ void cpu_exit(p) @@ -397,12 +398,7 @@ cpu_exit(p) } free((void *)fs, M_SUBPROC); } -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - switchexit(kernel_map, p->p_addr, USPACE); + switchexit(p); /* NOTREACHED */ } diff --git a/sys/arch/sun3/sun3/locore.s b/sys/arch/sun3/sun3/locore.s index dae84018a82f..d66dc11ae915 100644 --- a/sys/arch/sun3/sun3/locore.s +++ b/sys/arch/sun3/sun3/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.60 1998/06/08 20:47:46 gwr Exp $ */ +/* $NetBSD: locore.s,v 1.61 1998/09/09 00:07:56 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -630,26 +630,20 @@ ASBSS(nullpcb,SIZEOF_PCB) /* * At exit of a process, do a cpu_switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. - * The ipl is high enough to prevent the memory from being reallocated. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 | struct proc *p | save state into garbage pcb movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb) lea _ASM_LABEL(tmpstk),sp | goto a tmp stack - movl a0,sp@- | pass proc ptr down - /* Free old process's u-area. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + + /* Don't pop the proc; pass it to cpu_switch(). */ jra _C_LABEL(cpu_switch) diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index 5a18c597cdbc..b3110feb9b35 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.43 1998/07/28 18:34:58 thorpej Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.44 1998/09/09 00:07:57 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -63,7 +63,6 @@ /* XXX - Gratuitous name changes... */ #define kmem_alloc_wait uvm_km_valloc_wait #define kmem_free_wakeup uvm_km_free_wakeup -#define vmspace_free uvmspace_free #endif /* UVM */ #include @@ -188,20 +187,16 @@ cpu_set_kpc(proc, func) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call switch_exit, which switches to a temporary - * pcb and stack and never returns. We block memory allocation - * until switch_exit has made things safe again. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { - vmspace_free(p->p_vmspace); - - (void) splimp(); + (void) splhigh(); #if defined(UVM) uvmexp.swtch++; #else diff --git a/sys/arch/sun3/sun3x/locore.s b/sys/arch/sun3/sun3x/locore.s index f247f6ad80d1..a4f4124c07a6 100644 --- a/sys/arch/sun3/sun3x/locore.s +++ b/sys/arch/sun3/sun3x/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.27 1998/06/09 20:47:17 gwr Exp $ */ +/* $NetBSD: locore.s,v 1.28 1998/09/09 00:07:57 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -649,26 +649,20 @@ ASBSS(nullpcb,SIZEOF_PCB) /* * At exit of a process, do a cpu_switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. - * The ipl is high enough to prevent the memory from being reallocated. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 | struct proc *p | save state into garbage pcb movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb) lea _ASM_LABEL(tmpstk),sp | goto a tmp stack - movl a0,sp@- | pass proc ptr down - /* Free old process's u-area. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + + /* Don't pop the proc; pass it to cpu_switch(). */ jra _C_LABEL(cpu_switch) diff --git a/sys/arch/vax/vax/subr.s b/sys/arch/vax/vax/subr.s index b262a7581526..b579b695eda6 100644 --- a/sys/arch/vax/vax/subr.s +++ b/sys/arch/vax/vax/subr.s @@ -1,4 +1,4 @@ -/* $NetBSD: subr.s,v 1.25 1998/07/04 22:18:45 jonathan Exp $ */ +/* $NetBSD: subr.s,v 1.26 1998/09/09 00:09:19 thorpej Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -265,23 +265,13 @@ noque: .asciz "swtch" # ENTRY(cpu_exit,0) - movl 4(ap),r6 # Process pointer in r0 - pushl P_VMSPACE(r6) # free current vm space -#if defined(UVM) - calls $1,_uvmspace_free -#else - calls $1,_vmspace_free -#endif + movl 4(ap),r6 # Process pointer in r6 mtpr $0x18,$PR_IPL # Block almost everything - addl3 $512,_scratch,sp # Change stack, we will free it now - pushl $USPACE # stack size - pushl P_ADDR(r6) # pointer to stack space - pushl _kernel_map # the correct vm map -#if defined(UVM) - calls $3,_uvm_km_free -#else - calls $3,_kmem_free -#endif + addl3 $512,_scratch,sp # Change stack, and schedule it to be freed + + pushl r6 # exit2(p) + calls $1,_exit2 + clrl r0 # No process to switch from bicl3 $0xc0000000,_scratch,r1 mtpr r1,$PR_PCBB diff --git a/sys/arch/x68k/x68k/locore.s b/sys/arch/x68k/x68k/locore.s index f61730594738..1decfdb0a875 100644 --- a/sys/arch/x68k/x68k/locore.s +++ b/sys/arch/x68k/x68k/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.32 1998/09/07 14:14:34 minoura Exp $ */ +/* $NetBSD: locore.s,v 1.33 1998/09/09 00:09:19 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1261,23 +1261,18 @@ mdpflag: /* * At exit of a process, do a switch for the last time. - * Switch to a safe stack and PCB, and deallocate the process's resources. + * Switch to a safe stack and PCB, and select a new process to run. The + * old stack and u-area will be freed by the reaper. */ ENTRY(switch_exit) movl sp@(4),a0 movl #nullpcb,_curpcb | save state into garbage pcb lea tmpstk,sp | goto a tmp stack - /* Free old process's resources. */ - movl #USPACE,sp@- | size of u-area - movl a0@(P_ADDR),sp@- | address of process's u-area - movl _C_LABEL(kernel_map),sp@- | map it was allocated in -#if defined(UVM) - jbsr _C_LABEL(uvm_km_free) | deallocate it -#else - jbsr _C_LABEL(kmem_free) | deallocate it -#endif - lea sp@(12),sp | pop args + /* Schedule the vmspace and stack to be freed. */ + movl a0,sp@- | exit2(p) + jbsr _C_LABEL(exit2) + lea sp@(4),sp | pop args jra _C_LABEL(cpu_switch) diff --git a/sys/arch/x68k/x68k/vm_machdep.c b/sys/arch/x68k/x68k/vm_machdep.c index 4a73e1eea54c..3b30e1e1a0d9 100644 --- a/sys/arch/x68k/x68k/vm_machdep.c +++ b/sys/arch/x68k/x68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.12 1998/08/22 14:38:41 minoura Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.13 1998/09/09 00:09:19 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -116,24 +116,16 @@ cpu_set_kpc(p, pc) /* * cpu_exit is called as the last action during exit. - * We release the address space and machine-dependent resources, - * including the memory for the user structure and kernel stack. - * Once finished, we call switch_exit, which switches to a temporary - * pcb and stack and never returns. We block memory allocation - * until switch_exit has made things safe again. + * + * Block context switches and then call switch_exit() which will + * switch to another process thus we never return. */ void cpu_exit(p) struct proc *p; { -#if defined(UVM) - uvmspace_free(p->p_vmspace); -#else - vmspace_free(p->p_vmspace); -#endif - - (void) splimp(); + (void) splhigh(); #if defined(UVM) uvmexp.swtch++; #else