summaryrefslogtreecommitdiffstats
path: root/mm/hmm.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-03-16 14:53:10 +0100
committerJason Gunthorpe <jgg@mellanox.com>2020-03-26 14:33:37 -0300
commit5a0c38d307afde167175602aa52ca4e6c5c42c44 (patch)
treebc2395d96e90d7d6fd75a5d37868ce91cad5b9cd /mm/hmm.c
parentf8c888a304e12074d941428b4aa1b13f04dd54ee (diff)
downloadlinux-5a0c38d307afde167175602aa52ca4e6c5c42c44.tar.bz2
mm: merge hmm_vma_do_fault into into hmm_vma_walk_hole_
There is no good reason for this split, as it just obsfucates the flow. Link: https://lore.kernel.org/r/20200316135310.899364-6-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'mm/hmm.c')
-rw-r--r--mm/hmm.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/mm/hmm.c b/mm/hmm.c
index b15bf4041803..a5f4f8010965 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -33,32 +33,6 @@ struct hmm_vma_walk {
unsigned int flags;
};
-static int hmm_vma_do_fault(struct mm_walk *walk, unsigned long addr,
- bool write_fault, uint64_t *pfn)
-{
- unsigned int flags = FAULT_FLAG_REMOTE;
- struct hmm_vma_walk *hmm_vma_walk = walk->private;
- struct hmm_range *range = hmm_vma_walk->range;
- struct vm_area_struct *vma = walk->vma;
- vm_fault_t ret;
-
- if (!vma)
- goto err;
-
- if (write_fault)
- flags |= FAULT_FLAG_WRITE;
-
- ret = handle_mm_fault(vma, addr, flags);
- if (ret & VM_FAULT_ERROR)
- goto err;
-
- return -EBUSY;
-
-err:
- *pfn = range->values[HMM_PFN_ERROR];
- return -EFAULT;
-}
-
static int hmm_pfns_fill(unsigned long addr, unsigned long end,
struct hmm_range *range, enum hmm_pfn_value_e value)
{
@@ -90,24 +64,32 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end,
{
struct hmm_vma_walk *hmm_vma_walk = walk->private;
struct hmm_range *range = hmm_vma_walk->range;
+ struct vm_area_struct *vma = walk->vma;
uint64_t *pfns = range->pfns;
unsigned long i = (addr - range->start) >> PAGE_SHIFT;
+ unsigned int fault_flags = FAULT_FLAG_REMOTE;
WARN_ON_ONCE(!fault && !write_fault);
hmm_vma_walk->last = addr;
- if (write_fault && walk->vma && !(walk->vma->vm_flags & VM_WRITE))
- return -EPERM;
-
- for (; addr < end; addr += PAGE_SIZE, i++) {
- int ret;
+ if (!vma)
+ goto out_error;
- ret = hmm_vma_do_fault(walk, addr, write_fault, &pfns[i]);
- if (ret != -EBUSY)
- return ret;
+ if (write_fault) {
+ if (!(vma->vm_flags & VM_WRITE))
+ return -EPERM;
+ fault_flags |= FAULT_FLAG_WRITE;
}
+ for (; addr < end; addr += PAGE_SIZE, i++)
+ if (handle_mm_fault(vma, addr, fault_flags) & VM_FAULT_ERROR)
+ goto out_error;
+
return -EBUSY;
+
+out_error:
+ pfns[i] = range->values[HMM_PFN_ERROR];
+ return -EFAULT;
}
static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,