* [PATCH] mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast()
@ 2020-05-22 1:04 John Hubbard
2020-05-22 1:16 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: John Hubbard @ 2020-05-22 1:04 UTC (permalink / raw)
To: Andrew Morton, jgg
Cc: Liam.Howlett, daniel.m.jordan, dave, hughd, jglisse, jhubbard,
ldufour, linux-kernel, linux-mm, peterz, rientjes, vbabka,
walken, willy, yinghan
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().
Suggested-by: Matthew Wilcox <willy@infradead.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
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/20200521233841.1279742-1-jhubbard@nvidia.com
[2] https://lore.kernel.org/linux-mm/20200520124817.GG31189@ziepe.ca/
thanks,
John Hubbard
NVIDIA
mm/gup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/gup.c b/mm/gup.c
index ada6aa79576dc..3462c076e8ecf 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -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;
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast()
2020-05-22 1:04 [PATCH] mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast() John Hubbard
@ 2020-05-22 1:16 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2020-05-22 1:16 UTC (permalink / raw)
To: John Hubbard
Cc: Andrew Morton, jgg, Liam.Howlett, daniel.m.jordan, dave, hughd,
jglisse, ldufour, linux-kernel, linux-mm, peterz, rientjes,
vbabka, walken, yinghan
On Thu, May 21, 2020 at 06:04:43PM -0700, John Hubbard wrote:
> 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().
>
> Suggested-by: Matthew Wilcox <willy@infradead.org>
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!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-22 1:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 1:04 [PATCH] mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast() John Hubbard
2020-05-22 1:16 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).