All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mlock: operate on any regions with protection != PROT_NONE
@ 2011-02-01  1:03 Michel Lespinasse
  2011-02-01  1:08 ` Michel Lespinasse
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michel Lespinasse @ 2011-02-01  1:03 UTC (permalink / raw)
  To: linux-mm, Andrew Morton, Linus Torvalds
  Cc: Tao Ma, KOSAKI Motohiro, Rik van Riel, Hugh Dickins

As Tao Ma noticed, change 5ecfda0 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.

I am proposing to 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).

Please review. I am proposing this as a candidate for 2.6.38 inclusion,
because of the behavior change with blktrace.

diff --git a/mm/mlock.c b/mm/mlock.c
index 13e81ee..c3924c7f 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -178,6 +178,13 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma,
 	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;
 

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-03  0:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01  1:03 [PATCH] mlock: operate on any regions with protection != PROT_NONE Michel Lespinasse
2011-02-01  1:08 ` Michel Lespinasse
2011-02-01  5:59 ` Linus Torvalds
2011-02-01  6:36   ` Michel Lespinasse
2011-02-01 17:57   ` Rik van Riel
2011-02-01 17:57 ` Rik van Riel
2011-02-03  0:57   ` KOSAKI Motohiro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.