mm: mprotect: use pmd_trans_unstable instead of taking the pmd_lock
authorAndrea Arcangeli <[email protected]>
Wed, 22 Feb 2017 23:44:12 +0000 (15:44 -0800)
committerLinus Torvalds <[email protected]>
Thu, 23 Feb 2017 00:41:29 +0000 (16:41 -0800)
commit175ad4f1e7a29c8f914254e2e6316c50671e027a
treeecc4847e73314b2cc2db78f6a24e2f9e78b47905
parent7a0c4cf85b856430af62a907dd65dfc51438d24f
mm: mprotect: use pmd_trans_unstable instead of taking the pmd_lock

pmd_trans_unstable does an atomic read on the pmd so it doesn't require
the pmd_lock for the same check.

This also removes the special assumption that the mmap_sem is hold for
writing if prot_numa is not set.  userfaultfd will hold the mmap_sem
only for reading in change_pte_range like prot_numa, but it will not set
prot_numa.

This is always a valid micro-optimization regardless of userfaultfd.

[[email protected]: drop unneeded pmd_trans_unstable(pmd) check after __split_huge_pmd()]
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andrea Arcangeli <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Michael Rapoport <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/mprotect.c