mm/hmm: make full use of walk_page_range()
authorRalph Campbell <rcampbell@nvidia.com>
Mon, 4 Nov 2019 22:21:40 +0000 (14:21 -0800)
committerJason Gunthorpe <jgg@mellanox.com>
Sat, 23 Nov 2019 23:56:45 +0000 (19:56 -0400)
commitd28c2c9a487708b9db519ce7fedc10333032c76b
tree651d078ef9d500fb46c53f66577f1bac8f9dcee7
parentd3eeb1d77c5d0af9df442db63722928238310a86
mm/hmm: make full use of walk_page_range()

hmm_range_fault() calls find_vma() and walk_page_range() in a loop.  This
is unnecessary duplication since walk_page_range() calls find_vma() in a
loop already.

Simplify hmm_range_fault() by defining a walk_test() callback function to
filter unhandled vmas.

This also fixes a bug where hmm_range_fault() was not checking start >=
vma->vm_start before checking vma->vm_flags so hmm_range_fault() could
return an error based on the wrong vma for the requested range.

It also fixes a bug when the vma has no read access and the caller did not
request a fault, there shouldn't be any error return code.

Link: https://lore.kernel.org/r/20191104222141.5173-2-rcampbell@nvidia.com
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Reviewed-by: Christoph Hellwig <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>
mm/hmm.c