diff mbox series

[v2,06/13] mm/gup: add an assertion that the mmap lock is locked

Message ID 6-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com (mailing list archive)
State New
Headers show
Series Simplify the external interface for GUP | expand

Commit Message

Jason Gunthorpe Jan. 24, 2023, 8:34 p.m. UTC
Since commit 5b78ed24e8ec ("mm/pagemap: add mmap_assert_locked()
annotations to find_vma*()") we already have this assertion, it is just
buried in find_vma():

 __get_user_pages_locked()
  __get_user_pages()
  find_extend_vma()
   find_vma()

Also check it at the top of __get_user_pages_locked() as a form of
documentation.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 mm/gup.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

John Hubbard Jan. 25, 2023, 2:34 a.m. UTC | #1
On 1/24/23 12:34, Jason Gunthorpe wrote:
> Since commit 5b78ed24e8ec ("mm/pagemap: add mmap_assert_locked()
> annotations to find_vma*()") we already have this assertion, it is just
> buried in find_vma():
> 
>   __get_user_pages_locked()
>    __get_user_pages()
>    find_extend_vma()
>     find_vma()
> 
> Also check it at the top of __get_user_pages_locked() as a form of
> documentation.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>   mm/gup.c | 2 ++
>   1 file changed, 2 insertions(+)

Reviewed-by: John Hubbard <jhubbard@nvidia.com>

thanks,
diff mbox series

Patch

diff --git a/mm/gup.c b/mm/gup.c
index 4c236fb83dcd3e..de1a5c64fdfdcf 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1360,6 +1360,8 @@  static __always_inline long __get_user_pages_locked(struct mm_struct *mm,
 		must_unlock = true;
 		*locked = 1;
 	}
+	else
+		mmap_assert_locked(mm);
 
 	if (flags & FOLL_PIN)
 		mm_set_has_pinned_flag(&mm->flags);