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
81#ifdef CONFIG_FUTEX_PRIVATE_HASH81#ifdef CONFIG_FUTEX_PRIVATE_HASH
82int futex_hash_allocate_default(void);82int futex_hash_allocate_default(void);
83void futex_hash_free(struct mm_struct *mm);83void futex_hash_free(struct mm_struct *mm);
84int futex_mm_init(struct mm_struct *mm);84void futex_mm_init(struct mm_struct *mm);
85 85#else /* CONFIG_FUTEX_PRIVATE_HASH */
86#else /* !CONFIG_FUTEX_PRIVATE_HASH */
87static inline int futex_hash_allocate_default(void) { return 0; }86static inline int futex_hash_allocate_default(void) { return 0; }
88static inline int futex_hash_free(struct mm_struct *mm) { return 0; }87static inline int futex_hash_free(struct mm_struct *mm) { return 0; }
89static inline int futex_mm_init(struct mm_struct *mm) { return 0; }88static inline void futex_mm_init(struct mm_struct *mm) { }
90#endif /* CONFIG_FUTEX_PRIVATE_HASH */89#endif /* !CONFIG_FUTEX_PRIVATE_HASH */
91 90
92#else /* !CONFIG_FUTEX */91#else /* CONFIG_FUTEX */
93static inline void futex_init_task(struct task_struct *tsk) { }92static inline void futex_init_task(struct task_struct *tsk) { }
94static inline void futex_exit_recursive(struct task_struct *tsk) { }93static inline void futex_exit_recursive(struct task_struct *tsk) { }
95static inline void futex_exit_release(struct task_struct *tsk) { }94static inline void futex_exit_release(struct task_struct *tsk) { }
96static inline void futex_exec_release(struct task_struct *tsk) { }95static inline void futex_exec_release(struct task_struct *tsk) { }
97static inline long do_futex(u32 __user *uaddr, int op, u32 val,96static inline long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
98 ktime_t *timeout, u32 __user *uaddr2,97 u32 __user *uaddr2, u32 val2, u32 val3)
99 u32 val2, u32 val3)
100{98{
101 return -EINVAL;99 return -EINVAL;
102}100}
@@ -104,13 +102,9 @@ static inline int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsig · 1 unmodified line
104{102{
105 return -EINVAL;103 return -EINVAL;
106}104}
107static inline int futex_hash_allocate_default(void)105static inline int futex_hash_allocate_default(void) { return 0; }
108{
109 return 0;
110}
111static inline int futex_hash_free(struct mm_struct *mm) { return 0; }106static inline int futex_hash_free(struct mm_struct *mm) { return 0; }
112static inline int futex_mm_init(struct mm_struct *mm) { return 0; }107static inline void futex_mm_init(struct mm_struct *mm) { }
113 108#endif /* !CONFIG_FUTEX */
114#endif
115 109
116#endif110#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
1101#endif1101#endif
1102 mm_init_uprobes_state(mm);1102 mm_init_uprobes_state(mm);
1103 hugetlb_count_init(mm);1103 hugetlb_count_init(mm);
1104 futex_mm_init(mm);
1104 1105
1105 mm_flags_clear_all(mm);1106 mm_flags_clear_all(mm);
1106 if (current->mm) {1107 if (current->mm) {
@@ -1113,11 +1114,8 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, · 6 unmodified lines
1113 mm->def_flags = 0;1114 mm->def_flags = 0;
1114 }1115 }
1115 1116
1116 if (futex_mm_init(mm))
1117 goto fail_mm_init;
1118
1119 if (mm_alloc_pgd(mm))1117 if (mm_alloc_pgd(mm))
1120 goto fail_nopgd;1118 goto fail_mm_init;
1121 1119
1122 if (mm_alloc_id(mm))1120 if (mm_alloc_id(mm))
1123 goto fail_noid;1121 goto fail_noid;
@@ -1144,8 +1142,6 @@ fail_nocontext: · 20 unmodified lines
1144 mm_free_id(mm);1142 mm_free_id(mm);
1145fail_noid:1143fail_noid:
1146 mm_free_pgd(mm);1144 mm_free_pgd(mm);
1147fail_nopgd:
1148 futex_hash_free(mm);
1149fail_mm_init:1145fail_mm_init:
1150 free_mm(mm);1146 free_mm(mm);
1151 return NULL;1147 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
1720 return atomic_long_read(&mm->futex_atomic) == 0;1720 return atomic_long_read(&mm->futex_atomic) == 0;
1721}1721}
1722 1722
1723int futex_mm_init(struct mm_struct *mm)1723void futex_mm_init(struct mm_struct *mm)
1724{1724{
1725 mutex_init(&mm->futex_hash_lock);1725 mutex_init(&mm->futex_hash_lock);
1726 RCU_INIT_POINTER(mm->futex_phash, NULL);1726 RCU_INIT_POINTER(mm->futex_phash, NULL);
@@ -1729,7 +1729,6 @@ int futex_mm_init(struct mm_struct *mm) · 2 unmodified lines
1729 mm->futex_ref = NULL;1729 mm->futex_ref = NULL;
1730 atomic_long_set(&mm->futex_atomic, 0);1730 atomic_long_set(&mm->futex_atomic, 0);
1731 mm->futex_batches = get_state_synchronize_rcu();1731 mm->futex_batches = get_state_synchronize_rcu();
1732 return 0;
1733}1732}
1734 1733
1735void futex_hash_free(struct mm_struct *mm)1734void futex_hash_free(struct mm_struct *mm)