Messages in this thread | | | Subject | Re: [PATCH -v2] rmap: make anon_vma_prepare link in all the anon_vmas of a mergeable VMA | From | Peter Zijlstra <> | Date | Wed, 14 Apr 2010 16:27:08 +0200 |
| |
On Tue, 2010-04-13 at 21:00 +0900, KOSAKI Motohiro wrote: > > [ with the preemptible mmu_gather patches I introduce a refcount to > > the anon_vma, and then with atomic_inc_not_zero() we can add a > > guarantee that the returned anon_vma is alive ] > > Indeed. refcount is best way. anon_vma DESTROY_BY_RCU stuff seems > overengineering, I think. this is fastest, but anon_vma allocation is not > (and was not) fork/exit bottleneck point. So, I guess most simply way is > best.
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.
| |