aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-09-24 04:31:34 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-24 04:31:34 -0400
commite6aa0f07cb5e81a7cbeaf3be6e2101234c2f0d30 (patch)
tree77926550ac0c31b1423bcf193a4ed0ecb7fda2c1 /mm/mmap.c
parentd4738792fb86600b6cb7220459d9c47e819b3580 (diff)
parent72d31053f62c4bc464c2783974926969614a8649 (diff)
Merge commit 'v2.6.27-rc7' into x86/microcode
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 245c3d69067b..e7a5a68a9c2e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -370,7 +370,7 @@ find_vma_prepare(struct mm_struct *mm, unsigned long addr,
370 if (vma_tmp->vm_end > addr) { 370 if (vma_tmp->vm_end > addr) {
371 vma = vma_tmp; 371 vma = vma_tmp;
372 if (vma_tmp->vm_start <= addr) 372 if (vma_tmp->vm_start <= addr)
373 return vma; 373 break;
374 __rb_link = &__rb_parent->rb_left; 374 __rb_link = &__rb_parent->rb_left;
375 } else { 375 } else {
376 rb_prev = __rb_parent; 376 rb_prev = __rb_parent;
@@ -1030,6 +1030,10 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
1030 } else { 1030 } else {
1031 switch (flags & MAP_TYPE) { 1031 switch (flags & MAP_TYPE) {
1032 case MAP_SHARED: 1032 case MAP_SHARED:
1033 /*
1034 * Ignore pgoff.
1035 */
1036 pgoff = 0;
1033 vm_flags |= VM_SHARED | VM_MAYSHARE; 1037 vm_flags |= VM_SHARED | VM_MAYSHARE;
1034 break; 1038 break;
1035 case MAP_PRIVATE: 1039 case MAP_PRIVATE:
@@ -2273,14 +2277,14 @@ int install_special_mapping(struct mm_struct *mm,
2273 2277
2274static DEFINE_MUTEX(mm_all_locks_mutex); 2278static DEFINE_MUTEX(mm_all_locks_mutex);
2275 2279
2276static void vm_lock_anon_vma(struct anon_vma *anon_vma) 2280static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma)
2277{ 2281{
2278 if (!test_bit(0, (unsigned long *) &anon_vma->head.next)) { 2282 if (!test_bit(0, (unsigned long *) &anon_vma->head.next)) {
2279 /* 2283 /*
2280 * The LSB of head.next can't change from under us 2284 * The LSB of head.next can't change from under us
2281 * because we hold the mm_all_locks_mutex. 2285 * because we hold the mm_all_locks_mutex.
2282 */ 2286 */
2283 spin_lock(&anon_vma->lock); 2287 spin_lock_nest_lock(&anon_vma->lock, &mm->mmap_sem);
2284 /* 2288 /*
2285 * We can safely modify head.next after taking the 2289 * We can safely modify head.next after taking the
2286 * anon_vma->lock. If some other vma in this mm shares 2290 * anon_vma->lock. If some other vma in this mm shares
@@ -2296,7 +2300,7 @@ static void vm_lock_anon_vma(struct anon_vma *anon_vma)
2296 } 2300 }
2297} 2301}
2298 2302
2299static void vm_lock_mapping(struct address_space *mapping) 2303static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping)
2300{ 2304{
2301 if (!test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) { 2305 if (!test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) {
2302 /* 2306 /*
@@ -2310,7 +2314,7 @@ static void vm_lock_mapping(struct address_space *mapping)
2310 */ 2314 */
2311 if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags)) 2315 if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags))
2312 BUG(); 2316 BUG();
2313 spin_lock(&mapping->i_mmap_lock); 2317 spin_lock_nest_lock(&mapping->i_mmap_lock, &mm->mmap_sem);
2314 } 2318 }
2315} 2319}
2316 2320
@@ -2358,11 +2362,17 @@ int mm_take_all_locks(struct mm_struct *mm)
2358 for (vma = mm->mmap; vma; vma = vma->vm_next) { 2362 for (vma = mm->mmap; vma; vma = vma->vm_next) {
2359 if (signal_pending(current)) 2363 if (signal_pending(current))
2360 goto out_unlock; 2364 goto out_unlock;
2361 if (vma->anon_vma)
2362 vm_lock_anon_vma(vma->anon_vma);
2363 if (vma->vm_file && vma->vm_file->f_mapping) 2365 if (vma->vm_file && vma->vm_file->f_mapping)
2364 vm_lock_mapping(vma->vm_file->f_mapping); 2366 vm_lock_mapping(mm, vma->vm_file->f_mapping);
2365 } 2367 }
2368
2369 for (vma = mm->mmap; vma; vma = vma->vm_next) {
2370 if (signal_pending(current))
2371 goto out_unlock;
2372 if (vma->anon_vma)
2373 vm_lock_anon_vma(mm, vma->anon_vma);
2374 }
2375
2366 ret = 0; 2376 ret = 0;
2367 2377
2368out_unlock: 2378out_unlock: