From 637315ed9cfa6bf5fbad54adb32280509c88d812 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 9 Nov 2003 22:09:04 +0000 Subject: - Remove Giant from msync(2). Giant is still acquired by the lower layers if we drop into the pmap or vnode layers. - Migrate the handling of zero-length msync(2)s into vm_map_sync() so that multithread applications can't change the map between implementing the zero-length hack in msync(2) and reacquiring the map lock in vm_map_sync(). Reviewed by: tegge --- sys/vm/vm_map.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sys/vm/vm_map.c') diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 40db4c13a992..0fb7fc1c7f1f 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1952,6 +1952,13 @@ done: * If syncio is TRUE, dirty pages are written synchronously. * If invalidate is TRUE, any cached pages are freed as well. * + * If the size of the region from start to end is zero, we are + * supposed to flush all modified pages within the region containing + * start. Unfortunately, a region can be split or coalesced with + * neighboring regions, making it difficult to determine what the + * original region was. Therefore, we approximate this requirement by + * flushing the current region containing start. + * * Returns an error if any part of the specified range is not mapped. */ int @@ -1973,6 +1980,9 @@ vm_map_sync( if (!vm_map_lookup_entry(map, start, &entry)) { vm_map_unlock_read(map); return (KERN_INVALID_ADDRESS); + } else if (start == end) { + start = entry->start; + end = entry->end; } /* * Make a first pass to check for holes. -- cgit v1.3