Commit 45050692 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jason Gunthorpe

mm/hmm: simplify hmm_vma_walk_hugetlb_entry()

Remove the rather confusing goto label and just handle the fault case
directly in the branch checking for it.

Link: https://lore.kernel.org/r/20200316135310.899364-4-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 96268163
...@@ -559,7 +559,6 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, ...@@ -559,7 +559,6 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
bool fault, write_fault; bool fault, write_fault;
spinlock_t *ptl; spinlock_t *ptl;
pte_t entry; pte_t entry;
int ret = 0;
ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte); ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte);
entry = huge_ptep_get(pte); entry = huge_ptep_get(pte);
...@@ -572,8 +571,8 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, ...@@ -572,8 +571,8 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags, hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags,
&fault, &write_fault); &fault, &write_fault);
if (fault || write_fault) { if (fault || write_fault) {
ret = -ENOENT; spin_unlock(ptl);
goto unlock; return hmm_vma_walk_hole_(addr, end, fault, write_fault, walk);
} }
pfn = pte_pfn(entry) + ((start & ~hmask) >> PAGE_SHIFT); pfn = pte_pfn(entry) + ((start & ~hmask) >> PAGE_SHIFT);
...@@ -581,14 +580,8 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, ...@@ -581,14 +580,8 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) | range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) |
cpu_flags; cpu_flags;
hmm_vma_walk->last = end; hmm_vma_walk->last = end;
unlock:
spin_unlock(ptl); spin_unlock(ptl);
return 0;
if (ret == -ENOENT)
return hmm_vma_walk_hole_(addr, end, fault, write_fault, walk);
return ret;
} }
#else #else
#define hmm_vma_walk_hugetlb_entry NULL #define hmm_vma_walk_hugetlb_entry NULL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment