diff options
author | jake <jake@FreeBSD.org> | 2000-11-22 07:42:04 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2000-11-22 07:42:04 +0000 |
commit | 0c0be4e82677a2d8fb49b7a70676bf359e7360b0 (patch) | |
tree | a0c32260edfde6d861e66b11172147608684043e /sys/vm | |
parent | 1b544875743d53491a096b0c757bf30ce73bb83b (diff) | |
download | FreeBSD-src-0c0be4e82677a2d8fb49b7a70676bf359e7360b0.zip FreeBSD-src-0c0be4e82677a2d8fb49b7a70676bf359e7360b0.tar.gz |
Protect the following with a lockmgr lock:
allproc
zombproc
pidhashtbl
proc.p_list
proc.p_hash
nextpid
Reviewed by: jhb
Obtained from: BSD/OS and netbsd
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_glue.c | 4 | ||||
-rw-r--r-- | sys/vm/vm_meter.c | 4 | ||||
-rw-r--r-- | sys/vm/vm_object.c | 6 | ||||
-rw-r--r-- | sys/vm/vm_pageout.c | 4 |
4 files changed, 17 insertions, 1 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 82e22ba..3c9e941 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -360,6 +360,7 @@ loop: pp = NULL; ppri = INT_MIN; + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { if (p->p_stat == SRUN && (p->p_flag & (P_INMEM | P_SWAPPING)) == 0) { @@ -380,6 +381,7 @@ loop: } } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); /* * Nothing to do, back to sleep. @@ -439,6 +441,7 @@ int action; outp = outp2 = NULL; outpri = outpri2 = INT_MIN; + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); retry: for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { struct vmspace *vm; @@ -504,6 +507,7 @@ retry: } } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); /* * If we swapped something out, and another process needed memory, * then wakeup the sched process. diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index 8b68a65..9ed122e 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -78,6 +78,7 @@ loadav(struct loadavg *avg) register int i, nrun; register struct proc *p; + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (nrun = 0, p = allproc.lh_first; p != 0; p = p->p_list.le_next) { switch (p->p_stat) { case SSLEEP: @@ -92,6 +93,7 @@ loadav(struct loadavg *avg) nrun++; } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); for (i = 0; i < 3; i++) avg->ldavg[i] = (cexp[i] * avg->ldavg[i] + nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT; @@ -149,6 +151,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) /* * Calculate process statistics. */ + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { if (p->p_flag & P_SYSTEM) continue; @@ -199,6 +202,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) if (paging) totalp->t_pw++; } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); /* * Calculate object memory usage statistics. */ diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index e5403d1..0b079c3 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1620,12 +1620,16 @@ vm_object_in_map( object) vm_object_t object; { struct proc *p; + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { if( !p->p_vmspace /* || (p->p_flag & (P_SYSTEM|P_WEXIT)) */) continue; - if( _vm_object_in_map(&p->p_vmspace->vm_map, object, 0)) + if( _vm_object_in_map(&p->p_vmspace->vm_map, object, 0)) { + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); return 1; + } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); if( _vm_object_in_map( kernel_map, object, 0)) return 1; if( _vm_object_in_map( kmem_map, object, 0)) diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 4ab3930..3b0c7cc 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1129,6 +1129,7 @@ rescan0: if ((vm_swap_size < 64 || swap_pager_full) && vm_page_count_min()) { bigproc = NULL; bigsize = 0; + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { /* * if this is a system process, skip it @@ -1158,6 +1159,7 @@ rescan0: bigsize = size; } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); if (bigproc != NULL) { killproc(bigproc, "out of swap space"); bigproc->p_estcpu = 0; @@ -1442,6 +1444,7 @@ vm_daemon() * process is swapped out -- deactivate pages */ + lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC); for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { vm_pindex_t limit, size; @@ -1480,6 +1483,7 @@ vm_daemon() &p->p_vmspace->vm_map, limit); } } + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); } } #endif |