diff options
author | kib <kib@FreeBSD.org> | 2013-07-11 05:47:26 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-07-11 05:47:26 +0000 |
commit | da0e8446db5fe341cf068d68a7c012392cb2b064 (patch) | |
tree | 9d8f98842785918ec9d4f13e8755f946b6eddccd | |
parent | c2cfac4ffcfbb4f2ff275d0ccb9622a92fb70d88 (diff) | |
download | FreeBSD-src-da0e8446db5fe341cf068d68a7c012392cb2b064.zip FreeBSD-src-da0e8446db5fe341cf068d68a7c012392cb2b064.tar.gz |
Never remove user-wired pages from an object when doing
msync(MS_INVALIDATE). The vm_fault_copy_entry() requires that object
range which corresponds to the user-wired vm_map_entry, is always
fully populated.
Add OBJPR_NOTWIRED flag for vm_object_page_remove() to request the
preserving behaviour, use it when calling vm_object_page_remove() from
vm_object_sync().
Reported and tested by: pho
Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
-rw-r--r-- | sys/vm/vm_object.c | 19 | ||||
-rw-r--r-- | sys/vm/vm_object.h | 1 |
2 files changed, 11 insertions, 9 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 1c20ca6..1d128bf 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1054,9 +1054,9 @@ vm_object_sync(vm_object_t object, vm_ooffset_t offset, vm_size_t size, */ flags = OBJPR_NOTMAPPED; else if (old_msync) - flags = 0; + flags = OBJPR_NOTWIRED; else - flags = OBJPR_CLEANONLY; + flags = OBJPR_CLEANONLY | OBJPR_NOTWIRED; vm_object_page_remove(object, OFF_TO_IDX(offset), OFF_TO_IDX(offset + size + PAGE_MASK), flags); } @@ -1892,7 +1892,8 @@ again: vm_page_lock(p); if ((wirings = p->wire_count) != 0 && (wirings = pmap_page_wired_mappings(p)) != p->wire_count) { - if ((options & OBJPR_NOTMAPPED) == 0) { + if ((options & (OBJPR_NOTWIRED | OBJPR_NOTMAPPED)) == + 0) { pmap_remove_all(p); /* Account for removal of wired mappings. */ if (wirings != 0) @@ -1902,8 +1903,7 @@ again: p->valid = 0; vm_page_undirty(p); } - vm_page_unlock(p); - continue; + goto next; } if (vm_page_sleep_if_busy(p, TRUE, "vmopar")) goto again; @@ -1912,12 +1912,12 @@ again: if ((options & OBJPR_CLEANONLY) != 0 && p->valid != 0) { if ((options & OBJPR_NOTMAPPED) == 0) pmap_remove_write(p); - if (p->dirty) { - vm_page_unlock(p); - continue; - } + if (p->dirty) + goto next; } if ((options & OBJPR_NOTMAPPED) == 0) { + if ((options & OBJPR_NOTWIRED) != 0 && wirings != 0) + goto next; pmap_remove_all(p); /* Account for removal of wired mappings. */ if (wirings != 0) { @@ -1929,6 +1929,7 @@ again: } } vm_page_free(p); +next: vm_page_unlock(p); } vm_object_pip_wakeup(object); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 05ab73d..e083b72 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -205,6 +205,7 @@ struct vm_object { */ #define OBJPR_CLEANONLY 0x1 /* Don't remove dirty pages. */ #define OBJPR_NOTMAPPED 0x2 /* Don't unmap pages. */ +#define OBJPR_NOTWIRED 0x4 /* Don't remove wired pages. */ TAILQ_HEAD(object_q, vm_object); |