diff options
author | dillon <dillon@FreeBSD.org> | 1999-12-12 03:19:33 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 1999-12-12 03:19:33 +0000 |
commit | b66fb2c64801a0ee59e638561bfd8d3fe36b647c (patch) | |
tree | d1cf00b34925743e2181910ae5e72af2d03be373 /sys/vm/vm_map.c | |
parent | aeee88b81a6982928d45c0d80c325cd8372bbab0 (diff) | |
download | FreeBSD-src-b66fb2c64801a0ee59e638561bfd8d3fe36b647c.zip FreeBSD-src-b66fb2c64801a0ee59e638561bfd8d3fe36b647c.tar.gz |
Add MAP_NOSYNC feature to mmap(), and MADV_NOSYNC and MADV_AUTOSYNC to
madvise().
This feature prevents the update daemon from gratuitously flushing
dirty pages associated with a mapped file-backed region of memory. The
system pager will still page the memory as necessary and the VM system
will still be fully coherent with the filesystem. Modifications made
by other means to the same area of memory, for example by write(), are
unaffected. The feature works on a page-granularity basis.
MAP_NOSYNC allows one to use mmap() to share memory between processes
without incuring any significant filesystem overhead, putting it in
the same performance category as SysV Shared memory and anonymous memory.
Reviewed by: julian, alc, dg
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r-- | sys/vm/vm_map.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index eaa65f7..a1f422d3 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -460,6 +460,9 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, KASSERT(object == NULL, ("vm_map_insert: paradoxical MAP_NOFAULT request")); } + if (cow & MAP_DISABLE_SYNCER) + protoeflags |= MAP_ENTRY_NOSYNC; + if (object) { /* * When object is non-NULL, it could be shared with another @@ -539,13 +542,15 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, * Update the free space hint */ if ((map->first_free == prev_entry) && - (prev_entry->end >= new_entry->start)) + (prev_entry->end >= new_entry->start)) { map->first_free = new_entry; + } - if (cow & (MAP_PREFAULT|MAP_PREFAULT_PARTIAL)) + if (cow & (MAP_PREFAULT|MAP_PREFAULT_PARTIAL)) { pmap_object_init_pt(map->pmap, start, object, OFF_TO_IDX(offset), end - start, cow & MAP_PREFAULT_PARTIAL); + } return (KERN_SUCCESS); } @@ -1026,6 +1031,8 @@ vm_map_madvise(map, start, end, behav) case MADV_NORMAL: case MADV_SEQUENTIAL: case MADV_RANDOM: + case MADV_NOSYNC: + case MADV_AUTOSYNC: modify_map = 1; vm_map_lock(map); break; @@ -1077,6 +1084,12 @@ vm_map_madvise(map, start, end, behav) case MADV_RANDOM: vm_map_entry_set_behavior(current, MAP_ENTRY_BEHAV_RANDOM); break; + case MADV_NOSYNC: + current->eflags |= MAP_ENTRY_NOSYNC; + break; + case MADV_AUTOSYNC: + current->eflags &= ~MAP_ENTRY_NOSYNC; + break; default: break; } |