aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2014-06-04 19:05:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:51 -0400
commit7f39dda9d86fb4f4f17af0de170decf125726f8c (patch)
tree30c87e21eb0ad3366033a8d93f70a08dc02b7df0
parentf9625c48ecca4aa850b50ecbbb540228ad59e92e (diff)
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: 88c22088bf23 ("mm: optimize page_lock_anon_vma() fast-path") Reported-by: Dave Jones <davej@redhat.com> Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/rmap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mm/rmap.c b/mm/rmap.c
index 9c3e77396d1a..10aef960d3d0 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -103,6 +103,7 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)
103 * LOCK should suffice since the actual taking of the lock must 103 * LOCK should suffice since the actual taking of the lock must
104 * happen _before_ what follows. 104 * happen _before_ what follows.
105 */ 105 */
106 might_sleep();
106 if (rwsem_is_locked(&anon_vma->root->rwsem)) { 107 if (rwsem_is_locked(&anon_vma->root->rwsem)) {
107 anon_vma_lock_write(anon_vma); 108 anon_vma_lock_write(anon_vma);
108 anon_vma_unlock_write(anon_vma); 109 anon_vma_unlock_write(anon_vma);
@@ -426,8 +427,9 @@ struct anon_vma *page_get_anon_vma(struct page *page)
426 * above cannot corrupt). 427 * above cannot corrupt).
427 */ 428 */
428 if (!page_mapped(page)) { 429 if (!page_mapped(page)) {
430 rcu_read_unlock();
429 put_anon_vma(anon_vma); 431 put_anon_vma(anon_vma);
430 anon_vma = NULL; 432 return NULL;
431 } 433 }
432out: 434out:
433 rcu_read_unlock(); 435 rcu_read_unlock();
@@ -477,9 +479,9 @@ struct anon_vma *page_lock_anon_vma_read(struct page *page)
477 } 479 }
478 480
479 if (!page_mapped(page)) { 481 if (!page_mapped(page)) {
482 rcu_read_unlock();
480 put_anon_vma(anon_vma); 483 put_anon_vma(anon_vma);
481 anon_vma = NULL; 484 return NULL;
482 goto out;
483 } 485 }
484 486
485 /* we pinned the anon_vma, its safe to sleep */ 487 /* we pinned the anon_vma, its safe to sleep */