Hugh Dickins db114b83ab ksm: hold anon_vma in rmap_item
For full functionality, page_referenced_one() and try_to_unmap_one() need
to know the vma: to pass vma down to arch-dependent flushes, or to observe
VM_LOCKED or VM_EXEC.  But KSM keeps no record of vma: nor can it, since
vmas get split and merged without its knowledge.

Instead, note page's anon_vma in its rmap_item when adding to stable tree:
all the vmas which might map that page are listed by its anon_vma.

page_referenced_ksm() and try_to_unmap_ksm() then traverse the anon_vma,
first to find the probable vma, that which matches rmap_item's mm; but if
that is not enough to locate all instances, traverse again to try the
others.  This catches those occasions when fork has duplicated a pte of a
ksm page, but ksmd has not yet come around to assign it an rmap_item.

But each rmap_item in the stable tree which refers to an anon_vma needs to
take a reference to it.  Andrea's anon_vma design cleverly avoided a
reference count (an anon_vma was free when its list of vmas was empty),
but KSM now needs to add that.  Is a 32-bit count sufficient?  I believe
so - the anon_vma is only free when both count is 0 and list is empty.

Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Izik Eidus <ieidus@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Wright <chrisw@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-15 08:53:19 -08:00
..
2009-12-03 13:49:43 +01:00
2009-11-10 12:31:43 +01:00
2009-04-01 08:59:13 -07:00
2009-12-10 15:02:50 +01:00
2009-06-16 19:47:28 -07:00
2009-12-15 08:53:19 -08:00
2009-12-15 08:53:17 -08:00
2009-12-15 08:53:19 -08:00
2009-10-02 13:29:29 +09:00
2009-12-15 08:53:17 -08:00
2009-12-15 08:53:19 -08:00
2009-09-22 07:17:35 -07:00
2009-12-15 08:53:17 -08:00
2009-12-15 08:53:19 -08:00
2009-12-15 08:53:17 -08:00
2009-12-15 08:53:16 -08:00
2008-06-12 18:05:41 -07:00
2009-12-15 08:53:19 -08:00
2009-12-15 08:53:16 -08:00
2009-12-15 08:53:19 -08:00
2009-06-23 12:50:05 -07:00