Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_glue.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_domainset.h> | |||||
#include <vm/vm_map.h> | #include <vm/vm_map.h> | ||||
#include <vm/vm_page.h> | #include <vm/vm_page.h> | ||||
#include <vm/vm_pageout.h> | #include <vm/vm_pageout.h> | ||||
#include <vm/vm_object.h> | #include <vm/vm_object.h> | ||||
#include <vm/vm_kern.h> | #include <vm/vm_kern.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/vm_pager.h> | #include <vm/vm_pager.h> | ||||
#include <vm/swap_pager.h> | #include <vm/swap_pager.h> | ||||
▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 Lines | |||||
* ready to run. The new process is set up so that it returns directly | * ready to run. The new process is set up so that it returns directly | ||||
* to user mode to avoid stack copying and relocation problems. | * to user mode to avoid stack copying and relocation problems. | ||||
*/ | */ | ||||
int | int | ||||
vm_forkproc(struct thread *td, struct proc *p2, struct thread *td2, | vm_forkproc(struct thread *td, struct proc *p2, struct thread *td2, | ||||
struct vmspace *vm2, int flags) | struct vmspace *vm2, int flags) | ||||
{ | { | ||||
struct proc *p1 = td->td_proc; | struct proc *p1 = td->td_proc; | ||||
struct domainset *dset; | |||||
int error; | int error; | ||||
if ((flags & RFPROC) == 0) { | if ((flags & RFPROC) == 0) { | ||||
/* | /* | ||||
* Divorce the memory, if it is shared, essentially | * Divorce the memory, if it is shared, essentially | ||||
* this changes shared memory amongst threads, into | * this changes shared memory amongst threads, into | ||||
* COW locally. | * COW locally. | ||||
*/ | */ | ||||
if ((flags & RFMEM) == 0) { | if ((flags & RFMEM) == 0) { | ||||
if (p1->p_vmspace->vm_refcnt > 1) { | if (p1->p_vmspace->vm_refcnt > 1) { | ||||
error = vmspace_unshare(p1); | error = vmspace_unshare(p1); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
} | } | ||||
cpu_fork(td, p2, td2, flags); | cpu_fork(td, p2, td2, flags); | ||||
return (0); | return (0); | ||||
} | } | ||||
if (flags & RFMEM) { | if (flags & RFMEM) { | ||||
p2->p_vmspace = p1->p_vmspace; | p2->p_vmspace = p1->p_vmspace; | ||||
atomic_add_int(&p1->p_vmspace->vm_refcnt, 1); | atomic_add_int(&p1->p_vmspace->vm_refcnt, 1); | ||||
} | } | ||||
dset = td2->td_domain.dr_policy; | |||||
while (vm_page_count_severe()) { | while (vm_page_count_severe_set(&dset->ds_mask)) { | ||||
vm_wait_severe(); | vm_wait_doms(&dset->ds_mask); | ||||
} | } | ||||
if ((flags & RFMEM) == 0) { | if ((flags & RFMEM) == 0) { | ||||
p2->p_vmspace = vm2; | p2->p_vmspace = vm2; | ||||
if (p1->p_vmspace->vm_shm) | if (p1->p_vmspace->vm_shm) | ||||
shmfork(p1, p2); | shmfork(p1, p2); | ||||
} | } | ||||
Show All 27 Lines |