Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356503
b: refs/heads/master
c: a1ea954
h: refs/heads/master
i:
  356501: 497dd38
  356499: f5237fe
  356495: dd0a07d
v: v3
  • Loading branch information
Michel Lespinasse authored and Linus Torvalds committed Feb 24, 2013
1 parent b284fec commit 5c38a8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bebeb3d68b24bb4132d452c5707fe321208bcbcd
refs/heads/master: a1ea9549a7254b17ba85809f4a0200abc21453a2
22 changes: 6 additions & 16 deletions trunk/mm/fremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
struct vm_area_struct *vma;
int err = -EINVAL;
int has_write_lock = 0;
vm_flags_t vm_flags;

if (prot)
return err;
Expand Down Expand Up @@ -228,30 +229,16 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
/*
* drop PG_Mlocked flag for over-mapped range
*/
vm_flags_t saved_flags = vma->vm_flags;
if (!has_write_lock)
goto get_write_lock;
vm_flags = vma->vm_flags;
munlock_vma_pages_range(vma, start, start + size);
vma->vm_flags = saved_flags;
vma->vm_flags = vm_flags;
}

mmu_notifier_invalidate_range_start(mm, start, start + size);
err = vma->vm_ops->remap_pages(vma, start, size, pgoff);
mmu_notifier_invalidate_range_end(mm, start, start + size);
if (!err) {
if (vma->vm_flags & VM_LOCKED) {
/*
* might be mapping previously unmapped range of file
*/
mlock_vma_pages_range(vma, start, start + size);
} else if (!(flags & MAP_NONBLOCK)) {
if (unlikely(has_write_lock)) {
downgrade_write(&mm->mmap_sem);
has_write_lock = 0;
}
make_pages_present(start, start+size);
}
}

/*
* We can't clear VM_NONLINEAR because we'd have to do
Expand All @@ -260,10 +247,13 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
*/

out:
vm_flags = vma->vm_flags;
if (likely(!has_write_lock))
up_read(&mm->mmap_sem);
else
up_write(&mm->mmap_sem);
if (!err && ((vm_flags & VM_LOCKED) || !(flags & MAP_NONBLOCK)))
mm_populate(start, size);

return err;
}

0 comments on commit 5c38a8c

Please sign in to comment.