]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - mm/rmap.c
Merge branches 'pci/host-designware', 'pci/host-imx6', 'pci/host-mvebu' and 'pci...
[mirror_ubuntu-zesty-kernel.git] / mm / rmap.c
index 11cf322f8133d7048d414c6f0eed227f6b12d3ac..9c3e77396d1a118edb8f2de7d16ff835ed214f0a 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1332,9 +1332,19 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
                BUG_ON(!page || PageAnon(page));
 
                if (locked_vma) {
-                       mlock_vma_page(page);   /* no-op if already mlocked */
-                       if (page == check_page)
+                       if (page == check_page) {
+                               /* we know we have check_page locked */
+                               mlock_vma_page(page);
                                ret = SWAP_MLOCK;
+                       } else if (trylock_page(page)) {
+                               /*
+                                * If we can lock the page, perform mlock.
+                                * Otherwise leave the page alone, it will be
+                                * eventually encountered again later.
+                                */
+                               mlock_vma_page(page);
+                               unlock_page(page);
+                       }
                        continue;       /* don't unmap */
                }