Skip to content

Commit

Permalink
mm/hmm: simplify hmm_vma_walk_hugetlb_entry()
Browse files Browse the repository at this point in the history
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.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Christoph Hellwig authored and Jason Gunthorpe committed Mar 26, 2020
1 parent 9626816 commit 4505069
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions mm/hmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
bool fault, write_fault;
spinlock_t *ptl;
pte_t entry;
int ret = 0;

ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte);
entry = huge_ptep_get(pte);
Expand All @@ -572,23 +571,17 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags,
&fault, &write_fault);
if (fault || write_fault) {
ret = -ENOENT;
goto unlock;
spin_unlock(ptl);
return hmm_vma_walk_hole_(addr, end, fault, write_fault, walk);
}

pfn = pte_pfn(entry) + ((start & ~hmask) >> PAGE_SHIFT);
for (; addr < end; addr += PAGE_SIZE, i++, pfn++)
range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) |
cpu_flags;
hmm_vma_walk->last = end;

unlock:
spin_unlock(ptl);

if (ret == -ENOENT)
return hmm_vma_walk_hole_(addr, end, fault, write_fault, walk);

return ret;
return 0;
}
#else
#define hmm_vma_walk_hugetlb_entry NULL
Expand Down

0 comments on commit 4505069

Please sign in to comment.