diff options
Diffstat (limited to 'mm/gup.c')
-rw-r--r-- | mm/gup.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -258,6 +258,11 @@ unmap: | |||
258 | return ret; | 258 | return ret; |
259 | } | 259 | } |
260 | 260 | ||
261 | /* | ||
262 | * mmap_sem must be held on entry. If @nonblocking != NULL and | ||
263 | * *@flags does not include FOLL_NOWAIT, the mmap_sem may be released. | ||
264 | * If it is, *@nonblocking will be set to 0 and -EBUSY returned. | ||
265 | */ | ||
261 | static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, | 266 | static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, |
262 | unsigned long address, unsigned int *flags, int *nonblocking) | 267 | unsigned long address, unsigned int *flags, int *nonblocking) |
263 | { | 268 | { |
@@ -373,7 +378,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) | |||
373 | * with a put_page() call when it is finished with. vmas will only | 378 | * with a put_page() call when it is finished with. vmas will only |
374 | * remain valid while mmap_sem is held. | 379 | * remain valid while mmap_sem is held. |
375 | * | 380 | * |
376 | * Must be called with mmap_sem held for read or write. | 381 | * Must be called with mmap_sem held. It may be released. See below. |
377 | * | 382 | * |
378 | * __get_user_pages walks a process's page tables and takes a reference to | 383 | * __get_user_pages walks a process's page tables and takes a reference to |
379 | * each struct page that each user address corresponds to at a given | 384 | * each struct page that each user address corresponds to at a given |
@@ -396,7 +401,14 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) | |||
396 | * | 401 | * |
397 | * If @nonblocking != NULL, __get_user_pages will not wait for disk IO | 402 | * If @nonblocking != NULL, __get_user_pages will not wait for disk IO |
398 | * or mmap_sem contention, and if waiting is needed to pin all pages, | 403 | * or mmap_sem contention, and if waiting is needed to pin all pages, |
399 | * *@nonblocking will be set to 0. | 404 | * *@nonblocking will be set to 0. Further, if @gup_flags does not |
405 | * include FOLL_NOWAIT, the mmap_sem will be released via up_read() in | ||
406 | * this case. | ||
407 | * | ||
408 | * A caller using such a combination of @nonblocking and @gup_flags | ||
409 | * must therefore hold the mmap_sem for reading only, and recognize | ||
410 | * when it's been released. Otherwise, it must be held for either | ||
411 | * reading or writing and will not be released. | ||
400 | * | 412 | * |
401 | * In most cases, get_user_pages or get_user_pages_fast should be used | 413 | * In most cases, get_user_pages or get_user_pages_fast should be used |
402 | * instead of __get_user_pages. __get_user_pages should be used only if | 414 | * instead of __get_user_pages. __get_user_pages should be used only if |
@@ -528,7 +540,7 @@ EXPORT_SYMBOL(__get_user_pages); | |||
528 | * such architectures, gup() will not be enough to make a subsequent access | 540 | * such architectures, gup() will not be enough to make a subsequent access |
529 | * succeed. | 541 | * succeed. |
530 | * | 542 | * |
531 | * This should be called with the mm_sem held for read. | 543 | * This has the same semantics wrt the @mm->mmap_sem as does filemap_fault(). |
532 | */ | 544 | */ |
533 | int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, | 545 | int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, |
534 | unsigned long address, unsigned int fault_flags) | 546 | unsigned long address, unsigned int fault_flags) |