mm, rmap: Add yet more comments to page_get_anon_vma/page_lock_anon_vma
Inspired by an analysis from Hugh on why again all this doesn't explode in our face. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
139f37f5e1
commit
bc658c9603
@@ -352,6 +352,11 @@ void __init anon_vma_init(void)
|
|||||||
* The page might have been remapped to a different anon_vma or the anon_vma
|
* The page might have been remapped to a different anon_vma or the anon_vma
|
||||||
* returned may already be freed (and even reused).
|
* returned may already be freed (and even reused).
|
||||||
*
|
*
|
||||||
|
* In case it was remapped to a different anon_vma, the new anon_vma will be a
|
||||||
|
* child of the old anon_vma, and the anon_vma lifetime rules will therefore
|
||||||
|
* ensure that any anon_vma obtained from the page will still be valid for as
|
||||||
|
* long as we observe page_mapped() [ hence all those page_mapped() tests ].
|
||||||
|
*
|
||||||
* All users of this function must be very careful when walking the anon_vma
|
* All users of this function must be very careful when walking the anon_vma
|
||||||
* chain and verify that the page in question is indeed mapped in it
|
* chain and verify that the page in question is indeed mapped in it
|
||||||
* [ something equivalent to page_mapped_in_vma() ].
|
* [ something equivalent to page_mapped_in_vma() ].
|
||||||
@@ -421,7 +426,7 @@ struct anon_vma *page_lock_anon_vma(struct page *page)
|
|||||||
/*
|
/*
|
||||||
* If the page is still mapped, then this anon_vma is still
|
* If the page is still mapped, then this anon_vma is still
|
||||||
* its anon_vma, and holding the mutex ensures that it will
|
* its anon_vma, and holding the mutex ensures that it will
|
||||||
* not go away, see __put_anon_vma().
|
* not go away, see anon_vma_free().
|
||||||
*/
|
*/
|
||||||
if (!page_mapped(page)) {
|
if (!page_mapped(page)) {
|
||||||
mutex_unlock(&root_anon_vma->mutex);
|
mutex_unlock(&root_anon_vma->mutex);
|
||||||
|
Reference in New Issue
Block a user