linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Michal Hocko <mhocko@suse.cz>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Chen Gang <gang.chen.5i5j@gmail.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Eric Dumazet <edumazet@google.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: mm: possible deadlock in mm_take_all_locks
Date: Sun, 10 Jan 2016 09:05:32 +0100	[thread overview]
Message-ID: <CACT4Y+bbrEoQs2Od3gPQwqk-Y6nLWrXJJCbSFrRduwSrZk7vRA@mail.gmail.com> (raw)
In-Reply-To: <20160108232352.GA13046@node.shutemov.name>

On Sat, Jan 9, 2016 at 12:23 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
> On Fri, Jan 08, 2016 at 05:58:33PM +0100, Dmitry Vyukov wrote:
>> Hello,
>>
>> I've hit the following deadlock warning while running syzkaller fuzzer
>> on commit b06f3a168cdcd80026276898fd1fee443ef25743. As far as I
>> understand this is a false positive, because both call stacks are
>> protected by mm_all_locks_mutex.
>
> +Michal
>
> I don't think it's false positive.
>
> The reason we don't care about order of taking i_mmap_rwsem is that we
> never takes i_mmap_rwsem under other i_mmap_rwsem, but that's not true for
> i_mmap_rwsem vs. hugetlbfs_i_mmap_rwsem_key. That's why we have the
> annotation in the first place.
>
> See commit b610ded71918 ("hugetlb: fix lockdep splat caused by pmd
> sharing").

Description of b610ded71918 suggests that that code takes hugetlb
mutex first and them normal page mutex. In this patch you take them in
the opposite order: normal mutex, then hugetlb mutex. Won't this patch
only increase probability of deadlocks? Shouldn't you take them in the
opposite order?


> Consider totally untested patch below.
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 2ce04a649f6b..63aefcf409e1 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -3203,7 +3203,16 @@ int mm_take_all_locks(struct mm_struct *mm)
>         for (vma = mm->mmap; vma; vma = vma->vm_next) {
>                 if (signal_pending(current))
>                         goto out_unlock;
> -               if (vma->vm_file && vma->vm_file->f_mapping)
> +               if (vma->vm_file && vma->vm_file->f_mapping &&
> +                               !is_vm_hugetlb_page(vma))
> +                       vm_lock_mapping(mm, vma->vm_file->f_mapping);
> +       }
> +
> +       for (vma = mm->mmap; vma; vma = vma->vm_next) {
> +               if (signal_pending(current))
> +                       goto out_unlock;
> +               if (vma->vm_file && vma->vm_file->f_mapping &&
> +                               is_vm_hugetlb_page(vma))
>                         vm_lock_mapping(mm, vma->vm_file->f_mapping);
>         }
>
> --
>  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>

  reply	other threads:[~2016-01-10  8:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08 16:58 Dmitry Vyukov
2016-01-08 23:23 ` Kirill A. Shutemov
2016-01-10  8:05   ` Dmitry Vyukov [this message]
2016-01-10 20:39     ` Kirill A. Shutemov
2016-01-11  9:04       ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACT4Y+bbrEoQs2Od3gPQwqk-Y6nLWrXJJCbSFrRduwSrZk7vRA@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=edumazet@google.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=glider@google.com \
    --cc=kcc@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sasha.levin@oracle.com \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox