From nobody Sun Feb 8 16:50:52 2026 Received: from forward102a.mail.yandex.net (forward102a.mail.yandex.net [178.154.239.85]) (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 E52D629B8E6; Sat, 3 Jan 2026 07:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.85 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767425784; cv=none; b=mbJ8aH042YshOTcZnok8Kg3KWbVKj3GbqnEHk+AM6u0nTTHLKU9P6Q0qBLuePnBpTWiC5mbTc/JMJfzbB7n+/7Ua1iUAw8TBOC2wU0kQfGX8gIrOzBeTEtYUXqo/Ys0LFFJ40Luy64g4dQxdLI4l2R1P+mEaJ1CeU8DkmpcxdjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767425784; c=relaxed/simple; bh=6F/+tezkEB2vztihYOYq49PMzQhO8YkLYqMevzRARmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oUuxD5ovwRo/UnjesOjll4x2kksywFtiNi6rwUpIIdWw0RBxPaGMxQ4O7hkNPcIvY34hvv3xf/M3QyQ02nU43m5sDBWkQnJEq0vk56ttvtRytpjytX1O0tLUEi5iYZ2rhaGtkujhHRm0GXRk1DqHu0eJOJIPpLNxSfrTIeiJ56k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=onurozkan.dev; spf=pass smtp.mailfrom=onurozkan.dev; dkim=pass (1024-bit key) header.d=onurozkan.dev header.i=@onurozkan.dev header.b=jn04MPaK; arc=none smtp.client-ip=178.154.239.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=onurozkan.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=onurozkan.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=onurozkan.dev header.i=@onurozkan.dev header.b="jn04MPaK" Received: from mail-nwsmtp-smtp-production-main-97.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-97.vla.yp-c.yandex.net [IPv6:2a02:6b8:c15:2804:0:640:a3ea:0]) by forward102a.mail.yandex.net (Yandex) with ESMTPS id DA82EC0056; Sat, 03 Jan 2026 10:36:19 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-97.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id vZgUW4MHrmI0-YOFnTbUf; Sat, 03 Jan 2026 10:36:19 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onurozkan.dev; s=mail; t=1767425779; bh=8pibJ9wAikpYKSyeQ9ysDFVDnPDbGtUh727m8wRpnxs=; h=Cc:Message-ID:References:Date:In-Reply-To:Subject:To:From; b=jn04MPaKjWcvTMqLTVWsNbW02JwiUmTezQBk+2QfkxvujCsk0c+6jukXyplMDzzHT wU1uLsvymkfq5TdoTO3HX4spGdeKel0CN2DyJCihUFCoxZco8pqxJbyu/V3MwxMTxl 2MaKuKlw5gwLoAw8l2GKSKEt9cJrxLV6CrQZcLZI= Authentication-Results: mail-nwsmtp-smtp-production-main-97.vla.yp-c.yandex.net; dkim=pass header.i=@onurozkan.dev From: =?UTF-8?q?Onur=20=C3=96zkan?= To: rust-for-linux@vger.kernel.org Cc: lossin@kernel.org, lyude@redhat.com, ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, felipe_life@live.com, daniel@sedlak.dev, daniel.almeida@collabora.com, thomas.hellstrom@linux.intel.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Onur=20=C3=96zkan?= Subject: [PATCH v10 2/7] ww_mutex: add ww_class field unconditionally Date: Sat, 3 Jan 2026 10:35:49 +0300 Message-ID: <20260103073554.34855-3-work@onurozkan.dev> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260103073554.34855-1-work@onurozkan.dev> References: <20260103073554.34855-1-work@onurozkan.dev> 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-Transfer-Encoding: quoted-printable Removes DEBUG_WW_MUTEXES guard around the ww_class field in struct ww_mutex and struct ww_acquire_ctx to always initialize it. Keeping the class pointer available unconditionally allows Rust abstractions to keep from_raw() simple on Mutex and AcquireCtx, simplify AcquireCtx reinitialization logic and validate Mutex and AcquireCtx class pairing in much simpler way. Link: https://lore.kernel.org/all/ECC0425A-8B18-4626-8EA8-2F843C45E0A1@coll= abora.com/ Signed-off-by: Onur =C3=96zkan --- include/linux/ww_mutex.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h index 45ff6f7a872b..c9835035b6d6 100644 --- a/include/linux/ww_mutex.h +++ b/include/linux/ww_mutex.h @@ -47,9 +47,7 @@ struct ww_class { struct ww_mutex { struct WW_MUTEX_BASE base; struct ww_acquire_ctx *ctx; -#ifdef DEBUG_WW_MUTEXES struct ww_class *ww_class; -#endif }; =20 struct ww_acquire_ctx { @@ -58,9 +56,9 @@ struct ww_acquire_ctx { unsigned int acquired; unsigned short wounded; unsigned short is_wait_die; + struct ww_class *ww_class; #ifdef DEBUG_WW_MUTEXES unsigned int done_acquire; - struct ww_class *ww_class; void *contending_lock; #endif #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -110,9 +108,7 @@ static inline void ww_mutex_init(struct ww_mutex *lock, { ww_mutex_base_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_ke= y); lock->ctx =3D NULL; -#ifdef DEBUG_WW_MUTEXES lock->ww_class =3D ww_class; -#endif } =20 /** @@ -147,8 +143,8 @@ static inline void ww_acquire_init(struct ww_acquire_ct= x *ctx, ctx->acquired =3D 0; ctx->wounded =3D false; ctx->is_wait_die =3D ww_class->is_wait_die; -#ifdef DEBUG_WW_MUTEXES ctx->ww_class =3D ww_class; +#ifdef DEBUG_WW_MUTEXES ctx->done_acquire =3D 0; ctx->contending_lock =3D NULL; #endif --=20 2.51.2