History

mmap locking API: convert nested write lock sites

Add API for nested write locks and convert the few call sites doing that.

Michel Lespinasse committed 6 years ago

Commit aaa2cc51 parent 89154dd3 files · +8 −2Browse files

Unified · Split

3 files
  1. arch/um/include/asm/mmu_context.h +2 −1
  2. include/linux/mmap_lock.h +5 −0
  3. kernel/fork.c +1 −1
arch/um/include/asm/mmu_context.h+2−1
@@ -8,6 +8,7 @@ · 7 unmodified lines
88
99 #include <linux/sched.h>
1010 #include <linux/mm_types.h>
11+#include <linux/mmap_lock.h>
1112
1213 #include <asm/mmu.h>
1314
@@ -47,7 +48,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) · 33 unmodified lines
4748 * when the new ->mm is used for the first time.
4849 */
4950 __switch_mm(&new->context.id);
50− down_write_nested(&new->mmap_sem, 1);
51+ mmap_write_lock_nested(new, SINGLE_DEPTH_NESTING);
5152 uml_setup_stubs(new);
5253 mmap_write_unlock(new);
5354 }
include/linux/mmap_lock.h+5−0
@@ -11,6 +11,11 @@ static inline void mmap_write_lock(struct mm_struct *mm) · 10 unmodified lines
1111 down_write(&mm->mmap_sem);
1212 }
1313
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+
1419 static inline int mmap_write_lock_killable(struct mm_struct *mm)
1520 {
1621 return down_write_killable(&mm->mmap_sem);
kernel/fork.c+1−1
@@ -501,7 +501,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, · 500 unmodified lines
501501 /*
502502 * Not linked in yet - no deadlock potential:
503503 */
504− down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
504+ mmap_write_lock_nested(mm, SINGLE_DEPTH_NESTING);
505505
506506 /* No ordering required: file already has been exposed. */
507507 RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm));