lkml.org 
[lkml]   [2015]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 02/37] mm, frame_vector: do not use get_user_pages_locked()
From
Date

From: Dave Hansen <dave.hansen@linux.intel.com>

get_user_pages_locked() appears to be for use when a caller needs
to know that its lock on mmap_sem was invalidated by the gup
call.

But, get_vaddr_frames() is not one of those users. It
unconditionally locks the mmap_sem and unconditionally unlocks it
after the gup call. It takes no special action and does not need
to know whether its lock was invalidated or not.

Replace get_user_pages_locked() with a vanilla get_user_pages()
and save a few lines of code.

Note that this was the *ONLY* use of get_user_pages_locked() in
the entire kernel tree.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
---

b/mm/frame_vector.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff -puN mm/frame_vector.c~remove-get_user_pages_locked-user mm/frame_vector.c
--- a/mm/frame_vector.c~remove-get_user_pages_locked-user 2015-11-16 12:35:35.282169293 -0800
+++ b/mm/frame_vector.c 2015-11-16 12:35:35.285169429 -0800
@@ -40,7 +40,6 @@ int get_vaddr_frames(unsigned long start
struct vm_area_struct *vma;
int ret = 0;
int err;
- int locked;

if (nr_frames == 0)
return 0;
@@ -49,7 +48,6 @@ int get_vaddr_frames(unsigned long start
nr_frames = vec->nr_allocated;

down_read(&mm->mmap_sem);
- locked = 1;
vma = find_vma_intersection(mm, start, start + 1);
if (!vma) {
ret = -EFAULT;
@@ -58,8 +56,8 @@ int get_vaddr_frames(unsigned long start
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) {
vec->got_ref = true;
vec->is_pfns = false;
- ret = get_user_pages_locked(current, mm, start, nr_frames,
- write, force, (struct page **)(vec->ptrs), &locked);
+ ret = get_user_pages(current, mm, start, nr_frames,
+ write, force, (struct page **)(vec->ptrs), NULL);
goto out;
}

@@ -87,8 +85,7 @@ int get_vaddr_frames(unsigned long start
vma = find_vma_intersection(mm, start, start + 1);
} while (vma && vma->vm_flags & (VM_IO | VM_PFNMAP));
out:
- if (locked)
- up_read(&mm->mmap_sem);
+ up_read(&mm->mmap_sem);
if (!ret)
ret = -EFAULT;
if (ret > 0)
_

\
 
 \ /
  Last update: 2015-11-17 05:01    [W:0.148 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site