Peter Zijlstra d08b3851da [PATCH] mm: tracking shared dirty pages
Tracking of dirty pages in shared writeable mmap()s.

The idea is simple: write protect clean shared writeable pages, catch the
write-fault, make writeable and set dirty.  On page write-back clean all the
PTE dirty bits and write protect them once again.

The implementation is a tad harder, mainly because the default
backing_dev_info capabilities were too loosely maintained.  Hence it is not
enough to test the backing_dev_info for cap_account_dirty.

The current heuristic is as follows, a VMA is eligible when:
 - its shared writeable
    (vm_flags & (VM_WRITE|VM_SHARED)) == (VM_WRITE|VM_SHARED)
 - it is not a 'special' mapping
    (vm_flags & (VM_PFNMAP|VM_INSERTPAGE)) == 0
 - the backing_dev_info is cap_account_dirty
    mapping_cap_account_dirty(vma->vm_file->f_mapping)
 - f_op->mmap() didn't change the default page protection

Page from remap_pfn_range() are explicitly excluded because their COW
semantics are already horrid enough (see vm_normal_page() in do_wp_page()) and
because they don't have a backing store anyway.

mprotect() is taught about the new behaviour as well.  However it overrides
the last condition.

Cleaning the pages on write-back is done with page_mkclean() a new rmap call.
It can be called on any page, but is currently only implemented for mapped
pages, if the page is found the be of a VMA that accounts dirty pages it will
also wrprotect the PTE.

Finally, in fs/buffers.c:try_to_free_buffers(); remove clear_page_dirty() from
under ->private_lock.  This seems to be safe, since ->private_lock is used to
serialize access to the buffers, not the page itself.  This is needed because
clear_page_dirty() will call into page_mkclean() and would thereby violate
locking order.

[dhowells@redhat.com: Provide a page_mkclean() implementation for NOMMU]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 08:48:44 -07:00
..
2006-08-14 12:54:28 -07:00
2006-08-06 08:57:48 -07:00
2006-08-27 11:01:30 -07:00
2006-08-27 11:01:31 -07:00
2006-06-26 18:35:02 +02:00
2006-01-11 18:42:13 -08:00
2006-01-10 08:01:25 -08:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2006-09-22 23:24:30 -04:00
2006-01-08 20:12:40 -08:00
2006-08-27 11:01:31 -07:00
2006-04-02 13:37:19 +02:00
2006-04-11 13:53:33 +02:00
2006-07-12 12:52:55 -07:00
2005-10-30 17:37:32 -08:00
2006-08-21 10:02:50 +02:00
2006-06-26 09:58:17 -07:00
2006-08-14 13:10:59 -07:00
2006-03-28 09:16:08 -08:00
2006-06-23 07:42:49 -07:00
2006-06-26 09:58:17 -07:00
2005-11-07 18:18:11 -08:00
2005-04-16 15:20:36 -07:00
2006-03-23 07:38:11 -08:00
2006-03-23 07:38:11 -08:00
2006-03-23 07:38:12 -08:00
2006-06-23 07:42:49 -07:00
2005-04-16 15:20:36 -07:00