Add API for nested write locks and convert the few call sites doing that.
Unified · Split
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
| 10 | #include <linux/mm_types.h> | 10 | #include <linux/mm_types.h> |
| 11 | #include <linux/mmap_lock.h> | ||
| 11 | 12 | ||
| 12 | #include <asm/mmu.h> | 13 | #include <asm/mmu.h> |
| 13 | 14 | ||
| @@ -47,7 +48,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) · 33 unmodified lines | |||
| 47 | * when the new ->mm is used for the first time. | 48 | * when the new ->mm is used for the first time. |
| 48 | */ | 49 | */ |
| 49 | __switch_mm(&new->context.id); | 50 | __switch_mm(&new->context.id); |
| 50 | down_write_nested(&new->mmap_sem, 1); | 51 | mmap_write_lock_nested(new, SINGLE_DEPTH_NESTING); |
| 51 | uml_setup_stubs(new); | 52 | uml_setup_stubs(new); |
| 52 | mmap_write_unlock(new); | 53 | mmap_write_unlock(new); |
| 53 | } | 54 | } |
| @@ -11,6 +11,11 @@ static inline void mmap_write_lock(struct mm_struct *mm) · 10 unmodified lines | |||
| 11 | down_write(&mm->mmap_sem); | 11 | down_write(&mm->mmap_sem); |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass) | ||
| 15 | { | ||
| 16 | down_write_nested(&mm->mmap_sem, subclass); | ||
| 17 | } | ||
| 18 | |||
| 14 | static inline int mmap_write_lock_killable(struct mm_struct *mm) | 19 | static inline int mmap_write_lock_killable(struct mm_struct *mm) |
| 15 | { | 20 | { |
| 16 | return down_write_killable(&mm->mmap_sem); | 21 | return down_write_killable(&mm->mmap_sem); |
| @@ -501,7 +501,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, · 500 unmodified lines | |||
| 501 | /* | 501 | /* |
| 502 | * Not linked in yet - no deadlock potential: | 502 | * Not linked in yet - no deadlock potential: |
| 503 | */ | 503 | */ |
| 504 | down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING); | 504 | mmap_write_lock_nested(mm, SINGLE_DEPTH_NESTING); |
| 505 | 505 | ||
| 506 | /* No ordering required: file already has been exposed. */ | 506 | /* No ordering required: file already has been exposed. */ |
| 507 | RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm)); | 507 | RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm)); |