summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-04-07 07:16:06 +0000
committerpeter <peter@FreeBSD.org>1997-04-07 07:16:06 +0000
commitecf50a7463380158994f03aa71d9b084c0c5114a (patch)
treeec1548851ef256720ebb6254e235cc3d5bc04523 /sys/vm
parent237ff29ca4d094b8fbf6c41083b91ddda096ae46 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/vm/vm_extern.h4
-rw-r--r--sys/vm/vm_glue.c34
-rw-r--r--sys/vm/vm_map.c5
-rw-r--r--sys/vm/vm_map.h3
4 files changed, 22 insertions, 24 deletions
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h
index c419557..795cfc4 100644
--- a/sys/vm/vm_extern.h
+++ b/sys/vm/vm_extern.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
- * $Id: vm_extern.h,v 1.31 1997/02/22 09:48:11 peter Exp $
+ * $Id: vm_extern.h,v 1.32 1997/04/06 02:30:56 dyson Exp $
*/
#ifndef _VM_EXTERN_H_
@@ -81,7 +81,7 @@ void vm_fault_copy_entry __P((vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t
void vm_fault_unwire __P((vm_map_t, vm_offset_t, vm_offset_t));
int vm_fault_wire __P((vm_map_t, vm_offset_t, vm_offset_t));
int vm_fault_user_wire __P((vm_map_t, vm_offset_t, vm_offset_t));
-int vm_fork __P((struct proc *, struct proc *));
+void vm_fork __P((struct proc *, struct proc *, int));
int vm_mmap __P((vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int, caddr_t, vm_ooffset_t));
vm_offset_t vm_page_alloc_contig __P((vm_offset_t, vm_offset_t, vm_offset_t, vm_offset_t));
void vm_set_page_size __P((void));
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);
}
/*
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 18753d3..7a1de30 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_map.c,v 1.73 1997/04/06 02:29:43 dyson Exp $
+ * $Id: vm_map.c,v 1.74 1997/04/06 03:04:31 dyson Exp $
*/
/*
@@ -256,9 +256,6 @@ vmspace_free(vm)
while( vm->vm_map.ref_count != 1)
tsleep(&vm->vm_map.ref_count, PVM, "vmsfre", 0);
--vm->vm_map.ref_count;
- vm_object_pmap_remove(vm->vm_upages_obj,
- 0, vm->vm_upages_obj->size);
- vm_object_deallocate(vm->vm_upages_obj);
pmap_release(&vm->vm_pmap);
FREE(vm, M_VMMAP);
} else {
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h
index d1905ad6..8438ccf 100644
--- a/sys/vm/vm_map.h
+++ b/sys/vm/vm_map.h
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_map.h,v 1.24 1997/02/22 09:48:24 peter Exp $
+ * $Id: vm_map.h,v 1.25 1997/04/06 02:29:44 dyson Exp $
*/
/*
@@ -152,7 +152,6 @@ struct vmspace {
struct pmap vm_pmap; /* private physical map */
int vm_refcnt; /* number of references */
caddr_t vm_shm; /* SYS5 shared memory private data XXX */
- vm_object_t vm_upages_obj; /* UPAGES object */
/* we copy from vm_startcopy to the end of the structure on fork */
#define vm_startcopy vm_rssize
segsz_t vm_rssize; /* current resident set size in pages */
OpenPOWER on IntegriCloud