summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1999-12-12 03:19:33 +0000
committerdillon <dillon@FreeBSD.org>1999-12-12 03:19:33 +0000
commitb66fb2c64801a0ee59e638561bfd8d3fe36b647c (patch)
treed1cf00b34925743e2181910ae5e72af2d03be373 /sys/vm/vm_mmap.c
parentaeee88b81a6982928d45c0d80c325cd8372bbab0 (diff)
downloadFreeBSD-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_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index ce349acb..1721fd3 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -626,7 +626,7 @@ madvise(p, uap)
/*
* Check for illegal behavior
*/
- if (uap->behav < 0 || uap->behav > MADV_FREE)
+ if (uap->behav < 0 || uap->behav > MADV_AUTOSYNC)
return (EINVAL);
/*
* Check for illegal addresses. Watch out for address wrap... Note
@@ -1046,9 +1046,10 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
flags |= MAP_SHARED;
}
- if ((flags & (MAP_ANON|MAP_SHARED)) == 0) {
+ if ((flags & (MAP_ANON|MAP_SHARED)) == 0)
docow |= MAP_COPY_ON_WRITE;
- }
+ if (flags & MAP_NOSYNC)
+ docow |= MAP_DISABLE_SYNCER;
#if defined(VM_PROT_READ_IS_EXEC)
if (prot & VM_PROT_READ)
OpenPOWER on IntegriCloud