diff options
| author | Paul Cassella <cassella@cray.com> | 2014-08-06 19:07:24 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:20 -0400 |
| commit | 9a95f3cf7b33d66fa64727cff8cd2f2a9d09f335 (patch) | |
| tree | 14d7c178144b6de0b352b8e8d4b04ffdbae9a71c /mm/filemap.c | |
| parent | 4ffeaf3560a52b4a69cc7909873d08c0ef5909d4 (diff) | |
mm: describe mmap_sem rules for __lock_page_or_retry() and callers
Add a comment describing the circumstances in which
__lock_page_or_retry() will or will not release the mmap_sem when
returning 0.
Add comments to lock_page_or_retry()'s callers (filemap_fault(),
do_swap_page()) noting the impact on VM_FAULT_RETRY returns.
Add comments on up the call tree, particularly replacing the false "We
return with mmap_sem still held" comments.
Signed-off-by: Paul Cassella <cassella@cray.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
| -rw-r--r-- | mm/filemap.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 7e85c8147e1b..af19a6b079f5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
| @@ -808,6 +808,17 @@ int __lock_page_killable(struct page *page) | |||
| 808 | } | 808 | } |
| 809 | EXPORT_SYMBOL_GPL(__lock_page_killable); | 809 | EXPORT_SYMBOL_GPL(__lock_page_killable); |
| 810 | 810 | ||
| 811 | /* | ||
| 812 | * Return values: | ||
| 813 | * 1 - page is locked; mmap_sem is still held. | ||
| 814 | * 0 - page is not locked. | ||
| 815 | * mmap_sem has been released (up_read()), unless flags had both | ||
| 816 | * FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_RETRY_NOWAIT set, in | ||
| 817 | * which case mmap_sem is still held. | ||
| 818 | * | ||
| 819 | * If neither ALLOW_RETRY nor KILLABLE are set, will always return 1 | ||
| 820 | * with the page locked and the mmap_sem unperturbed. | ||
| 821 | */ | ||
| 811 | int __lock_page_or_retry(struct page *page, struct mm_struct *mm, | 822 | int __lock_page_or_retry(struct page *page, struct mm_struct *mm, |
| 812 | unsigned int flags) | 823 | unsigned int flags) |
| 813 | { | 824 | { |
| @@ -1827,6 +1838,18 @@ static void do_async_mmap_readahead(struct vm_area_struct *vma, | |||
| 1827 | * The goto's are kind of ugly, but this streamlines the normal case of having | 1838 | * The goto's are kind of ugly, but this streamlines the normal case of having |
| 1828 | * it in the page cache, and handles the special cases reasonably without | 1839 | * it in the page cache, and handles the special cases reasonably without |
| 1829 | * having a lot of duplicated code. | 1840 | * having a lot of duplicated code. |
| 1841 | * | ||
| 1842 | * vma->vm_mm->mmap_sem must be held on entry. | ||
| 1843 | * | ||
| 1844 | * If our return value has VM_FAULT_RETRY set, it's because | ||
| 1845 | * lock_page_or_retry() returned 0. | ||
| 1846 | * The mmap_sem has usually been released in this case. | ||
| 1847 | * See __lock_page_or_retry() for the exception. | ||
| 1848 | * | ||
| 1849 | * If our return value does not have VM_FAULT_RETRY set, the mmap_sem | ||
| 1850 | * has not been released. | ||
| 1851 | * | ||
| 1852 | * We never return with VM_FAULT_RETRY and a bit from VM_FAULT_ERROR set. | ||
| 1830 | */ | 1853 | */ |
| 1831 | int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | 1854 | int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
| 1832 | { | 1855 | { |
