The patch titled mlock: operate on any regions with protection != PROT_NONE has been removed from the -mm tree. Its filename was mlock-operate-on-any-regions-with-protection-=-prot_none.patch This patch was dropped because it was merged into mainline or a subsystem tree The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: mlock: operate on any regions with protection != PROT_NONE From: Michel Lespinasse <walken@xxxxxxxxxx> As Tao Ma noticed, 5ecfda0 ("mlock: avoid dirtying pages and triggering writeback") breaks blktrace. This is because blktrace mmaps a file with PROT_WRITE permissions but without PROT_READ, so my attempt to not unnecessarity break COW during mlock ended up causing mlock to fail with a permission problem. Let mlock ignore vma protection in all cases except PROT_NONE. In particular, mlock should not fail for PROT_WRITE regions (as in the blktrace case, which broke at 5ecfda0) or for PROT_EXEC regions (which seem to me like they were always broken). Signed-off-by: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Reported-by: Tao Ma <tm@xxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Acked-by: Rik van Riel <riel@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mlock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN mm/mlock.c~mlock-operate-on-any-regions-with-protection-=-prot_none mm/mlock.c --- a/mm/mlock.c~mlock-operate-on-any-regions-with-protection-=-prot_none +++ a/mm/mlock.c @@ -178,6 +178,13 @@ static long __mlock_vma_pages_range(stru if ((vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE) gup_flags |= FOLL_WRITE; + /* + * We want mlock to succeed for regions that have any permissions + * other than PROT_NONE. + */ + if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) + gup_flags |= FOLL_FORCE; + if (vma->vm_flags & VM_LOCKED) gup_flags |= FOLL_MLOCK; _ Patches currently in -mm which might be from walken@xxxxxxxxxx are origin.patch mm-allow-gup-to-fail-instead-of-waiting-on-a-page.patch mm-allow-gup-to-fail-instead-of-waiting-on-a-page-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html