Commit 7f39dda9 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds
Browse files

mm: fix sleeping function warning from __put_anon_vma

Trinity reports BUG:

  sleeping function called from invalid context at kernel/locking/rwsem.c:47
  in_atomic(): 0, irqs_disabled(): 0, pid: 5787, name: trinity-c27

__might_sleep < down_write < __put_anon_vma < page_get_anon_vma <
migrate_pages < compact_zone < compact_zone_order < try_to_compact_pages ..

Right, since conversion to mutex then rwsem, we should not put_anon_vma()
from inside an rcu_read_lock()ed section: fix the two places that did so.
And add might_sleep() to anon_vma_free(), as suggested by Peter Zijlstra.

Fixes: 88c22088

 ("mm: optimize page_lock_anon_vma() fast-path")
Reported-by: default avatarDave Jones <>
Signed-off-by: default avatarHugh Dickins <>
Cc: Peter Zijlstra <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent f9625c48
......@@ -103,6 +103,7 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)
* LOCK should suffice since the actual taking of the lock must
* happen _before_ what follows.
if (rwsem_is_locked(&anon_vma->root->rwsem)) {
......@@ -426,8 +427,9 @@ struct anon_vma *page_get_anon_vma(struct page *page)
* above cannot corrupt).
if (!page_mapped(page)) {
anon_vma = NULL;
return NULL;
......@@ -477,9 +479,9 @@ struct anon_vma *page_lock_anon_vma_read(struct page *page)
if (!page_mapped(page)) {
anon_vma = NULL;
goto out;
return NULL;
/* we pinned the anon_vma, its safe to sleep */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment