linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache.
@ 2013-08-09 21:34 Ning Qu
  2013-08-10  5:22 ` Ning Qu
  0 siblings, 1 reply; 5+ messages in thread
From: Ning Qu @ 2013-08-09 21:34 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Matthew Wilcox, Kirill A. Shutemov, linux-fsdevel, Hugh Dickins,
	Mel Gorman, Al Viro, Andrew Morton, Andrea Arcangeli,
	linux-kernel, Andi Kleen, Wu Fengguang, Jan Kara, Dave Hansen,
	linux-mm, Hillf Danton, Ning Qu

In vma_adjust, the current code grabs i_mmap_mutex before calling
vma_adjust_trans_huge. This used to be fine until huge page in page
cache comes in. The problem is the underlying function
split_file_huge_page will also grab the i_mmap_mutex before splitting
the huge page in page cache. Obviously this is causing deadlock
situation.

This fix is to move the vma_adjust_trans_huge before grab the lock for
file, the same as what the function is currently doing for anonymous
memory. Tested, everything works fine so far.

Signed-off-by: Ning Qu <quning@google.com>
---
 mm/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 519ce78..accf1b3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -750,6 +750,8 @@ again: remove_next = 1 + (end > next->vm_end);
  }
  }

+ vma_adjust_trans_huge(vma, start, end, adjust_next);
+
  if (file) {
  mapping = file->f_mapping;
  if (!(vma->vm_flags & VM_NONLINEAR)) {
@@ -773,8 +775,6 @@ again: remove_next = 1 + (end > next->vm_end);
  }
  }

- vma_adjust_trans_huge(vma, start, end, adjust_next);
-
  anon_vma = vma->anon_vma;
  if (!anon_vma && adjust_next)
  anon_vma = next->anon_vma;
-- 
1.8.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache
@ 2013-08-10  6:28 Ning Qu
  2013-08-12 13:55 ` Kirill A. Shutemov
  0 siblings, 1 reply; 5+ messages in thread
From: Ning Qu @ 2013-08-10  6:28 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Matthew Wilcox, Kirill A. Shutemov, linux-fsdevel, Hugh Dickins,
	Mel Gorman, Al Viro, Andrew Morton, Andrea Arcangeli,
	linux-kernel, Andi Kleen, Wu Fengguang, Jan Kara, Dave Hansen,
	linux-mm, Hillf Danton, Ning Qu

In vma_adjust, the current code grabs i_mmap_mutex before calling
vma_adjust_trans_huge. This used to be fine until huge page in page
cache comes in. The problem is the underlying function
split_file_huge_page will also grab the i_mmap_mutex before splitting
the huge page in page cache. Obviously this is causing deadlock
situation.

This fix is to move the vma_adjust_trans_huge before grab the lock for
file, the same as what the function is currently doing for anonymous
memory.

Tested, everything works fine so far.

Signed-off-by: Ning Qu <quning@google.com>
---
mm/mmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 519ce78..accf1b3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -750,6 +750,8 @@ again:			remove_next = 1 + (end > next->vm_end);
		}
	}

+	vma_adjust_trans_huge(vma, start, end, adjust_next);
+
	if (file) {
		mapping = file->f_mapping;
		if (!(vma->vm_flags & VM_NONLINEAR)) {
@@ -773,8 +775,6 @@ again:			remove_next = 1 + (end > next->vm_end);
		}
	}

-	vma_adjust_trans_huge(vma, start, end, adjust_next);
-
	anon_vma = vma->anon_vma;
	if (!anon_vma && adjust_next)
		anon_vma = next->anon_vma;
-- 
1.8.3


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-12 16:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-09 21:34 [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache Ning Qu
2013-08-10  5:22 ` Ning Qu
  -- strict thread matches above, loose matches on Subject: below --
2013-08-10  6:28 Ning Qu
2013-08-12 13:55 ` Kirill A. Shutemov
2013-08-12 16:42   ` Ning Qu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).