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 D9F1E35A3A7 for ; Fri, 27 Feb 2026 17:12:32 +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=1772212354; cv=none; b=UMs56vDHea9bvk8EWUOcUO1BocpeYVoeAJIPF61S2T3VKHRKqmM6Bpd/G6j0ZleBDDP4Jn6+FKMziAFtJ51XijUCxaYoL4WkM3x8Zhv+QSZooCp8aQH69l0ontV43t+J7k+Z2tKIRlf4Vq2A5SDhtiL/ezDNO4bZ1vUqgWg+OgQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772212354; c=relaxed/simple; bh=GYEQzcQeSTjQnMBHNVaK2W/LG7BzpdVH0+pX5skOYlM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Uh2zpnjsLeXJX8V0aD3V2AxLj+/N9RWpJUcoN45ydEvqVNEbU8Ewwhvybb6f1H5TorhRGRK4nVBA9pHFu5bZxrJxWfizKlmfw9OEcRSrvzeY5r2I3c3WsT4pvQzjA5uEzC/J0yexeMexv1VJ/rh0ekVbthKjswyMUeX7hpljQ5U= 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=oRb1CTVa; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3tYNi+kK; 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="oRb1CTVa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3tYNi+kK" Date: Fri, 27 Feb 2026 18:12:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772212351; 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=V/9pV6rq9Yv642eexnF8YqV7qkJvpkpDkkBdgDiWNbA=; b=oRb1CTVasm7WZNiVbWNVUSYPkNl69cRfGu9HWvAbmtfOuz6EK/f09vNz+83qntq8+ZnFhp Ft1NZcENhDFRStpu20a2/fCg6yERsNmy3hYhaKAWxcAQOmPj0k5QKilJOhs1UPj4Zeld56 zT1cMirMpSnBYqbuJKWAAL9qNPXgss88Oa2Ves0Pi+qDppQUeKJ+oJTOCLfaNtETne3+BK gMIR6WLxJ5wzJPbMPFikMTf7Pax6nw1O1KgXbDW5GqM8SfciGMntgNVZs7Gw8a1NioTiSY nlEuGy7hnmZnAnsWi+YsOpBlBM6AYS0IKdpdmYHW3v7a6bK8iImjRmMPFUc+xQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772212351; 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=V/9pV6rq9Yv642eexnF8YqV7qkJvpkpDkkBdgDiWNbA=; b=3tYNi+kKFnNI2sPsWxVnDFTF59u2DNtx0ZBcmkglqh5Nbuv/i6xO2LCRRKZs7Mp7TdT9D9 1QjIZ1W5t/t95UDg== From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: K Prateek Nayak , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, Darren Hart , Davidlohr Bueso , =?utf-8?B?QW5kcsOp?= Almeida Subject: Re: [RFC PATCH] futex: Dynamically allocate futex_queues depending on nr_node_ids Message-ID: <20260227171230.b4w4sE25@linutronix.de> References: <20260128101358.20954-1-kprateek.nayak@amd.com> <20260227144203.GJ1282955@noisy.programming.kicks-ass.net> <20260227161841.GH606826@noisy.programming.kicks-ass.net> 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: <20260227161841.GH606826@noisy.programming.kicks-ass.net> On 2026-02-27 17:18:41 [+0100], Peter Zijlstra wrote: > Ooh, I just remebered, I've always wanted to apply Linus' runtime-const > stuff to the futex thing. I wasn't aware we have this, I did want to do/ have something like this. Need to look at this in detail but=E2=80=A6 > --- a/kernel/futex/core.c > +++ b/kernel/futex/core.c > @@ -439,14 +442,14 @@ __futex_hash(union futex_key *key, struct futex_pri= vate_hash *fph) > * NOTE: this isn't perfectly uniform, but it is fast and > * handles sparse node masks. > */ > - node =3D (hash >> futex_hashshift) % nr_node_ids; > + node =3D runtime_const_shift_right_32(hash, __futex_shift) % nr_node_i= ds; getting rid of that div here would be the next step. If we could round it up to the next pow2 then we could avoid it. But I remember it did not show up in bench as much as I was thinking it would. > if (!node_possible(node)) { Sebastian