Fix the recently committed (and described) page writability nerf. The real
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 12 Jan 2007 22:12:53 +0000 (22:12 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 12 Jan 2007 22:12:53 +0000 (22:12 +0000)
commit70fc5283006abf89e499f860fc3a7eab0e8e104a
tree8db9908c18714cc029c62e0a26edd8a4c0421a4f
parent884d6eea55b71a538683718e0c44ae3966684f39
Fix the recently committed (and described) page writability nerf.  The real
kernel was unconditionally mapping writable pages read-only on read faults
in order to be able to take another fault on a write attempt.  This was needed
for early virtual kernel support in order to set the Modify bit in the
virtualized page table, but was being applied to ALL mappings rather then
just those installed by the virtual kernel.

Now the real kernel only does this for virtual kernel mappings.  Additionally,
the real kernel no longer makes the page read-only when clearing the Modify
bit in the real page table (in order to rearm the write fault).  When this
case occurs VPTE_M has already been set in the virtual page table and no
re-fault is required.

The virtual kernel now only needs to invalidate the real kernel's page
mapping when clearing the virtualized Modify bit in the virtual page table
(VPTE_M), in order to rearm the real kernel's write fault so it can detect
future modifications via the virtualized Modify bit.  Also, the virtual kernel
no longer needs to install read-only pages to detect the write fault.  This
allows the real kernel to do ALL the work required to handle VPTE_M and
make the actual page writable.  This greatly reduces the number of real
page faults that occur and greatly reduces the number of page faults which
have to be passed through to the virtual kernel.

This fix reduces fork() overhead for processes running under a virtual
kernel by 70%, from around 2100uS to around 650uS.
sys/libkern/mcount.c
sys/platform/pc32/i386/pmap.c
sys/platform/vkernel/platform/pmap.c
sys/vm/vm_fault.c