From c6c6cc7efad7de66468002a16796bccf2d80c119 Mon Sep 17 00:00:00 2001 From: ups Date: Thu, 8 Nov 2007 19:35:36 +0000 Subject: [PATCH] Use VM_FAULT_DIRTY to fault in pages for write access in proc_rwmen. Otherwise copy on write may create an anonymous page that is not marked as dirty. Since writing data to these pages in this function also does not dirty these pages they may be later discarded by the pagedaemon. --- sys/kern/sys_process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index ff9640a12703..432138c3d70f 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -216,7 +216,7 @@ proc_rwmem(struct proc *p, struct uio *uio) vm_object_t backing_object, object = NULL; vm_offset_t pageno = 0; /* page number */ vm_prot_t reqprot; - int error, writing; + int error, fault_flags, writing; /* * Assert that someone has locked this vmspace. (Should be @@ -234,6 +234,7 @@ proc_rwmem(struct proc *p, struct uio *uio) writing = uio->uio_rw == UIO_WRITE; reqprot = writing ? (VM_PROT_WRITE | VM_PROT_OVERRIDE_WRITE) : VM_PROT_READ; + fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL; /* * Only map in one page at a time. We don't have to, but it @@ -268,7 +269,7 @@ proc_rwmem(struct proc *p, struct uio *uio) /* * Fault the page on behalf of the process */ - error = vm_fault(map, pageno, reqprot, VM_FAULT_NORMAL); + error = vm_fault(map, pageno, reqprot, fault_flags); if (error) { error = EFAULT; break;