* [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
* RE: [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache
2013-08-10 6:28 [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache Ning Qu
@ 2013-08-12 13:55 ` Kirill A. Shutemov
2013-08-12 16:42 ` Ning Qu
0 siblings, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2013-08-12 13:55 UTC (permalink / raw)
To: Ning Qu
Cc: Kirill A. Shutemov, 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
Ning Qu wrote:
> 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>
Thanks, applied.
--
Kirill A. Shutemov
--
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 [flat|nested] 5+ messages in thread
* Re: [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache
2013-08-12 13:55 ` Kirill A. Shutemov
@ 2013-08-12 16:42 ` Ning Qu
0 siblings, 0 replies; 5+ messages in thread
From: Ning Qu @ 2013-08-12 16:42 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
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
That's great!
Best wishes,
--
Ning Qu
On Mon, Aug 12, 2013 at 6:55 AM, Kirill A. Shutemov <
kirill.shutemov@linux.intel.com> wrote:
> Ning Qu wrote:
> > 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>
>
> Thanks, applied.
>
> --
> Kirill A. Shutemov
>
[-- Attachment #2: Type: text/html, Size: 1423 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [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
* Re: [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, 0 replies; 5+ messages in thread
From: Ning Qu @ 2013-08-10 5:22 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
[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]
Oh, sorry about that. Let me see what's going on here.
Best wishes,
--
Ning Qu (曲宁) | Software Engineer | quning@google.com | +1-408-418-6066
On Fri, Aug 9, 2013 at 2:34 PM, Ning Qu <quning@google.com> wrote:
> 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
>
[-- Attachment #2: Type: text/html, Size: 4037 bytes --]
^ permalink raw reply [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-10 6:28 [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache Ning Qu
2013-08-12 13:55 ` Kirill A. Shutemov
2013-08-12 16:42 ` Ning Qu
-- strict thread matches above, loose matches on Subject: below --
2013-08-09 21:34 Ning Qu
2013-08-10 5:22 ` 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).