Skip to content

Commit 2b1642b

Browse files
committed
signal: Move MMCID exit out of sighand lock
There is no need anymore to keep this under sighand lock as the current code and the upcoming replacement are not depending on the exit state of a task anymore. That allows to use a mutex in the exit path. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://patch.msgid.link/20251119172549.706439391@linutronix.de
1 parent 539115f commit 2b1642b

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

include/linux/sched.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct allo
22982298
void sched_mm_cid_before_execve(struct task_struct *t);
22992299
void sched_mm_cid_after_execve(struct task_struct *t);
23002300
void sched_mm_cid_fork(struct task_struct *t);
2301-
void sched_mm_cid_exit_signals(struct task_struct *t);
2301+
void sched_mm_cid_exit(struct task_struct *t);
23022302
static inline int task_mm_cid(struct task_struct *t)
23032303
{
23042304
return t->mm_cid.cid;
@@ -2307,7 +2307,7 @@ static inline int task_mm_cid(struct task_struct *t)
23072307
static inline void sched_mm_cid_before_execve(struct task_struct *t) { }
23082308
static inline void sched_mm_cid_after_execve(struct task_struct *t) { }
23092309
static inline void sched_mm_cid_fork(struct task_struct *t) { }
2310-
static inline void sched_mm_cid_exit_signals(struct task_struct *t) { }
2310+
static inline void sched_mm_cid_exit(struct task_struct *t) { }
23112311
static inline int task_mm_cid(struct task_struct *t)
23122312
{
23132313
/*

kernel/exit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ void __noreturn do_exit(long code)
910910
user_events_exit(tsk);
911911

912912
io_uring_files_cancel();
913+
sched_mm_cid_exit(tsk);
913914
exit_signals(tsk); /* sets PF_EXITING */
914915

915916
seccomp_filter_release(tsk);

kernel/sched/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10392,7 +10392,7 @@ static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpu
1039210392
WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, weight);
1039310393
}
1039410394

10395-
void sched_mm_cid_exit_signals(struct task_struct *t)
10395+
void sched_mm_cid_exit(struct task_struct *t)
1039610396
{
1039710397
struct mm_struct *mm = t->mm;
1039810398

@@ -10410,7 +10410,7 @@ void sched_mm_cid_exit_signals(struct task_struct *t)
1041010410
/* Deactivate MM CID allocation across execve() */
1041110411
void sched_mm_cid_before_execve(struct task_struct *t)
1041210412
{
10413-
sched_mm_cid_exit_signals(t);
10413+
sched_mm_cid_exit(t);
1041410414
}
1041510415

1041610416
/* Reactivate MM CID after successful execve() */

kernel/signal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,6 @@ void exit_signals(struct task_struct *tsk)
31253125
cgroup_threadgroup_change_begin(tsk);
31263126

31273127
if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) {
3128-
sched_mm_cid_exit_signals(tsk);
31293128
tsk->flags |= PF_EXITING;
31303129
cgroup_threadgroup_change_end(tsk);
31313130
return;
@@ -3136,7 +3135,6 @@ void exit_signals(struct task_struct *tsk)
31363135
* From now this task is not visible for group-wide signals,
31373136
* see wants_signal(), do_signal_stop().
31383137
*/
3139-
sched_mm_cid_exit_signals(tsk);
31403138
tsk->flags |= PF_EXITING;
31413139

31423140
cgroup_threadgroup_change_end(tsk);

0 commit comments

Comments
 (0)