From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4AE4219005E for ; Wed, 23 Sep 2026 05:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790141666; cv=none; b=MgLmk+yp7HM4RMjXYevV1dbv9N0BGKI19VFBNiopChtASKQE0usOwdCDCoJRjyV9Oaedtgg0SJG+csCE76OXfAQ7+aSuERMHFnt+d9ID0qGtsd025Dh5f1YJwAXIyMIbEA9k6ndRGpZOTPkUqetgeBzhzW5HYA7W3MIAZR6x0jI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790141666; c=relaxed/simple; bh=+Zd3h5u6N+N5Ms7Szim1Fw+hrsr+ojwPPp/37WoWfI0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PZjmMZYaOKkggV8Lrx8D3WH+6tTEiDZnH/7EgxlWq4oYBhBB8uOAZFNAz/WqvMOrQugOJGbkEaUn08ZlXh6XB5FXqMUlM/HHjFew1/OkkPyaUlu/MNq49yAbdQDzj/cdok6SXXugNf/DDtTyJeJLsC+HVaqSxb/PRRWE1k8IvCI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G4ONNA1d; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G4ONNA1d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7304F1F00898; Wed, 23 Sep 2026 05:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790141664; bh=M5qIhAjSX1NSy0AvzqnkHxwmMfSEPWJSFmMa4qL9iMM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=G4ONNA1dZoq/yr93y343aEaiUpDPnZiwRawbVrY7ed096MYGtO+Kdk1uAc6nrYoOS VVeRQ9+iwLaJO8+lyH3YJSqVM/nHMHVEKkYsf9Kpwiwbmyea3DzUVnS34NtvKzTKBK 5Rqb+qFV7ampKZzlhYwZ49ESeNw2Z+jKfAdi5K28gGuIOCTRAmDvYYGoN3B5NrCRcq g8grf4al4Mp2y/uRvxFRS6aTiZWAdX5OYdTyhbKgdHr/VwH/+soYbmq5mbwkm9bYQ0 zipp84svI52KqnlC/LnsTLAurMZKVSMHlS+3+cAWpbFEmCF1xVRD70x/iCrx3clyUR uVIHXqgeOt/Fw== Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.phl.internal (Postfix) with ESMTP id A532FF40066; Wed, 23 Sep 2026 01:34:23 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 23 Sep 2026 01:34:23 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEQDudFIUlzSD9LylPJ3BOxVkG7BdYtkVRlhef6vQpZn2CP8M+xdcB0Xnip6noRBy 6lkEKhqtF8BIcGjfAFbMve/DITNFQE3eyIbaxUZLQSOZwIS70IrYT/WHozBsKooDflAwhE 39VY8OEqjEWPf3nIcoDXom0nFUJSd7OS3yag1Y4E/vVTLvTw74PGAA6UPkKZaMshEKcEXh HuzAIUUNlSFtKRk4dnJSg7lX/fbAF4hlEmW5xRAkVjqbXNJjVL+pOe0BYRmIMV3bv0wiS5 YQruk/eft1kOzXyBCyjrUFjHzv4rseGHMxIZBkPYJtSCOkRSsFT5hXMgh1+qUsGhJXbhUw 3v5796LwlNf0sgol29iSA+DG2C4znad2xCKB/enaQcF2/dLfEOHLAz4lwMYJfTLULRUH3t A9zFaHDqoCrXfuy3PSjvFcgd6FkhZCb0rifxPwgXEX9uDOdSPemPKF5/tGHW+WgIcGaz8I pvBYo7mxu7LLKDWV+AwwoIQ88kMtadoO9j0MAQR+sZtJ8UsPmJNxq5z950wBE+WvlQMF1f FuxPCByTwLWvfZ0h0SXXGdW72mIHgFao4yh0BdKcsw635Y9oa+aU2rPe9VUaYmLimhcAlY YjeZu6+ggNzD/WaOBjT58cE+gV3Ji4PnJha4IWMRsfPVF0coBerL2dsajM/w X-ME-Proxy: Feedback-ID: i8dbe485b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Sep 2026 01:34:23 -0400 (EDT) Date: Wed, 23 Sep 2026 07:34:22 +0200 From: Boqun Feng To: Onur =?iso-8859-1?Q?=D6zkan?= Cc: rust-for-linux@vger.kernel.org, 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 Subject: Re: [PATCH v9 2/7] ww_mutex: add ww_class field unconditionally Message-ID: References: <20260102175302.194435-1-work@onurozkan.dev> <20260102175302.194435-3-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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260102175302.194435-3-work@onurozkan.dev> On Fri, Jan 02, 2026 at 08:52:57PM +0300, Onur Özkan wrote: > 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. > @Peter and @Waiman, any dispute on this patch? I would like to make some progress on this since it'll be needed for GPUVM and KMS if I understand correctly. Regards, Boqun > Link: https://lore.kernel.org/all/ECC0425A-8B18-4626-8EA8-2F843C45E0A1@collabora.com/ > Signed-off-by: Onur Özkan > --- > 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 > }; > > 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_key); > lock->ctx = NULL; > -#ifdef DEBUG_WW_MUTEXES > lock->ww_class = ww_class; > -#endif > } > > /** > @@ -147,8 +143,8 @@ static inline void ww_acquire_init(struct ww_acquire_ctx *ctx, > ctx->acquired = 0; > ctx->wounded = false; > ctx->is_wait_die = ww_class->is_wait_die; > -#ifdef DEBUG_WW_MUTEXES > ctx->ww_class = ww_class; > +#ifdef DEBUG_WW_MUTEXES > ctx->done_acquire = 0; > ctx->contending_lock = NULL; > #endif > -- > 2.51.2 >