[PATCH v2 hmm 8/9] mm/hmm: do not set pfns when returning an error code
Jason Gunthorpe
jgg at ziepe.ca
Fri Mar 27 20:00:20 UTC 2020
From: Jason Gunthorpe <jgg at mellanox.com>
Most places that return an error code, like -EFAULT, do not set
HMM_PFN_ERROR, only two places do this.
Resolve this inconsistency by never setting the pfns on an error
exit. This doesn't seem like a worthwhile thing to do anyhow.
If for some reason it becomes important, it makes more sense to directly
return the address of the failing page rather than have the caller scan
for the HMM_PFN_ERROR.
No caller inspects the pnfs output array if hmm_range_fault() fails.
Reviewed-by: Christoph Hellwig <hch at lst.de>
Signed-off-by: Jason Gunthorpe <jgg at mellanox.com>
---
mm/hmm.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/mm/hmm.c b/mm/hmm.c
index dc826898979bc5..e875d9ef0968fd 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -77,17 +77,14 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end,
unsigned int required_fault, struct mm_walk *walk)
{
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(!required_fault);
hmm_vma_walk->last = addr;
if (!vma)
- goto out_error;
+ return -EFAULT;
if (required_fault & HMM_NEED_WRITE_FAULT) {
if (!(vma->vm_flags & VM_WRITE))
@@ -95,15 +92,10 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end,
fault_flags |= FAULT_FLAG_WRITE;
}
- for (; addr < end; addr += PAGE_SIZE, i++)
+ for (; addr < end; addr += PAGE_SIZE)
if (handle_mm_fault(vma, addr, fault_flags) & VM_FAULT_ERROR)
- goto out_error;
-
+ return -EFAULT;
return -EBUSY;
-
-out_error:
- pfns[i] = range->values[HMM_PFN_ERROR];
- return -EFAULT;
}
static unsigned int hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
@@ -286,7 +278,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
/* Report error for everything else */
pte_unmap(ptep);
- *pfn = range->values[HMM_PFN_ERROR];
return -EFAULT;
}
@@ -572,9 +563,6 @@ static const struct mm_walk_ops hmm_walk_ops = {
*
* This is similar to get_user_pages(), except that it can read the page tables
* without mutating them (ie causing faults).
- *
- * On error, for one virtual address in the range, the function will mark the
- * corresponding HMM pfn entry with an error flag.
*/
long hmm_range_fault(struct hmm_range *range)
{
--
2.25.2
More information about the amd-gfx
mailing list