mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast()
Subsystems (2)
John Hubbard
reviewerPATCH 1/1 mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast()
Instead of scattering these assertions across the drivers, do this assertion inside the core of get_user_pages_fast*() functions. That also includes pin_user_pages_fast*() routines.
Add a might_lock_read(mmap_sem) call to internal_get_user_pages_fast().
---
Hi Andrew,
This applies on top of [1], which in turn applies to today's (20200521) linux-next.
As noted in the discussion [2], this will need changing from mmap_sem to mmap_lock, after Michel Lespinasse's patchset arrives.
[1]
https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/linux-mm/[email protected]/
thanks,
John Hubbard
NVIDIA
mm/gup.c | 3 +++ 1 file changed, 3 insertions(+)
mm/gup.c +3 -0
@@ -2728,6 +2728,9 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, FOLL_FAST_ONLY)))return -EINVAL ; +if (!(gup_flags &FOLL_FAST_ONLY )) +might_lock_read (¤t->mm->mmap_sem); + start =untagged_addr (start) &PAGE_MASK ; addr = start; len = (unsigned long ) nr_pages <<PAGE_SHIFT ;
Signature · 1 line
2.26.2
Quoted 8 lines · John Hubbard
Instead of scattering these assertions across the drivers, do this assertion inside the core of get_user_pages_fast*() functions. That also includes pin_user_pages_fast*() routines.
Add a
might_lock_read(mmap_sem)call tointernal_get_user_pages_fast().Suggested-by Matthew Wilcox <[email protected]>
Yup, this is exactly what I meant. Feel free to transform this into an Acked-by: or Reviewed-by: if that's the appropriate tag.
Thanks, John!