From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7736976036; Sat, 5 Oct 2024 07:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728114057; cv=none; b=dJkArpFnYTBWuckTexFi1wTNcUQGmJteec8Sc4cnUf9hpKN6azs7MlAczk5TK6NXCVrygYQv6O2uj/LjEVvUhZE4B6MQZbrxVdWKvuQuRFIE3eJSSQ4Fuo06aA2RwbmNLrIm67XUW4jMsJNH05Ga672dykR/KZ2IalkogSMinSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728114057; c=relaxed/simple; bh=OOyGjemrI/6GNJZpq4lLbRxvulRXcPiW/aPQFXh7c6c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jz62s6MXfb9OMZ+oVlfGq5tbkJjRNTDH7Z6yePyxQvguRPkw5KDckfh/uPzjLN9JIkxfbv4jmqegitrSZSWXO4yKiobzoEnqIygZD1KEshcovrXH9UVvi/hNSk0QEJOsQYfw24PlJE2fjBlLhAnNVKCx8skVgyajq23tyvwRJOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qlowxjur; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qlowxjur" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C35AC4CEC2; Sat, 5 Oct 2024 07:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728114057; bh=OOyGjemrI/6GNJZpq4lLbRxvulRXcPiW/aPQFXh7c6c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qlowxjur4uhb0Ziu2f6fUriGDF632pACf4ITMBKMLnIISnGNxb2SK1/KhUwWkIg2h YnVGpfhEUy1TjkQVW2LVNZ8lRVlZjqxME1fH09RCpmiR00SBN9QbViG7pR0+iBxj9j /UXq4+H0DmBrnBW7VxkoxUytRLXQo0DN8MiNbU/Q= Date: Sat, 5 Oct 2024 09:40:53 +0200 From: Greg KH To: Gary Guo Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Martin Rodriguez Reboredo , Will Deacon , Peter Zijlstra , Mark Rutland , Dirk Behme , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH 1/3] rust: implement `kernel::sync::Refcount` Message-ID: <2024100505-aftermath-glue-7e61@gregkh> References: <20241004155247.2210469-1-gary@garyguo.net> <20241004155247.2210469-2-gary@garyguo.net> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241004155247.2210469-2-gary@garyguo.net> On Fri, Oct 04, 2024 at 04:52:22PM +0100, Gary Guo wrote: > This is a wrapping layer of `include/linux/refcount.h`. Currently only > the most basic operations (read/set/inc/dec/dec_and_test) are implemented, > additional methods can be implemented when they are needed. > > Currently the kernel refcount has already been used in `Arc`, however it > calls into FFI directly. > > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Mark Rutland > Signed-off-by: Gary Guo > --- > rust/helpers/refcount.c | 15 ++++++ > rust/kernel/sync.rs | 2 + > rust/kernel/sync/refcount.rs | 94 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 111 insertions(+) > create mode 100644 rust/kernel/sync/refcount.rs > > diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c > index f47afc148ec3..39649443426b 100644 > --- a/rust/helpers/refcount.c > +++ b/rust/helpers/refcount.c > @@ -8,11 +8,26 @@ refcount_t rust_helper_REFCOUNT_INIT(int n) > return (refcount_t)REFCOUNT_INIT(n); > } > > +unsigned int rust_helper_refcount_read(refcount_t *r) > +{ > + return refcount_read(r); > +} Reading a refcount is almost always a wrong thing to do (it can change right after you read it), and I don't see any of the later patches in this series use this call, so can you just drop this? thanks, greg k-h