History

futex: Make futex_mm_init() void

Nothing fails there. Mop up the leftovers of the early version of this, which did an allocation. While at it clean up the stubs and the #ifdef comments to make the header file readable.

Thomas Gleixner committed 5 months ago

Commit d7b3f521 parent c1ffc9c3 files · +14 −25Browse files

Unified · Split

3 files
  1. include/linux/futex.h +11 −17
  2. kernel/fork.c +2 −6
  3. kernel/futex/core.c +1 −2
include/linux/futex.h+11−17
@@ -81,22 +81,20 @@ int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsigned long arg4) · 80 unmodified lines
8181 #ifdef CONFIG_FUTEX_PRIVATE_HASH
8282 int futex_hash_allocate_default(void);
8383 void futex_hash_free(struct mm_struct *mm);
84−int futex_mm_init(struct mm_struct *mm);
85−
86−#else /* !CONFIG_FUTEX_PRIVATE_HASH */
84+void futex_mm_init(struct mm_struct *mm);
85+#else /* CONFIG_FUTEX_PRIVATE_HASH */
8786 static inline int futex_hash_allocate_default(void) { return 0; }
8887 static inline int futex_hash_free(struct mm_struct *mm) { return 0; }
89−static inline int futex_mm_init(struct mm_struct *mm) { return 0; }
90−#endif /* CONFIG_FUTEX_PRIVATE_HASH */
88+static inline void futex_mm_init(struct mm_struct *mm) { }
89+#endif /* !CONFIG_FUTEX_PRIVATE_HASH */
9190
92−#else /* !CONFIG_FUTEX */
91+#else /* CONFIG_FUTEX */
9392 static inline void futex_init_task(struct task_struct *tsk) { }
9493 static inline void futex_exit_recursive(struct task_struct *tsk) { }
9594 static inline void futex_exit_release(struct task_struct *tsk) { }
9695 static inline void futex_exec_release(struct task_struct *tsk) { }
97−static inline long do_futex(u32 __user *uaddr, int op, u32 val,
98− ktime_t *timeout, u32 __user *uaddr2,
99− u32 val2, u32 val3)
96+static inline long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
97+ u32 __user *uaddr2, u32 val2, u32 val3)
10098 {
10199 return -EINVAL;
102100 }
@@ -104,13 +102,9 @@ static inline int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsig · 1 unmodified line
104102 {
105103 return -EINVAL;
106104 }
107−static inline int futex_hash_allocate_default(void)
108−{
109− return 0;
110−}
105+static inline int futex_hash_allocate_default(void) { return 0; }
111106 static inline int futex_hash_free(struct mm_struct *mm) { return 0; }
112−static inline int futex_mm_init(struct mm_struct *mm) { return 0; }
113−
114−#endif
107+static inline void futex_mm_init(struct mm_struct *mm) { }
108+#endif /* !CONFIG_FUTEX */
115109
116−#endif
110+#endif /* _LINUX_FUTEX_H */
kernel/fork.c+2−6
@@ -1101,6 +1101,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, · 1100 unmodified lines
11011101 #endif
11021102 mm_init_uprobes_state(mm);
11031103 hugetlb_count_init(mm);
1104+ futex_mm_init(mm);
11041105
11051106 mm_flags_clear_all(mm);
11061107 if (current->mm) {
@@ -1113,11 +1114,8 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, · 6 unmodified lines
11131114 mm->def_flags = 0;
11141115 }
11151116
1116− if (futex_mm_init(mm))
1117− goto fail_mm_init;
1118−
11191117 if (mm_alloc_pgd(mm))
1120− goto fail_nopgd;
1118+ goto fail_mm_init;
11211119
11221120 if (mm_alloc_id(mm))
11231121 goto fail_noid;
@@ -1144,8 +1142,6 @@ fail_nocontext: · 20 unmodified lines
11441142 mm_free_id(mm);
11451143 fail_noid:
11461144 mm_free_pgd(mm);
1147−fail_nopgd:
1148− futex_hash_free(mm);
11491145 fail_mm_init:
11501146 free_mm(mm);
11511147 return NULL;
kernel/futex/core.c+1−2
@@ -1720,7 +1720,7 @@ static bool futex_ref_is_dead(struct futex_private_hash *fph) · 1719 unmodified lines
17201720 return atomic_long_read(&mm->futex_atomic) == 0;
17211721 }
17221722
1723−int futex_mm_init(struct mm_struct *mm)
1723+void futex_mm_init(struct mm_struct *mm)
17241724 {
17251725 mutex_init(&mm->futex_hash_lock);
17261726 RCU_INIT_POINTER(mm->futex_phash, NULL);
@@ -1729,7 +1729,6 @@ int futex_mm_init(struct mm_struct *mm) · 2 unmodified lines
17291729 mm->futex_ref = NULL;
17301730 atomic_long_set(&mm->futex_atomic, 0);
17311731 mm->futex_batches = get_state_synchronize_rcu();
1732− return 0;
17331732 }
17341733
17351734 void futex_hash_free(struct mm_struct *mm)