shekita@provolone.cs.wisc.edu (E Shekita) (07/19/90)
I have a question about memory objects and copy-on-write (COW). Let's suppose I have a memory object server that is in charge of paging object X. Further suppose that when a memory_object_data_request() comes in for a page in X, my memory object server does the following: (1) vm_allocate()'s a page P in its virtual address space (2) reads the requested page from disk into P (3) provides P to Mach via memory_object_data_provided() (4) vm_deallocate()'s P The question is: will P be mapped COW in step (3), or will Mach copy P immediately in step (3)? Obviously it would be nice if P was mapped COW in step (3), because then an unnecessary copy is avoided. Initially, I though that P will definitely be mapped COW, just as in, say, vm_copy(). However, P is backed by a different memory object (the default pager) than X, and I have recently been told that a physical page cannot be shared by two different memory objects. Consequently, I'm not so sure what happens.... Can anyone at CMU set me straight? thanks in advance -- Gene
shekita@provolone.cs.wisc.edu (E Shekita) (07/21/90)
>Let's suppose I have a memory object server that is in charge of >paging object X. Further suppose that when a memory_object_data_request() >comes in for a page in X, my memory object server does the following: > > (1) vm_allocate()'s a page P in its virtual address space > (2) reads the requested page from disk into P > (3) provides P to Mach via memory_object_data_provided() > (4) vm_deallocate()'s P > >The question is: will P be mapped COW in step (3), or will Mach copy >P immediately in step (3)? Obviously it would be nice if P was mapped >COW in step (3), because then an unnecessary copy is avoided. Since nobody replied immediately, I ran a few tests, and using vm_statistics(), it looks like P is copied immediately in step (3) and not mapped COW... Oh well. In this case, it probably doesn't matter since the vm_allocate() in step (1) zeros P anyway, and this is as expensive as a copy. Given what takes place, the above steps are more efficiently written: (1) vm_allocate() page P once for all time when the program starts up. Then on memory_object_datarequest(): (2) reads the requested page from disk into P. (3) provide P to Mach via memory_object_data_provided(). Mach will copy the data it needs out of P. Gene