From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BF858411636 for ; Thu, 19 Mar 2026 23:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962689; cv=none; b=gCu5EGcwAQOwL5GnM1N5qKQ1WSw3czAD8cPjdF7B1YiajMEEZ996QumR1FUddxn8i727H9t9vZQbgIENdPzati1bWg6VeuhkgN9MLLkCKdGyVfYYLyxhYe5ouTJfcxF72aBk9ahgLePBH5DwRGdNL24BEwXdZy1uhSTTqX+WNfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962689; c=relaxed/simple; bh=BjaccXKUTAyl/qBzmxWweVic3+CIETV+NR6ZsoI2m2o=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=hSrilSFoiu1wZn/yleY+xh9I7rVVI4kVPsWMaKPHVVs99Pr+iAHMUFgZ3RNSP9c69mtXfBVvXr7sobuPvAIMyuPCfCNCX7Fz7oXe1W39ykkNJrjDIiZ6uyFq2z7uhApHzyCdeuQAYxCqt0Y/uG7v/CbXr1rzntNfCYYVQuQbxvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bJAahE6V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bJAahE6V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E18DCC2BCAF; Thu, 19 Mar 2026 23:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773962689; bh=BjaccXKUTAyl/qBzmxWweVic3+CIETV+NR6ZsoI2m2o=; h=Date:From:To:Cc:Subject:References:From; b=bJAahE6VTIKxqUbdzPC62jV8Xr4LyawqcANFRJRChJcRs5L0H5EfX9Vk7hY8ctkCW fI45iwdZEmLr8Cy3Kz4uDTgDO+/RSy1tR6+gr17LeYavIkJhbrUi5fqZMswwGhlNrL Nx/58wiktAS7vqn8wGEgxk7t3UEqroXrIboyZSJ1b1YY0596P4CtYQpBURL1SZu0Jk g+yY30rqjYYmxLUMEWBn0R6gusNHLSTO8TLj/ZgUyQI9MygI6dGaZE4Kpg2GfNWSiZ mN+3yvFrCqi0n36MgtIslN3nZUlFEgSdEMuNv7n3kekiLUEtPqYdgNwxU4UDPP5v/n XaCcDCebh9cdA== Date: Fri, 20 Mar 2026 00:24:46 +0100 Message-ID: <20260319231239.682582451@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Mathieu Desnoyers , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , "Liam R . Howlett" , Uros Bizjak , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [patch v2 08/11] futex: Add robust futex unlock IP range References: <20260319225224.853416463@kernel.org> 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 There will be a VDSO function to unlock robust futexes in user space. The unlock sequence is racy vs. clearing the list_pending_op pointer in the tasks robust list head. To plug this race the kernel needs to know the instruction window. As the VDSO is per MM the addresses are stored in mm_struct::futex. Architectures which implement support for this have to update these addresses when the VDSO is (re)mapped and indicate the pending op pointer size which is matching the IP. Arguably this could be resolved by chasing mm->context->vdso->image, but that's architecture specific and requires to touch quite some cache lines. Having it in mm::futex reduces the cache line impact and avoids having yet another set of architecture specific functionality. To support multi size robust list applications (gaming) this provides two ranges. Signed-off-by: Thomas Gleixner --- V2: Store ranges in a struct with size information and allow up to two ranges. --- include/linux/futex_types.h | 22 ++++++++++++++++++++++ include/linux/mm_types.h | 1 + init/Kconfig | 6 ++++++ 3 files changed, 29 insertions(+) --- a/include/linux/futex_types.h +++ b/include/linux/futex_types.h @@ -31,6 +31,20 @@ struct futex_sched_data { }; /** + * struct futex_unlock_cs_range - Range for the VDSO unlock critical section + * @start_ip: The start IP of the robust futex unlock critical section (inclusive) + * @end_ip: The end IP of the robust futex unlock critical section (exclusive) + * @pop_size32: Pending OP pointer size indicator. 0 == 64-bit, 1 == 32-bit + */ +struct futex_unlock_cs_range { + unsigned long start_ip; + unsigned long end_ip; + unsigned int pop_size32; +}; + +#define FUTEX_ROBUST_MAX_CS_RANGES 2 + +/** * struct futex_mm_data - Futex related per MM data * @phash_lock: Mutex to protect the private hash operations * @phash: RCU managed pointer to the private hash @@ -39,6 +53,10 @@ struct futex_sched_data { * @phash_rcu: RCU head for call_rcu() * @phash_atomic: Aggregate value for @phash_ref * @phash_ref: Per CPU reference counter for a private hash + * + * @unlock_cs_num_ranges: The number of critical section ranges for VDSO assisted unlock + * of robust futexes. + * @unlock_cs_ranges: The critical section ranges for VDSO assisted unlock */ struct futex_mm_data { #ifdef CONFIG_FUTEX_PRIVATE_HASH @@ -50,6 +68,10 @@ struct futex_mm_data { atomic_long_t phash_atomic; unsigned int __percpu *phash_ref; #endif +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK + unsigned int unlock_cs_num_ranges; + struct futex_unlock_cs_range unlock_cs_ranges[FUTEX_ROBUST_MAX_CS_RANGES]; +#endif }; #else --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -22,6 +22,7 @@ #include #include #include +#include #include --- a/init/Kconfig +++ b/init/Kconfig @@ -1822,6 +1822,12 @@ config FUTEX_MPOL depends on FUTEX && NUMA default y +config HAVE_FUTEX_ROBUST_UNLOCK + bool + +config FUTEX_ROBUST_UNLOCK + def_bool FUTEX && HAVE_GENERIC_VDSO && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FUTEX_ROBUST_UNLOCK + config EPOLL bool "Enable eventpoll support" if EXPERT default y