On Tue, 2010-04-13 at 21:00 +0900, KOSAKI Motohiro wrote:
Well, that refcount stuff still relies on DESTROY_BY_RCU :-)
Anyway, it also looks like a lot of races are avoided by ordering the
rmap_add/remove calls wrt to adding/removing the page to/from the LRU.
Rmap calls come from LRU pages, and it looks like rmap state is only
changed for pages that are not on the LRU.
I still have to go through all that code again to make sure, but I
couldn't find a race between page_add_anon_rmap() and
page_lock_anon_vma() due to that.
If there is, we need to look at page_mapped() before page->mapping
because page_add_anon_rmap() first increments the mapcount and only then
adjusts the mapping, so the existing order in page_anon_lock_vma() can
end up dereferencing a long dead anon_vma.
--