From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx119.postini.com [74.125.245.119]) by kanga.kvack.org (Postfix) with SMTP id F08E06B0031 for ; Sat, 10 Aug 2013 01:22:36 -0400 (EDT) Received: by mail-wg0-f43.google.com with SMTP id z12so4098037wgg.10 for ; Fri, 09 Aug 2013 22:22:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ning Qu Date: Fri, 9 Aug 2013 22:22:14 -0700 Message-ID: Subject: Re: [PATCH] thp: Fix deadlock situation in vma_adjust with huge page in page cache. Content-Type: multipart/alternative; boundary=001a11c23c7e2d5c1004e39114b2 Sender: owner-linux-mm@kvack.org List-ID: To: "Kirill A. Shutemov" Cc: Matthew Wilcox , "Kirill A. Shutemov" , linux-fsdevel@vger.kernel.org, Hugh Dickins , Mel Gorman , Al Viro , Andrew Morton , Andrea Arcangeli , linux-kernel@vger.kernel.org, Andi Kleen , Wu Fengguang , Jan Kara , Dave Hansen , linux-mm@kvack.org, Hillf Danton , Ning Qu --001a11c23c7e2d5c1004e39114b2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Oh, sorry about that. Let me see what's going on here. Best wishes, --=20 Ning Qu (=E6=9B=B2=E5=AE=81) | Software Engineer | quning@google.com | +1-4= 08-418-6066 On Fri, Aug 9, 2013 at 2:34 PM, 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 > --- > 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 =3D 1 + (end > next->vm_end); > } > } > > + vma_adjust_trans_huge(vma, start, end, adjust_next); > + > if (file) { > mapping =3D file->f_mapping; > if (!(vma->vm_flags & VM_NONLINEAR)) { > @@ -773,8 +775,6 @@ again: remove_next =3D 1 + (end > next->vm_end); > } > } > > - vma_adjust_trans_huge(vma, start, end, adjust_next); > - > anon_vma =3D vma->anon_vma; > if (!anon_vma && adjust_next) > anon_vma =3D next->anon_vma; > -- > 1.8.3 > --001a11c23c7e2d5c1004e39114b2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Oh, sorry about that. Let me see what's going on here.=

Best wish= es,
--=C2=A0
= Ning Qu (=E6=9B=B2=E5=AE=81)=C2=A0|=C2=A0Software Engineer |=C2=A0qu= ning@google.com=C2=A0|=C2=A0+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@goog= le.com>
---
=C2=A0mm/mmap.c | 4 ++--
=C2=A01 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 =3D 1 + (end > next->vm_end);<= br> =C2=A0 }
=C2=A0 }

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

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

--001a11c23c7e2d5c1004e39114b2-- -- 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: email@kvack.org