From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9DD310650 for ; Sun, 16 Nov 2025 20:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763326138; cv=none; b=Nmg/x4AiUDjhDEwRchl9/+MC6WAarsIGnFKTHtX2HCNBmLZJWPVH33vWckdihAnjQYyEBAs7SPSYUzpkUBiD+L1bTJpuPVN1Qs57cU50VVJWgf7HZsAqIt2674j+MwiCOt7evNDcm/mQ4Vca9M5fCzyvBM/27FehEDOFQin4+Yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763326138; c=relaxed/simple; bh=vs2qE4aSRCJ4MOSQwu+0ikKD1GazpoXb7+IgmCQ2HLI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=d7lII6vqvLIOLNJFD78cl0YANy1Jk1fUJOixPHCnB+ykQ4TBfbashCiscfaKtRaUQRRTVX+ZeAMcOavZLgMEIqAeBZnt9p1kd42d3nVlmy5KZpAQ1apWe4JLbVTvhfZ1TphDdi1iPLU+/u8zFuBNzmvfp227l+hyM7STBXGZzmw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2E7PT+MA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=97Cp/Ozz; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2E7PT+MA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="97Cp/Ozz" Message-ID: <20251104075427.359149311@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1763326135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=ezhVeQoFFg5cKP4kQ5iOgV9eN2TIDhn3UPvppBHphsg=; b=2E7PT+MAJF0oAhcUMbs6PQb9Gx+GTcHSh90Sq0Smr/gytmLVwQI8heNt/3m00y2tm3Hve4 dFjObC3SZYgE9EvT64uSUF90wj/xdmbk7t2IWgm6O+o/O/7qAnA1gOq3ilxC4MM17iNgKr YhhccgGhnzXEZ2Ly51LbgEO41vlP5l6A+AwfRlwEC/+/vRWV5SsFrB5pShAayzC9hcdUQN 1TPsEYVhRRxYG7DHvO3Z12xMvbHEEP4C8v6oseoveZ/GANX9UW8YsX2572ST+MBImGfIRF f/uU/JJaKDkLFt0yyyr4eeaiGIVwmZynG/NPnjtwazxKb3uqqrKc3PBsVV2dTQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1763326135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=ezhVeQoFFg5cKP4kQ5iOgV9eN2TIDhn3UPvppBHphsg=; b=97Cp/Ozzxfx6NtDTTVwlyEuO8inaAGmBmog4k1BFLNOewAkD1NpcMnzWJMBWE4yN1sc55L IWsVhLMjmIDRrYAg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Gabriele Monaco , Mathieu Desnoyers , Michael Jeanson , Jens Axboe , "Paul E. McKenney" , "Gautham R. Shenoy" , Florian Weimer , Tim Chen , Yury Norov , Shrikanth Hegde Subject: [patch V4 11/20] signal: Move MMCID exit out of sighand lock References: <20251104075053.700034556@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Sun, 16 Nov 2025 21:48:55 +0100 (CET) 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 --- include/linux/sched.h | 4 ++-- kernel/exit.c | 1 + kernel/sched/core.c | 4 ++-- kernel/signal.c | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-) --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2298,7 +2298,7 @@ static __always_inline void alloc_tag_re 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 tas 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) { /* --- a/kernel/exit.c +++ b/kernel/exit.c @@ -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); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10392,7 +10392,7 @@ static inline void mm_update_cpus_allowe 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 ta /* 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() */ --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3125,7 +3125,6 @@ void exit_signals(struct task_struct *ts 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 *ts * 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);