summaryrefslogtreecommitdiffstats
path: root/mm/mlock.c
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-11-21 23:42:06 +0000
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-11-21 23:42:06 +0000
commit300e812db26f4aa022e346f5fb9af1af134d98d8 (patch)
tree382b45253a704087e8aa0c770bf3fc2ad67d4b02 /mm/mlock.c
parent4420dd2b306f1997232a13462bca0d420be5b1b8 (diff)
parentcfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff)
Merge commit 'v3.2-rc2' into fbdev-next
Diffstat (limited to 'mm/mlock.c')
-rw-r--r--mm/mlock.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/mm/mlock.c b/mm/mlock.c
index 048260c4e02..4f4f53bdc65 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -14,7 +14,7 @@
#include <linux/mempolicy.h>
#include <linux/syscalls.h>
#include <linux/sched.h>
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/rmap.h>
#include <linux/mmzone.h>
#include <linux/hugetlb.h>
@@ -110,7 +110,15 @@ void munlock_vma_page(struct page *page)
if (TestClearPageMlocked(page)) {
dec_zone_page_state(page, NR_MLOCK);
if (!isolate_lru_page(page)) {
- int ret = try_to_munlock(page);
+ int ret = SWAP_AGAIN;
+
+ /*
+ * Optimization: if the page was mapped just once,
+ * that's our mapping and we don't need to check all the
+ * other vmas.
+ */
+ if (page_mapcount(page) > 1)
+ ret = try_to_munlock(page);
/*
* did try_to_unlock() succeed or punt?
*/
@@ -549,7 +557,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
if (!can_do_mlock())
goto out;
- lru_add_drain_all(); /* flush pagevec */
+ if (flags & MCL_CURRENT)
+ lru_add_drain_all(); /* flush pagevec */
down_write(&current->mm->mmap_sem);