diff options
author | Matthew Dillon <dillon@FreeBSD.org> | 1999-12-12 03:19:33 +0000 |
---|---|---|
committer | Matthew Dillon <dillon@FreeBSD.org> | 1999-12-12 03:19:33 +0000 |
commit | 4f79d873c19c33d2b41899b5a0a2672e858e2051 (patch) | |
tree | 0b3e6a3e45e7ec9c304d18652b63808c21eae649 /sys/vm/vm_mmap.c | |
parent | 8828590563b92b41a478c67c5905a37a525a2f04 (diff) | |
download | src-4f79d873c19c33d2b41899b5a0a2672e858e2051.tar.gz src-4f79d873c19c33d2b41899b5a0a2672e858e2051.zip |
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
Notes
Notes:
svn path=/head/; revision=54467
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r-- | sys/vm/vm_mmap.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index ce349acb2d49..1721fd3e1bac 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) |