Merge branch 'for-linus-1' of git://git.infradead.org/mtd-2.6
[firefly-linux-kernel-4.4.55.git] / mm / memory.c
index 820b4c4810f0b67164dd6ce2e34f69edcfca474f..9da8cab1b1b0abceae9569a794447f3ddb0c1134 100644 (file)
@@ -1569,6 +1569,8 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                                        fault_flags |= FAULT_FLAG_WRITE;
                                if (nonblocking)
                                        fault_flags |= FAULT_FLAG_ALLOW_RETRY;
+                               if (foll_flags & FOLL_NOWAIT)
+                                       fault_flags |= (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT);
 
                                ret = handle_mm_fault(mm, vma, start,
                                                        fault_flags);
@@ -1598,7 +1600,8 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                                }
 
                                if (ret & VM_FAULT_RETRY) {
-                                       *nonblocking = 0;
+                                       if (nonblocking)
+                                               *nonblocking = 0;
                                        return i;
                                }
 
@@ -2768,7 +2771,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
        swp_entry_t entry;
        pte_t pte;
        int locked;
-       struct mem_cgroup *ptr = NULL;
+       struct mem_cgroup *ptr;
        int exclusive = 0;
        int ret = 0;
 
@@ -3711,6 +3714,22 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
        return buf - old_buf;
 }
 
+/**
+ * access_remote_vm - access another process' address space
+ * @mm:                the mm_struct of the target address space
+ * @addr:      start address to access
+ * @buf:       source or destination buffer
+ * @len:       number of bytes to transfer
+ * @write:     whether the access is a write
+ *
+ * The caller must hold a reference on @mm.
+ */
+int access_remote_vm(struct mm_struct *mm, unsigned long addr,
+               void *buf, int len, int write)
+{
+       return __access_remote_vm(NULL, mm, addr, buf, len, write);
+}
+
 /*
  * Access another process' address space.
  * Source/target buffer must be kernel space,