]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
signal: Move MMCID exit out of sighand lock
authorThomas Gleixner <tglx@linutronix.de>
Wed, 19 Nov 2025 17:27:05 +0000 (18:27 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 25 Nov 2025 18:45:40 +0000 (19:45 +0100)
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
include/linux/sched.h
kernel/exit.c
kernel/sched/core.c
kernel/signal.c

index 64f080d6ed6e4b333edf2a26e36254e9e86f0dac..c411ae021bc5523c1a3dad53f487a30e49e8c40d 100644 (file)
@@ -2298,7 +2298,7 @@ static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct allo
 void sched_mm_cid_before_execve(struct task_struct *t);
 void sched_mm_cid_after_execve(struct task_struct *t);
 void sched_mm_cid_fork(struct task_struct *t);
-void sched_mm_cid_exit_signals(struct task_struct *t);
+void sched_mm_cid_exit(struct task_struct *t);
 static inline int task_mm_cid(struct task_struct *t)
 {
        return t->mm_cid.cid;
@@ -2307,7 +2307,7 @@ static inline int task_mm_cid(struct task_struct *t)
 static inline void sched_mm_cid_before_execve(struct task_struct *t) { }
 static inline void sched_mm_cid_after_execve(struct task_struct *t) { }
 static inline void sched_mm_cid_fork(struct task_struct *t) { }
-static inline void sched_mm_cid_exit_signals(struct task_struct *t) { }
+static inline void sched_mm_cid_exit(struct task_struct *t) { }
 static inline int task_mm_cid(struct task_struct *t)
 {
        /*
index 9f74e8f1c431b6aa6e391ff71aadf9895a3857ae..324616f690b7b1c77a11fdd8fceda060237eec04 100644 (file)
@@ -910,6 +910,7 @@ void __noreturn do_exit(long code)
        user_events_exit(tsk);
 
        io_uring_files_cancel();
+       sched_mm_cid_exit(tsk);
        exit_signals(tsk);  /* sets PF_EXITING */
 
        seccomp_filter_release(tsk);
index 9a114b6f6a6fddab9645bdea4e9149bcdf66c250..3fdf90a7074d80828e5f9d93ddde98c80dfaacdd 100644 (file)
@@ -10392,7 +10392,7 @@ static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpu
        WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, weight);
 }
 
-void sched_mm_cid_exit_signals(struct task_struct *t)
+void sched_mm_cid_exit(struct task_struct *t)
 {
        struct mm_struct *mm = t->mm;
 
@@ -10410,7 +10410,7 @@ void sched_mm_cid_exit_signals(struct task_struct *t)
 /* Deactivate MM CID allocation across execve() */
 void sched_mm_cid_before_execve(struct task_struct *t)
 {
-       sched_mm_cid_exit_signals(t);
+       sched_mm_cid_exit(t);
 }
 
 /* Reactivate MM CID after successful execve() */
index fe9190d84f281e650a2f2b356f6fe692e22dadd4..e42b8bd6922fcb08a09de7b35e8160a5acf79133 100644 (file)
@@ -3125,7 +3125,6 @@ void exit_signals(struct task_struct *tsk)
        cgroup_threadgroup_change_begin(tsk);
 
        if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) {
-               sched_mm_cid_exit_signals(tsk);
                tsk->flags |= PF_EXITING;
                cgroup_threadgroup_change_end(tsk);
                return;
@@ -3136,7 +3135,6 @@ void exit_signals(struct task_struct *tsk)
         * From now this task is not visible for group-wide signals,
         * see wants_signal(), do_signal_stop().
         */
-       sched_mm_cid_exit_signals(tsk);
        tsk->flags |= PF_EXITING;
 
        cgroup_threadgroup_change_end(tsk);