diff options
author | peter <peter@FreeBSD.org> | 1997-04-07 07:16:06 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-04-07 07:16:06 +0000 |
commit | ecf50a7463380158994f03aa71d9b084c0c5114a (patch) | |
tree | ec1548851ef256720ebb6254e235cc3d5bc04523 /sys/vm/vm_glue.c | |
parent | 237ff29ca4d094b8fbf6c41083b91ddda096ae46 (diff) | |
download | FreeBSD-src-ecf50a7463380158994f03aa71d9b084c0c5114a.zip FreeBSD-src-ecf50a7463380158994f03aa71d9b084c0c5114a.tar.gz |
The biggie: Get rid of the UPAGES from the top of the per-process address
space. (!)
Have each process use the kernel stack and pcb in the kvm space. Since
the stacks are at a different address, we cannot copy the stack at fork()
and allow the child to return up through the function call tree to return
to user mode - create a new execution context and have the new process
begin executing from cpu_switch() and go to user mode directly.
In theory this should speed up fork a bit.
Context switch the tss_esp0 pointer in the common tss. This is a lot
simpler since than swithching the gdt[GPROC0_SEL].sd.sd_base pointer
to each process's tss since the esp0 pointer is a 32 bit pointer, and the
sd_base setting is split into three different bit sections at non-aligned
boundaries and requires a lot of twiddling to reset.
The 8K of memory at the top of the process space is now empty, and unmapped
(and unmappable, it's higher than VM_MAXUSER_ADDRESS).
Simplity the pmap code to manage process contexts, we no longer have to
double map the UPAGES, this simplifies and should measuably speed up fork().
The following parts came from John Dyson:
Set PG_G on the UPAGES that are now in kernel context, and invalidate
them when swapping them out.
Move the upages object (upobj) from the vmspace to the proc structure.
Now that the UPAGES (pcb and kernel stack) are out of user space, make
rfork(..RFMEM..) do what was intended by sharing the vmspace
entirely via reference counting rather than simply inheriting the mappings.
Diffstat (limited to 'sys/vm/vm_glue.c')
-rw-r--r-- | sys/vm/vm_glue.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 1aa329a..2116a0e 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -59,7 +59,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id$ + * $Id: vm_glue.c,v 1.61 1997/02/22 09:48:17 peter Exp $ */ #include "opt_rlimit.h" @@ -74,6 +74,7 @@ #include <sys/kernel.h> #include <sys/dkstat.h> +#include <sys/unistd.h> #include <vm/vm.h> #include <vm/vm_param.h> @@ -197,15 +198,13 @@ vsunlock(addr, len, dirtied) * Here we arrange for the address space to be copied or referenced, * allocate a user struct (pcb and kernel stack), then call the * machine-dependent layer to fill those in and make the new process - * ready to run. - * NOTE: the kernel stack may be at a different location in the child - * process, and thus addresses of automatic variables may be invalid - * after cpu_fork returns in the child process. We do nothing here - * after cpu_fork returns. + * ready to run. The new process is set up so that it returns directly + * to user mode to avoid stack copying and relocation problems. */ -int -vm_fork(p1, p2) +void +vm_fork(p1, p2, flags) register struct proc *p1, *p2; + int flags; { register struct user *up; int i; @@ -216,10 +215,15 @@ vm_fork(p1, p2) VM_WAIT; } - p2->p_vmspace = vmspace_fork(p1->p_vmspace); + if (flags & RFMEM) { + p2->p_vmspace = p1->p_vmspace; + p1->p_vmspace->vm_refcnt++; + } else { + p2->p_vmspace = vmspace_fork(p1->p_vmspace); - if (p1->p_vmspace->vm_shm) - shmfork(p1, p2); + if (p1->p_vmspace->vm_shm) + shmfork(p1, p2); + } pmap_new_proc(p2); @@ -242,12 +246,10 @@ vm_fork(p1, p2) /* - * cpu_fork will copy and update the kernel stack and pcb, and make - * the child ready to run. It marks the child so that it can return - * differently than the parent. It returns twice, once in the parent - * process and once in the child. + * cpu_fork will copy and update the pcb, set up the kernel stack, + * and make the child ready to run. */ - return (cpu_fork(p1, p2)); + cpu_fork(p1, p2); } /* |