From nobody Mon Sep 28 23:12:46 2026 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 120B738D3FC; Sat, 15 Aug 2026 22:29:59 +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=1786833001; cv=none; b=cjXevo9XxWTHTVT60yNBqq3ZgGEoLXps/6oiDFp+DShmLGyb9TAjVPBS0X8dTxTntw2gRmJj410dh9yQw3sOri3ppBsHqf4RLVlODWovCiuMg9HsnYJFTbIOUUb8luEmOMLf/+Zz7s0SFzU1bBG3+lAZ1nck5HH3NxCE1RaH6XE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786833001; c=relaxed/simple; bh=0mDhpnlzY6s2JrXVfxEm2DxdFO8UKB31oDvSyej7djk=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=Z6jkhwWU1RdftlVgtu7iRzcJf+9lwniFhA1JdIXijGnj5Z4T+euHiwVrNVITOKxu9oMBo3WbxiX2/lIxGM+guXn8QwiCbv4Q1UWvcm9VqEMpb4K7y8AOAVHrjuNOiMO6RXbYGZBF83wpNbQSoi42t1neJBdd6wVwyZaa0Bu1J+c= 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=YmRUGDOA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kFAr28c+; 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="YmRUGDOA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kFAr28c+" Date: Sat, 15 Aug 2026 22:29:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786832990; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K/S/WSjKxBfeVK8Y+RXK3BJ7JFeST7r99tHGxJJshSQ=; b=YmRUGDOATGMlb+0Ji+qEM/QPCVd3NOMsTNh+Hb2CWDNmMfHPNgYRXzntYGHb4zQEHMTB3r sishPg7sfGDCIeLm8zkpUUlUuXhpMfFysSL6x3EeZttaNZLE5hv5zmGPoUbC00rq7BlBel CcLFjM52OrXXKtzVH0OEjktrPfK6fVFVru1XiWGuJ1OqAuhoPazZroyKWsBtQws4YODdXs vm2GYMWuw73xlz1mQcom5XiamFhcyOUgcLgh3izXHFzNAezZ9IVQNsrJNeVtDp7Uw5SkEQ RbD3XbUs4aQYzB5sp0ZdaBWD1sO/BpHtZaSd7mMCWPX+vUf7I9e5zn4i5/klAQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786832990; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K/S/WSjKxBfeVK8Y+RXK3BJ7JFeST7r99tHGxJJshSQ=; b=kFAr28c+/GvLQmTN3AHI0jYXL4yczl0zl2iV5xIr19KJt3ziDpQuTUc72lD/xsGWO501+p OiTCI3+vjGfcRyDQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] futex: Clean up the redundant exit/exec functions Cc: Thomas Gleixner , Kyle Zeng , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178683298903.1542179.8748527561234052984.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 221b62e97811845340c888993ae049467399d2b5 Gitweb: https://git.kernel.org/tip/221b62e97811845340c888993ae049467= 399d2b5 Author: Thomas Gleixner AuthorDate: Fri, 07 Aug 2026 17:07:17 +02:00 Committer: Thomas Gleixner CommitterDate: Sun, 16 Aug 2026 00:16:32 +02:00 futex: Clean up the redundant exit/exec functions futex_exit_release() and futex_exec_release() are identical now. That means also exit_mm_release() and exec_mm_release() are identical. Consolidate the whole lot and remove the redundant copies. Signed-off-by: Thomas Gleixner Reviewed-by: Kyle Zeng Acked-by: Peter Zijlstra --- fs/exec.c | 2 +- include/linux/futex.h | 6 ++---- include/linux/sched/mm.h | 10 ++++++---- kernel/exit.c | 2 +- kernel/fork.c | 10 ++-------- kernel/futex/core.c | 37 +++++++++++++++++-------------------- 6 files changed, 29 insertions(+), 38 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index d01523d..22df492 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -856,7 +856,7 @@ static int exec_mmap(struct linux_binprm *bprm) tsk =3D current; old_mm =3D current->mm; /* Clean up futexes and release the mm */ - exec_mm_release(tsk, old_mm); + mm_exit_exec_release(tsk, old_mm); =20 ret =3D down_write_killable(&tsk->signal->exec_update_lock); if (ret) diff --git a/include/linux/futex.h b/include/linux/futex.h index 51d5faa..18ed18d 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -71,8 +71,7 @@ static inline void futex_init_task(struct task_struct *ts= k) } =20 void futex_exit_recursive(struct task_struct *tsk); -void futex_exit_release(struct task_struct *tsk); -void futex_exec_release(struct task_struct *tsk); +void futex_exit_exec_release(struct task_struct *tsk); void futex_exec_done(struct task_struct *tsk); =20 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, @@ -90,8 +89,7 @@ static inline int futex_hash_free(struct mm_struct *mm) {= return 0; } #else /* CONFIG_FUTEX */ static inline void futex_init_task(struct task_struct *tsk) { } static inline void futex_exit_recursive(struct task_struct *tsk) { } -static inline void futex_exit_release(struct task_struct *tsk) { } -static inline void futex_exec_release(struct task_struct *tsk) { } +static inline void futex_exit_exec_release(struct task_struct *tsk) { } static inline void futex_exec_done(struct task_struct *tsk) { } static inline long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *t= imeout, u32 __user *uaddr2, u32 val2, u32 val3) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 95d0040..7fe7dfd 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -155,10 +155,12 @@ extern struct mm_struct *get_task_mm(struct task_stru= ct *task); * succeeds. */ extern struct mm_struct *mm_access(struct task_struct *task, unsigned int = mode); -/* Remove the current tasks stale references to the old mm_struct on exit(= ) */ -extern void exit_mm_release(struct task_struct *, struct mm_struct *); -/* Remove the current tasks stale references to the old mm_struct on exec(= ) */ -extern void exec_mm_release(struct task_struct *, struct mm_struct *); + +/* + * Remove the current tasks stale references to the old mm_struct on exit(= ) and + * exec(). Cleans up futexes as well. + */ +extern void mm_exit_exec_release(struct task_struct *, struct mm_struct *); =20 #ifdef CONFIG_MEMCG extern void mm_update_next_owner(struct mm_struct *mm); diff --git a/kernel/exit.c b/kernel/exit.c index 2c0b1c0..adf93b9 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -582,7 +582,7 @@ static void exit_mm(void) { struct mm_struct *mm =3D current->mm; =20 - exit_mm_release(current, mm); + mm_exit_exec_release(current, mm); if (!mm) return; =20 diff --git a/kernel/fork.c b/kernel/fork.c index f0e2e13..7c6918b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1502,15 +1502,9 @@ static void mm_release(struct task_struct *tsk, stru= ct mm_struct *mm) complete_vfork_done(tsk); } =20 -void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm) +void mm_exit_exec_release(struct task_struct *tsk, struct mm_struct *mm) { - futex_exit_release(tsk); - mm_release(tsk, mm); -} - -void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm) -{ - futex_exec_release(tsk); + futex_exit_exec_release(tsk); mm_release(tsk, mm); } =20 diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 3c1562d..2d1dbde 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -1537,32 +1537,29 @@ static void futex_cleanup_end(struct task_struct *t= sk) mutex_unlock(&tsk->futex.exit_mutex); } =20 -void futex_exit_release(struct task_struct *tsk) +/* + * Invoked from mm_exit_exec_release() to cleanup the robust lists and pi = state + * of the outgoing task. + * + * exec() makes it interesting for futexes because the TID of the task sta= ys the + * same, but from a futex perspective the task has to be treated like an e= xiting + * task. This is especially important for the sanity check for private fut= exes + * in attach_to_pi_owner() which compares the owner's mm with the waiter's= mm. + * + * That check would give the wrong answer if futex_cleanup_end() would + * set the state to FUTEX_STATE_OK as long as the task still has the old + * mm. + * + * After the task has switched to the new mm it sets it to + * FUTEX_STATE_OK again in futex_exec_done(). + */ +void futex_exit_exec_release(struct task_struct *tsk) { futex_cleanup_begin(tsk); futex_cleanup(tsk); futex_cleanup_end(tsk); } =20 -void futex_exec_release(struct task_struct *tsk) -{ - /* - * exec() makes it interesting for futexes because the TID of the task - * stays the same, but from a futex perspective the task has to be - * treated like an exiting task. This is especially important for the - * sanity check for private futexes in attach_to_pi_owner() which - * compares the owner's mm with the waiter's mm. - * - * That check would give the wrong answer if futex_cleanup_end() would - * set the state to FUTEX_STATE_OK as long as the task still has the old - * mm. - * - * After the task has switched to the new mm it sets it to - * FUTEX_STATE_OK again in futex_exec_done(). - */ - futex_exit_release(tsk); -} - /* * exec() has switched to the new mm. Futex operations are safe again. */