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 1382220B810 for ; Fri, 27 Mar 2026 13:24:58 +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=1774617900; cv=none; b=gs1LQfl4Hnw2hNMsd1hODJU6SMxEqaAnqnNLBa8kZnaIlslTWRL1GEzwl1RPS2oXw/6wUnlMl6MLhJYF4NI5manCVRxpy2y3Des81AdO+r6iZ3c5hDvLJjQhkorxY4vY+rVoB5ABeDhfHoowS/7c22WsBDrBmcWN5TSLqFzNcEY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774617900; c=relaxed/simple; bh=FrB4206Us3IOBXm98eRoglyify5tjYtbvHhIPJN2Wh0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k527fHV1+Bgw9pLz9RzLyBcWsh/9lfCX8ul+x0T5vHMY0vgZ+dd9qMWaurdZfDBsHh6/MQNGQeWS8jriWaebLGZ8ZZZXdgrQpvB70DD1DvvjbAL8zhrKsvSlLl43E9Pl3emYjvvaq5IHOZ0DHXKE5KV8L91hlUGmsV2uUu+M6hk= 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=IFztqb4b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kLLB6ka0; 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="IFztqb4b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kLLB6ka0" Date: Fri, 27 Mar 2026 14:24:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774617897; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vFr52eT10C92sVd19RFl2hDvKTMnnGM8scY1bhVtYZc=; b=IFztqb4bz1BeY4pMc9G6gvzKhT+71/XlOGJ+qsurBbXHfJfyIki9LX3HI5JuBWJ6IsCTWH befzreLAXXeqzN6Cubz5aU+pSccYeLmH1J/h2g0TO1YgIBgIKuYIV94sw3Bx0YpPasalU8 tswb6XyHYqFvvlfEQAhfvqoCofL3OYI4XyBpWGvgx8UrhMfR9CZ6K3hwEpGs5XVt8SuJZH TzGPyHseelz6BD8GWQ+TWgEaFJ+G1buQgrVkVpkkkYuaR2XtYbGQbcx7qOef3yG3HTlrT2 VjeOmq1ojserO5/JPvZHwZArbgOrAJIfNN18Q8hLpkpgHyhg/bA5WyLXhj2z4w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774617897; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vFr52eT10C92sVd19RFl2hDvKTMnnGM8scY1bhVtYZc=; b=kLLB6ka0+7CIoCD6MYFD8gctYD+Q5K7TXhHQYhHQgTFWWuMKVzc/oKFOuTztZqK2N2xP+i 2ZYrkwx2rB1ZGECQ== From: Sebastian Andrzej Siewior To: Thomas Gleixner Cc: LKML , Mathieu Desnoyers , =?utf-8?B?QW5kcsOp?= Almeida , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , "Liam R . Howlett" , Uros Bizjak , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= Subject: Re: [patch v2 08/11] futex: Add robust futex unlock IP range Message-ID: <20260327132455.e0PX5nfN@linutronix.de> References: <20260319225224.853416463@kernel.org> <20260319231239.682582451@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 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20260319231239.682582451@kernel.org> On 2026-03-20 00:24:46 [+0100], Thomas Gleixner wrote: > --- a/include/linux/futex_types.h > +++ b/include/linux/futex_types.h > @@ -31,6 +31,20 @@ struct futex_sched_data { =E2=80=A6 > =20 > +struct futex_unlock_cs_range { > + unsigned long start_ip; > + unsigned long end_ip; > + unsigned int pop_size32; > +}; > + > +#define FUTEX_ROBUST_MAX_CS_RANGES 2 =E2=80=A6 > @@ -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_RANGE= S]; > +#endif > }; While looking at this from an economic point of view, we get: | unsigned int * phash_ref; /* 80 8 */ | unsigned int unlock_cs_num_ranges; /* 88 4 */ | | /* XXX 4 bytes hole, try to pack */ | | struct futex_unlock_cs_range unlock_cs_ranges[2]; /* 96 48 */ |} |struct futex_unlock_cs_range { | long unsigned int start_ip; /* 0 8 */ | long unsigned int end_ip; /* 8 8 */ | unsigned int pop_size32; /* 16 4 */ | | /* size: 24, cachelines: 1, members: 3 */ | /* padding: 4 */ | /* last cacheline: 24 bytes */ |}; end_ip could be replaced with a u16 size. There is no need to have pop_size32 as u32, it could be a u16 filling the gap. On the other hand, pop_size32 could be passed by the caller since it is known if it is the first or the second member / the 64bit or 32bit case. unlock_cs_num_ranges could probably go because if start_ip =3D=3D NULL then there is no mapping since it can't be mapped at 0x0. Worst case would be to check two variables vs NULL. And if we replace end_ip with size then we could remove it because vdso is known at compile so we should know the size at compile time. Sebastian