From nobody Thu Dec 18 20:19:26 2025 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 ACC211A0706 for ; Wed, 18 Dec 2024 11:16:30 +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=1734520594; cv=none; b=YQstZqyJo9VDx35daDTSSZbx0oTNiJOozXJJmblbZ7XgSHatwb88uG6KeqwZ48laTT9yDMMkZMZg+wR5ks1xDvZ5BVYpXSSKivVfsy92qrJfxuyAdOeE+g4iVEGEPNKzZWS5JCLyPBlJ8gB2ypC42h62FnfluysnJlva1DxUbvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734520594; c=relaxed/simple; bh=XCZnUcVRTg/OdBNdYd0llHPmAfBHZiYKdMr5bvCqgZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KGF3N2slhUC4TKcE6n4GR7urAnrp/HGD2Vs6gOlZzb9OTCe1uMDRT/kNBFKaXo03AnI2esmAhpMmal5yIcuPh4nx5n4fgRPx9ZE2eacLGzToc25edyAq7n2erE9uMIp+9Sq1vN7DZob5W+JuHGKTXptUpientP1Y4lQhlGVLdMU= 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=oVd2RRy6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=y2a7l/St; 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="oVd2RRy6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="y2a7l/St" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1734520587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FjMoQW4IUAh/X7O25zMu1DmUj0sv7Y/29SSuFX54hl0=; b=oVd2RRy62yB59XKqHW51YkKhmwsmSmX5PF6Gd68ikCHYK5hfh6G1ZDZXDKprv+7b2eKZx5 KKL+oo8yV13TTSytG5+u9QH/MxLIIJjKFye5JCGNGOljTKGIKxhrxsV4MYnkqWUYSZ0lFz NDSejLlT6v2N5UOItBZy1YeZLsXrsKZuoG4FdbK/+n5lgJYzz9bQ/nkUF9ShTV2bki3a9j 1IEZ/dH/1R6kL5XItR3hanq5t9481DygE5MAUqF23t9MBRBTKG3+R9qRWzjfTOYaRNrikr +KgWoXpQqtMxYdDf7ltlyEgNpD05UaNauBDj9MDyKlm/q3aSijbPTepVU5+0WA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1734520587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FjMoQW4IUAh/X7O25zMu1DmUj0sv7Y/29SSuFX54hl0=; b=y2a7l/St8NL21PbSUVy0qGg5rlf9J320OKt+6wh95LWeYX/NjSL3WFKc6K5ArwK/9EqWMb k3uZzSVhnu/V7nAQ== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH v6 05/15] futex: Move private hashing into its own function. Date: Wed, 18 Dec 2024 12:09:43 +0100 Message-ID: <20241218111618.268028-6-bigeasy@linutronix.de> In-Reply-To: <20241218111618.268028-1-bigeasy@linutronix.de> References: <20241218111618.268028-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hashing of the private is slightly different and will be needed again while moving a futex_q entry to a different hash bucket after the resize. Move the private hashing into its own function. Signed-off-by: Sebastian Andrzej Siewior --- kernel/futex/core.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 583a0149d62c9..907b76590df16 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -117,6 +117,18 @@ static inline bool futex_key_is_private(union futex_ke= y *key) return !(key->both.offset & (FUT_OFF_INODE | FUT_OFF_MMSHARED)); } =20 +static struct futex_hash_bucket *futex_hash_private(union futex_key *key, + struct futex_hash_bucket *fhb, + u32 hash_mask) +{ + u32 hash; + + hash =3D jhash2((void *)&key->private.address, + sizeof(key->private.address) / 4, + key->both.offset); + return &fhb[hash & hash_mask]; +} + /** * futex_hash - Return the hash bucket in the global hash * @key: Pointer to the futex key for which the hash is calculated @@ -131,14 +143,9 @@ struct futex_hash_bucket *futex_hash(union futex_key *= key) u32 hash; =20 fhb =3D current->mm->futex_hash_bucket; - if (fhb && futex_key_is_private(key)) { - u32 hash_mask =3D current->mm->futex_hash_mask; + if (fhb && futex_key_is_private(key)) + return futex_hash_private(key, fhb, current->mm->futex_hash_mask); =20 - hash =3D jhash2((void *)&key->private.address, - sizeof(key->private.address) / 4, - key->both.offset); - return &fhb[hash & hash_mask]; - } hash =3D jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4, key->both.offset); --=20 2.45.2