summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-08-24 08:39:39 +0000
committerdfr <dfr@FreeBSD.org>1998-08-24 08:39:39 +0000
commit5fdaeb281d55485bff844095417fc1fbe1e45922 (patch)
tree896c704e890ada16cbc9fb366182b5bb739b46ec /sys/vm
parent1fb12a8979b46c244de5277f71b805b2fa8a39ad (diff)
downloadFreeBSD-src-5fdaeb281d55485bff844095417fc1fbe1e45922.zip
FreeBSD-src-5fdaeb281d55485bff844095417fc1fbe1e45922.tar.gz
Change various syscalls to use size_t arguments instead of u_int.
Add some overflow checks to read/write (from bde). Change all modifications to vm_page::flags, vm_page::busy, vm_object::flags and vm_object::paging_in_progress to use operations which are not interruptable. Reviewed by: Bruce Evans <bde@zeta.org.au>
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/swap_pager.c14
-rw-r--r--sys/vm/vm_fault.c21
-rw-r--r--sys/vm/vm_kern.c8
-rw-r--r--sys/vm/vm_map.c38
-rw-r--r--sys/vm/vm_meter.c6
-rw-r--r--sys/vm/vm_mmap.c4
-rw-r--r--sys/vm/vm_object.c64
-rw-r--r--sys/vm/vm_object.h33
-rw-r--r--sys/vm/vm_page.c22
-rw-r--r--sys/vm/vm_page.h24
-rw-r--r--sys/vm/vm_pageout.c20
-rw-r--r--sys/vm/vnode_pager.c8
12 files changed, 143 insertions, 119 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 946b6d2..5cdbef4 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -39,7 +39,7 @@
* from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
*
* @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
- * $Id: swap_pager.c,v 1.98 1998/07/28 15:30:01 bde Exp $
+ * $Id: swap_pager.c,v 1.99 1998/08/13 08:05:13 dfr Exp $
*/
/*
@@ -1104,7 +1104,7 @@ swap_pager_getpages(object, m, count, reqpage)
if (rv == VM_PAGER_OK) {
for (i = 0; i < count; i++) {
m[i]->dirty = 0;
- m[i]->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(m[i], PG_ZERO);
if (i != reqpage) {
/*
* whether or not to leave the page
@@ -1590,12 +1590,10 @@ swap_pager_finish(spc)
PAGE_BWAKEUP(ma[i]);
}
- s = splvm();
- object->paging_in_progress -= spc->spc_count;
- splx(s);
+ vm_object_pip_subtract(object, spc->spc_count);
if ((object->paging_in_progress == 0) &&
(object->flags & OBJ_PIPWNT)) {
- object->flags &= ~OBJ_PIPWNT;
+ vm_object_clear_flag(object, OBJ_PIPWNT);
wakeup(object);
}
@@ -1648,10 +1646,10 @@ swap_pager_iodone(bp)
(bp->b_flags & B_READ) ? "pagein" : "pageout",
(u_long) bp->b_blkno, bp->b_bcount, bp->b_error);
} else {
- object->paging_in_progress -= spc->spc_count;
+ vm_object_pip_subtract(object, spc->spc_count);
if ((object->paging_in_progress == 0) &&
(object->flags & OBJ_PIPWNT)) {
- object->flags &= ~OBJ_PIPWNT;
+ vm_object_clear_flag(object, OBJ_PIPWNT);
wakeup(object);
}
ma = spc->spc_m;
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index f074234..8233f11 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -66,7 +66,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_fault.c,v 1.85 1998/07/22 09:38:04 dg Exp $
+ * $Id: vm_fault.c,v 1.86 1998/08/06 08:33:19 dfr Exp $
*/
/*
@@ -291,7 +291,7 @@ RetryFault:;
if ((fs.m->flags & PG_BUSY) ||
(fs.m->busy &&
(fs.m->valid & VM_PAGE_BITS_ALL) != VM_PAGE_BITS_ALL)) {
- fs.m->flags |= PG_WANTED | PG_REFERENCED;
+ PAGE_SET_FLAG(fs.m, PG_WANTED | PG_REFERENCED);
cnt.v_intrans++;
tsleep(fs.m, PSWP, "vmpfw", 0);
}
@@ -314,7 +314,7 @@ RetryFault:;
goto RetryFault;
}
- fs.m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(fs.m, PG_BUSY);
if (((fs.m->valid & VM_PAGE_BITS_ALL) != VM_PAGE_BITS_ALL) &&
fs.m->object != kernel_object && fs.m->object != kmem_object) {
goto readrest;
@@ -607,7 +607,7 @@ readrest:
vm_page_rename(fs.m, fs.first_object, fs.first_pindex);
fs.first_m = fs.m;
fs.first_m->dirty = VM_PAGE_BITS_ALL;
- fs.first_m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(fs.first_m, PG_BUSY);
fs.m = NULL;
cnt.v_cow_optim++;
} else {
@@ -705,8 +705,9 @@ readrest:
*/
if (prot & VM_PROT_WRITE) {
- fs.m->flags |= PG_WRITEABLE;
- fs.m->object->flags |= OBJ_WRITEABLE|OBJ_MIGHTBEDIRTY;
+ PAGE_SET_FLAG(fs.m, PG_WRITEABLE);
+ vm_object_set_flag(fs.m->object,
+ OBJ_WRITEABLE|OBJ_MIGHTBEDIRTY);
/*
* If the fault is a write, we know that this page is being
* written NOW. This will save on the pmap_is_modified() calls
@@ -719,14 +720,14 @@ readrest:
unlock_things(&fs);
fs.m->valid = VM_PAGE_BITS_ALL;
- fs.m->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(fs.m, PG_ZERO);
pmap_enter(fs.map->pmap, vaddr, VM_PAGE_TO_PHYS(fs.m), prot, wired);
if (((fault_flags & VM_FAULT_WIRE_MASK) == 0) && (wired == 0)) {
pmap_prefault(fs.map->pmap, vaddr, fs.entry);
}
- fs.m->flags |= PG_MAPPED|PG_REFERENCED;
+ PAGE_SET_FLAG(fs.m, PG_MAPPED|PG_REFERENCED);
if (fault_flags & VM_FAULT_HOLD)
vm_page_hold(fs.m);
@@ -966,10 +967,10 @@ vm_fault_copy_entry(dst_map, src_map, dst_entry, src_entry)
* Enter it in the pmap...
*/
- dst_m->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(dst_m, PG_ZERO);
pmap_enter(dst_map->pmap, vaddr, VM_PAGE_TO_PHYS(dst_m),
prot, FALSE);
- dst_m->flags |= PG_WRITEABLE|PG_MAPPED;
+ PAGE_SET_FLAG(dst_m, PG_WRITEABLE|PG_MAPPED);
/*
* Mark it no longer busy, and put it on the active list.
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 6a71c87..6097257 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_kern.c,v 1.47 1998/06/05 21:48:45 dg Exp $
+ * $Id: vm_kern.c,v 1.48 1998/06/21 14:53:41 bde Exp $
*/
/*
@@ -181,7 +181,7 @@ kmem_alloc(map, size)
VM_ALLOC_ZERO | VM_ALLOC_RETRY);
if ((mem->flags & PG_ZERO) == 0)
vm_page_zero_fill(mem);
- mem->flags &= ~(PG_BUSY | PG_ZERO);
+ PAGE_CLEAR_FLAG(mem, (PG_BUSY | PG_ZERO));
mem->valid = VM_PAGE_BITS_ALL;
}
@@ -332,7 +332,7 @@ retry:
vm_map_unlock(map);
return (0);
}
- m->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(m, PG_ZERO);
m->valid = VM_PAGE_BITS_ALL;
}
@@ -361,7 +361,7 @@ retry:
PAGE_WAKEUP(m);
pmap_enter(kernel_pmap, addr + i, VM_PAGE_TO_PHYS(m),
VM_PROT_ALL, 1);
- m->flags |= PG_MAPPED | PG_WRITEABLE | PG_REFERENCED;
+ PAGE_SET_FLAG(m, PG_MAPPED | PG_WRITEABLE | PG_REFERENCED);
}
vm_map_unlock(map);
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 398a9eb..9205540 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.132 1998/07/14 12:14:58 bde Exp $
+ * $Id: vm_map.c,v 1.133 1998/08/06 08:33:19 dfr Exp $
*/
/*
@@ -542,9 +542,9 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
new_entry->offset = offset;
if (object) {
if ((object->ref_count > 1) || (object->shadow_count != 0)) {
- object->flags &= ~OBJ_ONEMAPPING;
+ vm_object_clear_flag(object, OBJ_ONEMAPPING);
} else {
- object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(object, OBJ_ONEMAPPING);
}
}
@@ -758,7 +758,7 @@ vm_map_simplify_entry(map, entry)
if (startaddr > entry->start) \
_vm_map_clip_start(map, entry, startaddr); \
else if (entry->object.vm_object && (entry->object.vm_object->ref_count == 1)) \
- entry->object.vm_object->flags |= OBJ_ONEMAPPING; \
+ vm_object_set_flag(entry->object.vm_object, OBJ_ONEMAPPING); \
}
/*
@@ -808,7 +808,8 @@ _vm_map_clip_start(map, entry, start)
if ((entry->eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP)) == 0) {
if (new_entry->object.vm_object->ref_count == 1)
- new_entry->object.vm_object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(new_entry->object.vm_object,
+ OBJ_ONEMAPPING);
vm_object_reference(new_entry->object.vm_object);
}
}
@@ -826,7 +827,7 @@ _vm_map_clip_start(map, entry, start)
if (endaddr < entry->end) \
_vm_map_clip_end(map, entry, endaddr); \
else if (entry->object.vm_object && (entry->object.vm_object->ref_count == 1)) \
- entry->object.vm_object->flags |= OBJ_ONEMAPPING; \
+ vm_object_set_flag(entry->object.vm_object, OBJ_ONEMAPPING); \
}
/*
@@ -871,7 +872,8 @@ _vm_map_clip_end(map, entry, end)
if ((entry->eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP)) == 0) {
if (new_entry->object.vm_object->ref_count == 1)
- new_entry->object.vm_object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(new_entry->object.vm_object,
+ OBJ_ONEMAPPING);
vm_object_reference(new_entry->object.vm_object);
}
}
@@ -1770,7 +1772,7 @@ vm_map_delete(map, start, end)
entry = first_entry->next;
object = entry->object.vm_object;
if (object && (object->ref_count == 1) && (object->shadow_count == 0))
- object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(object, OBJ_ONEMAPPING);
} else {
entry = first_entry;
vm_map_clip_start(map, entry, start);
@@ -1972,7 +1974,7 @@ vm_map_split(entry)
vm_object_reference(source); /* Referenced by new_object */
TAILQ_INSERT_TAIL(&source->shadow_head,
new_object, shadow_list);
- source->flags &= ~OBJ_ONEMAPPING;
+ vm_object_clear_flag(source, OBJ_ONEMAPPING);
new_object->backing_object_offset =
orig_object->backing_object_offset + offidxstart;
new_object->backing_object = source;
@@ -1988,16 +1990,16 @@ vm_map_split(entry)
if (m == NULL)
continue;
if (m->flags & PG_BUSY) {
- m->flags |= PG_WANTED;
+ PAGE_SET_FLAG(m, PG_WANTED);
tsleep(m, PVM, "spltwt", 0);
goto retry;
}
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
vm_page_protect(m, VM_PROT_NONE);
vm_page_rename(m, new_object, idx);
m->dirty = VM_PAGE_BITS_ALL;
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
}
if (orig_object->type == OBJT_SWAP) {
@@ -2072,7 +2074,7 @@ vm_map_copy_entry(src_map, dst_map, src_entry, dst_entry)
}
vm_object_reference(src_object);
- src_object->flags &= ~OBJ_ONEMAPPING;
+ vm_object_clear_flag(src_object, OBJ_ONEMAPPING);
dst_entry->object.vm_object = src_object;
src_entry->eflags |= (MAP_ENTRY_COW|MAP_ENTRY_NEEDS_COPY);
dst_entry->eflags |= (MAP_ENTRY_COW|MAP_ENTRY_NEEDS_COPY);
@@ -2151,7 +2153,7 @@ vmspace_fork(vm1)
old_entry->eflags &= ~MAP_ENTRY_NEEDS_COPY;
object = old_entry->object.vm_object;
}
- object->flags &= ~OBJ_ONEMAPPING;
+ vm_object_clear_flag(object, OBJ_ONEMAPPING);
/*
* Clone the entry, referencing the sharing map.
@@ -2610,7 +2612,7 @@ vm_uiomove(mapa, srcobject, cp, cnta, uaddra, npages)
/*
* Set the object optimization hint flag
*/
- srcobject->flags |= OBJ_OPT;
+ vm_object_set_flag(srcobject, OBJ_OPT);
vm_object_reference(srcobject);
entry->object.vm_object = srcobject;
@@ -2668,7 +2670,7 @@ vm_uiomove(mapa, srcobject, cp, cnta, uaddra, npages)
/*
* Set the object optimization hint flag
*/
- srcobject->flags |= OBJ_OPT;
+ vm_object_set_flag(srcobject, OBJ_OPT);
vm_object_reference(srcobject);
if (oldobject) {
@@ -2694,7 +2696,7 @@ vm_uiomove(mapa, srcobject, cp, cnta, uaddra, npages)
*/
} else {
- srcobject->flags |= OBJ_OPT;
+ vm_object_set_flag(srcobject, OBJ_OPT);
vm_object_reference(srcobject);
pmap_remove (map->pmap, uaddr, tend);
@@ -2821,7 +2823,7 @@ m_inretry:
vm_object_deallocate(robject);
}
- object->flags &= ~OBJ_OPT;
+ vm_object_clear_flag(object, OBJ_OPT);
}
#include "opt_ddb.h"
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 6ef1c6d..4879535 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_meter.c 8.4 (Berkeley) 1/4/94
- * $Id: vm_meter.c,v 1.24 1998/03/28 10:33:27 bde Exp $
+ * $Id: vm_meter.c,v 1.25 1998/03/30 09:56:49 phk Exp $
*/
#include <sys/param.h>
@@ -138,7 +138,7 @@ vmtotal SYSCTL_HANDLER_ARGS
for (object = TAILQ_FIRST(&vm_object_list);
object != NULL;
object = TAILQ_NEXT(object,object_list))
- object->flags &= ~OBJ_ACTIVE;
+ vm_object_clear_flag(object, OBJ_ACTIVE);
/*
* Calculate process statistics.
*/
@@ -181,7 +181,7 @@ vmtotal SYSCTL_HANDLER_ARGS
if ((entry->eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP)) ||
entry->object.vm_object == NULL)
continue;
- entry->object.vm_object->flags |= OBJ_ACTIVE;
+ vm_object_set_flag(entry->object.vm_object, OBJ_ACTIVE);
paging |= entry->object.vm_object->paging_in_progress;
}
if (paging)
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index b66d5c7..b33fac6 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -38,7 +38,7 @@
* from: Utah $Hdr: vm_mmap.c 1.6 91/10/21$
*
* @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94
- * $Id: vm_mmap.c,v 1.80 1998/07/05 11:56:52 dfr Exp $
+ * $Id: vm_mmap.c,v 1.81 1998/07/15 02:32:35 bde Exp $
*/
/*
@@ -747,7 +747,7 @@ mincore(p, uap)
mincoreinfo |= MINCORE_MODIFIED_OTHER;
if ((m->flags & PG_REFERENCED) ||
pmap_ts_referenced(VM_PAGE_TO_PHYS(m))) {
- m->flags |= PG_REFERENCED;
+ PAGE_SET_FLAG(m, PG_REFERENCED);
mincoreinfo |= MINCORE_REFERENCED_OTHER;
}
}
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 1af903f..dc7421f 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_object.c,v 1.125 1998/07/14 12:26:15 bde Exp $
+ * $Id: vm_object.c,v 1.126 1998/08/06 08:33:19 dfr Exp $
*/
/*
@@ -153,7 +153,7 @@ _vm_object_allocate(type, size, object)
object->flags = 0;
object->id = ++objidnumber;
if ((object->type == OBJT_DEFAULT) || (object->type == OBJT_SWAP))
- object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(object, OBJ_ONEMAPPING);
object->behavior = OBJ_NORMAL;
object->paging_in_progress = 0;
object->resident_page_count = 0;
@@ -275,7 +275,7 @@ vm_object_vndeallocate(object)
object->ref_count--;
if (object->ref_count == 0) {
vp->v_flag &= ~VTEXT;
- object->flags &= ~OBJ_OPT;
+ vm_object_clear_flag(object, OBJ_OPT);
}
vrele(vp);
}
@@ -317,7 +317,7 @@ vm_object_deallocate(object)
* objects.
*/
if ((object->ref_count == 2) && (object->shadow_count == 0)) {
- object->flags |= OBJ_ONEMAPPING;
+ vm_object_set_flag(object, OBJ_ONEMAPPING);
object->ref_count--;
return;
} else if ((object->ref_count == 2) && (object->shadow_count == 1)) {
@@ -385,7 +385,7 @@ doterm:
TAILQ_REMOVE(&temp->shadow_head, object, shadow_list);
temp->shadow_count--;
if (temp->ref_count == 0)
- temp->flags &= ~OBJ_OPT;
+ vm_object_clear_flag(temp, OBJ_OPT);
temp->generation++;
object->backing_object = NULL;
}
@@ -411,7 +411,7 @@ vm_object_terminate(object)
/*
* Make sure no one uses us.
*/
- object->flags |= OBJ_DEAD;
+ vm_object_set_flag(object, OBJ_DEAD);
/*
* wait for the pageout daemon to be done with the object
@@ -461,7 +461,7 @@ vm_object_terminate(object)
if (p->busy || (p->flags & PG_BUSY))
printf("vm_object_terminate: freeing busy page\n");
#endif
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
vm_page_free(p);
cnt.v_pfree++;
}
@@ -540,7 +540,7 @@ vm_object_page_clean(object, start, end, flags)
vp = object->handle;
- object->flags |= OBJ_CLEANING;
+ vm_object_set_flag(object, OBJ_CLEANING);
tstart = start;
if (end == 0) {
@@ -550,12 +550,12 @@ vm_object_page_clean(object, start, end, flags)
}
for(p = TAILQ_FIRST(&object->memq); p; p = TAILQ_NEXT(p, listq)) {
- p->flags |= PG_CLEANCHK;
+ PAGE_SET_FLAG(p, PG_CLEANCHK);
vm_page_protect(p, VM_PROT_READ);
}
if ((tstart == 0) && (tend == object->size)) {
- object->flags &= ~(OBJ_WRITEABLE|OBJ_MIGHTBEDIRTY);
+ vm_object_clear_flag(object, OBJ_WRITEABLE|OBJ_MIGHTBEDIRTY);
}
rescan:
@@ -569,19 +569,19 @@ rescan:
(pi < tstart) || (pi >= tend) ||
(p->valid == 0) ||
((p->queue - p->pc) == PQ_CACHE)) {
- p->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(p, PG_CLEANCHK);
continue;
}
vm_page_test_dirty(p);
if ((p->dirty & p->valid) == 0) {
- p->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(p, PG_CLEANCHK);
continue;
}
s = splvm();
while ((p->flags & PG_BUSY) || p->busy) {
- p->flags |= PG_WANTED | PG_REFERENCED;
+ PAGE_SET_FLAG(p, PG_WANTED | PG_REFERENCED);
tsleep(p, PVM, "vpcwai", 0);
if (object->generation != curgeneration) {
splx(s);
@@ -597,12 +597,12 @@ rescan:
(tp->busy != 0))
break;
if((tp->queue - tp->pc) == PQ_CACHE) {
- tp->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(tp, PG_CLEANCHK);
break;
}
vm_page_test_dirty(tp);
if ((tp->dirty & tp->valid) == 0) {
- tp->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(tp, PG_CLEANCHK);
break;
}
maf[ i - 1 ] = tp;
@@ -622,12 +622,12 @@ rescan:
(tp->busy != 0))
break;
if((tp->queue - tp->pc) == PQ_CACHE) {
- tp->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(tp, PG_CLEANCHK);
break;
}
vm_page_test_dirty(tp);
if ((tp->dirty & tp->valid) == 0) {
- tp->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(tp, PG_CLEANCHK);
break;
}
mab[ i - 1 ] = tp;
@@ -641,14 +641,14 @@ rescan:
for(i=0;i<maxb;i++) {
int index = (maxb - i) - 1;
ma[index] = mab[i];
- ma[index]->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(ma[index], PG_CLEANCHK);
}
- p->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(p, PG_CLEANCHK);
ma[maxb] = p;
for(i=0;i<maxf;i++) {
int index = (maxb + i) + 1;
ma[index] = maf[i];
- ma[index]->flags &= ~PG_CLEANCHK;
+ PAGE_CLEAR_FLAG(ma[index], PG_CLEANCHK);
}
runlen = maxb + maxf + 1;
@@ -657,7 +657,7 @@ rescan:
for (i = 0; i<runlen; i++) {
if (ma[i]->valid & ma[i]->dirty) {
vm_page_protect(ma[i], VM_PROT_READ);
- ma[i]->flags |= PG_CLEANCHK;
+ PAGE_SET_FLAG(ma[i], PG_CLEANCHK);
}
}
if (object->generation != curgeneration)
@@ -666,7 +666,7 @@ rescan:
VOP_FSYNC(vp, NULL, (pagerflags & VM_PAGER_PUT_SYNC)?MNT_WAIT:0, curproc);
- object->flags &= ~OBJ_CLEANING;
+ vm_object_clear_flag(object, OBJ_CLEANING);
return;
}
@@ -719,7 +719,7 @@ vm_object_pmap_copy(object, start, end)
vm_page_protect(p, VM_PROT_READ);
}
- object->flags &= ~OBJ_WRITEABLE;
+ vm_object_clear_flag(object, OBJ_WRITEABLE);
}
/*
@@ -770,7 +770,7 @@ vm_object_pmap_remove(object, start, end)
vm_page_protect(p, VM_PROT_NONE);
}
if ((start == 0) && (object->size == end))
- object->flags &= ~OBJ_WRITEABLE;
+ vm_object_clear_flag(object, OBJ_WRITEABLE);
}
/*
@@ -884,7 +884,7 @@ vm_object_shadow(object, offset, length)
result->backing_object = source;
if (source) {
TAILQ_INSERT_TAIL(&source->shadow_head, result, shadow_list);
- source->flags &= ~OBJ_ONEMAPPING;
+ vm_object_clear_flag(source, OBJ_ONEMAPPING);
source->shadow_count++;
source->generation++;
}
@@ -941,7 +941,7 @@ vm_object_qcollapse(object)
p = next;
continue;
}
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
new_pindex = p->pindex - backing_offset_index;
if (p->pindex < backing_offset_index ||
@@ -1053,7 +1053,7 @@ vm_object_collapse(object)
if (backing_object->ref_count == 1) {
- backing_object->flags |= OBJ_DEAD;
+ vm_object_set_flag(backing_object, OBJ_DEAD);
/*
* We can collapse the backing object.
*
@@ -1066,7 +1066,7 @@ vm_object_collapse(object)
while ((p = TAILQ_FIRST(&backing_object->memq)) != 0) {
new_pindex = p->pindex - backing_offset_index;
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
/*
* If the parent has a page here, or if this
@@ -1216,7 +1216,7 @@ vm_object_collapse(object)
p = TAILQ_NEXT(p, listq)) {
new_pindex = p->pindex - backing_offset_index;
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
/*
* If the parent has a page here, or if this
@@ -1236,7 +1236,7 @@ vm_object_collapse(object)
return;
}
- pp->flags |= PG_BUSY;
+ PAGE_SET_FLAG(pp, PG_BUSY);
if ((pp->valid == 0) &&
!vm_pager_has_page(object, OFF_TO_IDX(object->paging_offset) + new_pindex, NULL, NULL)) {
/*
@@ -1341,7 +1341,7 @@ again:
continue;
}
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
vm_page_protect(p, VM_PROT_NONE);
vm_page_free(p);
}
@@ -1374,7 +1374,7 @@ again:
}
}
- p->flags |= PG_BUSY;
+ PAGE_SET_FLAG(p, PG_BUSY);
vm_page_protect(p, VM_PROT_NONE);
vm_page_free(p);
}
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 4855a80..9897393 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_object.h,v 1.49 1998/05/04 17:12:53 dyson Exp $
+ * $Id: vm_object.h,v 1.50 1998/08/06 08:33:19 dfr Exp $
*/
/*
@@ -72,6 +72,7 @@
#define _VM_OBJECT_
#include <sys/queue.h>
+#include <machine/atomic.h>
enum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_DEAD };
typedef enum obj_type objtype_t;
@@ -162,21 +163,35 @@ extern vm_object_t kmem_object;
#ifdef KERNEL
static __inline void
+vm_object_set_flag(vm_object_t object, u_int bits)
+{
+ atomic_set_short(&object->flags, bits);
+}
+
+static __inline void
+vm_object_clear_flag(vm_object_t object, u_int bits)
+{
+ atomic_clear_short(&object->flags, bits);
+}
+
+static __inline void
vm_object_pip_add(vm_object_t object, int i)
{
- int s = splvm();
- object->paging_in_progress += i;
- splx(s);
+ atomic_add_short(&object->paging_in_progress, i);
+}
+
+static __inline void
+vm_object_pip_subtract(vm_object_t object, int i)
+{
+ atomic_subtract_short(&object->paging_in_progress, i);
}
static __inline void
vm_object_pip_wakeup(vm_object_t object)
{
- int s = splvm();
- object->paging_in_progress--;
- splx(s);
+ atomic_subtract_short(&object->paging_in_progress, 1);
if ((object->flags & OBJ_PIPWNT) && object->paging_in_progress == 0) {
- object->flags &= ~OBJ_PIPWNT;
+ vm_object_clear_flag(object, OBJ_PIPWNT);
wakeup(object);
}
}
@@ -189,7 +204,7 @@ vm_object_pip_sleep(vm_object_t object, char *waitid)
if (object->paging_in_progress) {
s = splvm();
if (object->paging_in_progress) {
- object->flags |= OBJ_PIPWNT;
+ vm_object_set_flag(object, OBJ_PIPWNT);
tsleep(object, PVM, waitid, 0);
}
splx(s);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index b32229b..03abeec 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91
- * $Id: vm_page.c,v 1.104 1998/07/15 04:17:55 bde Exp $
+ * $Id: vm_page.c,v 1.105 1998/07/26 18:15:20 dfr Exp $
*/
/*
@@ -403,7 +403,7 @@ vm_page_insert(m, object, pindex)
*/
TAILQ_INSERT_TAIL(&object->memq, m, listq);
- m->flags |= PG_TABLED;
+ PAGE_SET_FLAG(m, PG_TABLED);
m->object->page_hint = m;
m->object->generation++;
@@ -446,9 +446,9 @@ vm_page_remove(m)
}
#endif
- m->flags &= ~PG_BUSY;
+ PAGE_CLEAR_FLAG(m, PG_BUSY);
if (m->flags & PG_WANTED) {
- m->flags &= ~PG_WANTED;
+ PAGE_CLEAR_FLAG(m, PG_WANTED);
wakeup(m);
}
@@ -484,7 +484,7 @@ vm_page_remove(m)
object->generation++;
m->object = NULL;
- m->flags &= ~PG_TABLED;
+ PAGE_CLEAR_FLAG(m, PG_TABLED);
}
/*
@@ -940,7 +940,7 @@ vm_page_alloc(object, pindex, page_req)
m->flags = PG_ZERO | PG_BUSY;
} else if (qtype == PQ_CACHE) {
oldobject = m->object;
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
vm_page_remove(m);
m->flags = PG_BUSY;
} else {
@@ -1011,7 +1011,7 @@ vm_page_sleep(vm_page_t m, char *msg, char *busy) {
int s;
s = splvm();
if ((busy && *busy) || (m->flags & PG_BUSY)) {
- m->flags |= PG_WANTED;
+ PAGE_SET_FLAG(m, PG_WANTED);
tsleep(m, PVM, msg, 0);
slept = 1;
}
@@ -1247,7 +1247,7 @@ vm_page_wire(m)
}
(*vm_page_queues[PQ_NONE].lcnt)++;
m->wire_count++;
- m->flags |= PG_MAPPED;
+ PAGE_SET_FLAG(m, PG_MAPPED);
}
/*
@@ -1384,7 +1384,7 @@ retrylookup:
s = splvm();
while ((object->generation == generation) &&
(m->busy || (m->flags & PG_BUSY))) {
- m->flags |= PG_WANTED | PG_REFERENCED;
+ PAGE_SET_FLAG(m, PG_WANTED | PG_REFERENCED);
tsleep(m, PVM, "pgrbwt", 0);
if ((allocflags & VM_ALLOC_RETRY) == 0) {
splx(s);
@@ -1394,7 +1394,7 @@ retrylookup:
splx(s);
goto retrylookup;
} else {
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
return m;
}
}
@@ -1633,7 +1633,7 @@ again1:
pqtype = m->queue - m->pc;
if (pqtype == PQ_CACHE) {
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
vm_page_free(m);
}
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 4bfa8c1..fc6d61c 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -61,7 +61,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_page.h,v 1.42 1998/06/30 08:01:30 jmg Exp $
+ * $Id: vm_page.h,v 1.43 1998/08/22 15:24:09 mckay Exp $
*/
/*
@@ -74,6 +74,8 @@
#include "opt_vmpage.h"
#include <vm/pmap.h>
+#include <machine/atomic.h>
+
/*
* Management of resident (logical) pages.
*
@@ -279,24 +281,30 @@ extern vm_offset_t last_phys_addr; /* physical address for last_page */
* Functions implemented as macros
*/
+#define PAGE_SET_FLAG(m, bits) atomic_set_short(&(m)->flags, bits)
+
+#define PAGE_CLEAR_FLAG(m, bits) atomic_clear_short(&(m)->flags, bits)
+
#define PAGE_ASSERT_WAIT(m, interruptible) { \
- (m)->flags |= PG_WANTED; \
+ PAGE_SET_FLAG(m, PG_WANTED); \
assert_wait((int) (m), (interruptible)); \
}
#define PAGE_WAKEUP(m) { \
- (m)->flags &= ~PG_BUSY; \
+ PAGE_CLEAR_FLAG(m, PG_BUSY); \
if (((m)->flags & PG_WANTED) && ((m)->busy == 0)) { \
- (m)->flags &= ~PG_WANTED; \
+ PAGE_CLEAR_FLAG(m, PG_WANTED); \
wakeup((m)); \
} \
}
+#define PAGE_BUSY(m) atomic_add_char(&(m)->busy, 1)
+
#define PAGE_BWAKEUP(m) { \
- (m)->busy--; \
+ atomic_subtract_char(&(m)->busy, 1); \
if ((((m)->flags & (PG_WANTED | PG_BUSY)) == PG_WANTED) && \
((m)->busy == 0)) { \
- (m)->flags &= ~PG_WANTED; \
+ PAGE_CLEAR_FLAG(m, PG_WANTED); \
wakeup((m)); \
} \
}
@@ -373,11 +381,11 @@ vm_page_protect(vm_page_t mem, int prot)
if (prot == VM_PROT_NONE) {
if (mem->flags & (PG_WRITEABLE|PG_MAPPED)) {
pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_NONE);
- mem->flags &= ~(PG_WRITEABLE|PG_MAPPED);
+ PAGE_CLEAR_FLAG(mem, PG_WRITEABLE|PG_MAPPED);
}
} else if ((prot == VM_PROT_READ) && (mem->flags & PG_WRITEABLE)) {
pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_READ);
- mem->flags &= ~PG_WRITEABLE;
+ PAGE_CLEAR_FLAG(mem, PG_WRITEABLE);
}
}
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index ce39df5..2175622 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -65,7 +65,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: vm_pageout.c,v 1.123 1998/07/10 17:58:35 alex Exp $
+ * $Id: vm_pageout.c,v 1.124 1998/08/06 08:33:19 dfr Exp $
*/
/*
@@ -362,7 +362,7 @@ vm_pageout_flush(mc, count, flags)
int i;
for (i = 0; i < count; i++) {
- mc[i]->busy++;
+ PAGE_BUSY(mc[i]);
vm_page_protect(mc[i], VM_PROT_READ);
}
@@ -476,7 +476,7 @@ vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only)
actcount = pmap_ts_referenced(VM_PAGE_TO_PHYS(p));
if (actcount) {
- p->flags |= PG_REFERENCED;
+ PAGE_SET_FLAG(p, PG_REFERENCED);
} else if (p->flags & PG_REFERENCED) {
actcount = 1;
}
@@ -485,7 +485,7 @@ vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only)
(p->flags & PG_REFERENCED)) {
vm_page_activate(p);
p->act_count += actcount;
- p->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(p, PG_REFERENCED);
} else if (p->queue == PQ_ACTIVE) {
if ((p->flags & PG_REFERENCED) == 0) {
p->act_count -= min(p->act_count, ACT_DECLINE);
@@ -500,7 +500,7 @@ vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only)
}
} else {
vm_page_activate(p);
- p->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(p, PG_REFERENCED);
if (p->act_count < (ACT_MAX - ACT_ADVANCE))
p->act_count += ACT_ADVANCE;
s = splvm();
@@ -599,7 +599,7 @@ vm_pageout_page_free(vm_page_t m) {
vbusy(vp);
}
- m->flags |= PG_BUSY;
+ PAGE_SET_FLAG(m, PG_BUSY);
vm_page_protect(m, VM_PROT_NONE);
vm_page_free(m);
vm_object_deallocate(object);
@@ -683,7 +683,7 @@ rescan0:
* If the object is not being used, we ignore previous references.
*/
if (m->object->ref_count == 0) {
- m->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(m, PG_REFERENCED);
pmap_clear_reference(VM_PAGE_TO_PHYS(m));
/*
@@ -708,7 +708,7 @@ rescan0:
* inactive queue again.
*/
if ((m->flags & PG_REFERENCED) != 0) {
- m->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(m, PG_REFERENCED);
actcount = pmap_ts_referenced(VM_PAGE_TO_PHYS(m));
vm_page_activate(m);
m->act_count += (actcount + ACT_ADVANCE + 1);
@@ -906,7 +906,7 @@ rescan0:
/*
* Since we have "tested" this bit, we need to clear it now.
*/
- m->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(m, PG_REFERENCED);
/*
* Only if an object is currently being used, do we use the
@@ -1095,7 +1095,7 @@ vm_pageout_page_stats()
actcount = 0;
if (m->flags & PG_REFERENCED) {
- m->flags &= ~PG_REFERENCED;
+ PAGE_CLEAR_FLAG(m, PG_REFERENCED);
actcount += 1;
}
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index fdda3e3..50b77a0 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -38,7 +38,7 @@
* SUCH DAMAGE.
*
* from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91
- * $Id: vnode_pager.c,v 1.93 1998/07/11 07:46:16 bde Exp $
+ * $Id: vnode_pager.c,v 1.94 1998/07/11 11:30:46 bde Exp $
*/
/*
@@ -442,7 +442,7 @@ vnode_pager_input_smlfs(object, m)
}
vm_pager_unmap_page(kva);
pmap_clear_modify(VM_PAGE_TO_PHYS(m));
- m->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(m, PG_ZERO);
if (error) {
return VM_PAGER_ERROR;
}
@@ -506,7 +506,7 @@ vnode_pager_input_old(object, m)
}
pmap_clear_modify(VM_PAGE_TO_PHYS(m));
m->dirty = 0;
- m->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(m, PG_ZERO);
return error ? VM_PAGER_ERROR : VM_PAGER_OK;
}
@@ -773,7 +773,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
vm_page_set_validclean(mt, 0, nvalid);
}
- mt->flags &= ~PG_ZERO;
+ PAGE_CLEAR_FLAG(mt, PG_ZERO);
if (i != reqpage) {
/*
OpenPOWER on IntegriCloud